# How to import TeamSpeak sdk in Cmake ?

**URL:** https://discourse.cmake.org/t/how-to-import-teamspeak-sdk-in-cmake/7211
**Category:** Usage
**Tags:** os:windows
**Created:** [January 8, 2023, 9:03pm UTC](https://discourse.cmake.org/t/how-to-import-teamspeak-sdk-in-cmake/7211 "2023-01-08T21:03:21Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Tchoune](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/a4c791/32.png) [@Tchoune](https://discourse.cmake.org/u/Tchoune)
#### Post date: [January 8, 2023, 9:03pm UTC](https://discourse.cmake.org/t/how-to-import-teamspeak-sdk-in-cmake/7211/1 "2023-01-08T21:03:22Z")

</div>

Hi  
I would like to use Teamspeak in a TrinityCore that uses Cmake.  
But I have a problem that I can’t import the TeamSpeak library.  
Here is my Cmakelists.txt configuration:

```auto
find_package(TSClientSdk REQUIRED COMPONENTS lib)
find_package(TSServerSdk REQUIRED COMPONENTS lib)

add_library(TSClientSdk UNKNOWN IMPORTED)
add_library(TSServerSdk UNKNOWN IMPORTED)

set_target_properties(TSClientSdk
  PROPERTIES
    IMPORTED_LOCATION
      "${TSClientSdk_LIBRARY}"
    INTERFACE_INCLUDE_DIRECTORIES
      "${TSClientSdk_INCLUDE_DIR}")

set_target_properties(TSServerSdk
  PROPERTIES
    IMPORTED_LOCATION
      "${TSServerSdk_LIBRARY}"
    INTERFACE_INCLUDE_DIRECTORIES
      "${TSServerSdk_INCLUDE_DIR}")

```

I have created environment variables on windows :  
TSClientSdk\_INCLUDE\_DIR : C:\Users\tchou\Downloads\ts3\_sdk\_3.1.1.0\ts3\_sdk\_3.1.1.0\include\teamspeak

TSClientSdk\_LIBRARY : C:\Users\tchou\Downloads\ts3\_sdk\_3.1.1.0\ts3\_sdk\_3.1.1.0\lib\windows\win64\ts3client.lib

TSServerSdk\_INCLUDE\_DIR :  
C:\Users\tchou\Downloads\ts3\_sdk\_3.1.1.0\ts3\_sdk\_3.1.1.0\include\teamspeak

TSServerSdk\_LIBRARY : C:\Users\tchou\Downloads\ts3\_sdk\_3.1.1.0\ts3\_sdk\_3.1.1.0\lib\windows\win64\ts3server.lib

And my configuration in Cmake:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/b/b7a2882447be259d959204bacf933a79de9b74dd.png)

But when I compile in visual studio :  
Error LNK1181 cannot open input file ‘TSClientSdk .lib’ worldserver C:\Users\tchou\Documents\BuildWow\src\serverworldserver\LINK 1

Does anyone have a procedure to add the Teamspeak library in Cmake ?  
Thanks a lot !

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 8, 2023, 10:38pm UTC](https://discourse.cmake.org/t/how-to-import-teamspeak-sdk-in-cmake/7211/2 "2023-01-08T22:38:14Z")

</div>

Try this:

```auto
set_target_properties(TSClientSdk
  PROPERTIES
    IMPORTED_IMPLIB
      "${TSClientSdk_LIBRARY}"
    INTERFACE_INCLUDE_DIRECTORIES
      "${TSClientSdk_INCLUDE_DIR}")

set_target_properties(TSServerSdk
  PROPERTIES
    IMPORTED_IMPLIB
      "${TSServerSdk_LIBRARY}"
    INTERFACE_INCLUDE_DIRECTORIES
      "${TSServerSdk_INCLUDE_DIR}")

```

`IMPLIB` on Windows is for the `.lib` while the `.dll` belongs in `IMPORTED_LOCATION`. The import/runtime library split is the cause of this necessity (and, for other reasons, the DLL is better in `LOCATION`).

---

<div class="post-metadata">

### Author: ![Tchoune](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/a4c791/32.png) [@Tchoune](https://discourse.cmake.org/u/Tchoune)
#### Post date: [January 8, 2023, 11:53pm UTC](https://discourse.cmake.org/t/how-to-import-teamspeak-sdk-in-cmake/7211/3 "2023-01-08T23:53:08Z")

</div>

Thanks for your help, I modified the file as you suggested. I deleted the cache and redid my configuration and I can’t find out if it is really imported on Cmake:

```auto
Detected 64-bit platform
MSVC: Minimum version required is 19.30, found 19.34.31937.0 - ok!
MSVC: 64-bit platform, enforced -D_WIN64 parameter
MSVC: Enabled increased number of sections in object files
MSVC: Overloaded standard names
MSVC: Disabled NON-SECURE warnings
MSVC: Disabled POSIX warnings
MSVC: Disabled generic compiletime warnings
Found MySQL: found components: binary 
Found MySQL executable: C:/Program Files/MySQL/MySQL Server 8.0/bin/mysql.exe

* TrinityCore revision : b6820a706f46+ 2023-01-08 00:01:09 +0100 (master branch)

* Install core to : C:/Program Files/TrinityCore
* Install configs to : C:/Program Files/TrinityCore

* Build world/auth : Yes (default)
* Build with scripts : Yes (static)
* Build map/vmap tools : Yes (default)
* Build unit tests : No (default)
* Build core w/PCH : Yes (default)
* Build scripts w/PCH : Yes (default)
* Show compile-warnings : No (default)
* Use coreside debug : No (default)
* Show source tree : Yes (hierarchical)
* Use GIT revision hash : Yes (default)

CMake Warning at C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:1384 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:1507 (_Boost_COMPONENT_DEPENDENCIES)
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:2118 (_Boost_MISSING_DEPENDENCIES)
  dep/boost/CMakeLists.txt:31 (find_package)

CMake Warning at C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:1384 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:1507 (_Boost_COMPONENT_DEPENDENCIES)
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:2118 (_Boost_MISSING_DEPENDENCIES)
  dep/boost/CMakeLists.txt:31 (find_package)

CMake Warning at C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:1384 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:1507 (_Boost_COMPONENT_DEPENDENCIES)
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:2118 (_Boost_MISSING_DEPENDENCIES)
  dep/boost/CMakeLists.txt:31 (find_package)

CMake Warning at C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:1384 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:1507 (_Boost_COMPONENT_DEPENDENCIES)
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:2118 (_Boost_MISSING_DEPENDENCIES)
  dep/boost/CMakeLists.txt:31 (find_package)

CMake Warning at C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:1384 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:1507 (_Boost_COMPONENT_DEPENDENCIES)
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindBoost.cmake:2118 (_Boost_MISSING_DEPENDENCIES)
  dep/boost/CMakeLists.txt:31 (find_package)

Found MySQL: C:/Program Files/MySQL/MySQL Server 8.0/lib/libmysql.lib found components: lib 
Found MySQL library: C:/Program Files/MySQL/MySQL Server 8.0/lib/libmysql.lib
Found MySQL headers: C:/Program Files/MySQL/MySQL Server 8.0/include
adding TeamSpeak Client SDK
CMAKE_SYSTEM_NAME: Windows
CMAKE_SYSTEM_PROCESSOR AMD64
CMAKE_GENERATOR_PLATFORM x64
TS_LIB_PATH: windows/win64
adding TeamSpeak Server SDK
CMAKE_SYSTEM_NAME: Windows
CMAKE_SYSTEM_PROCESSOR AMD64
TS_LIB_PATH: windows/win64

* Script configuration (static):
    |
    +- worldserver
    | +- Argus
    | +- Battlefield
    | +- BrokenIsles
    | +- Commands
    | +- Custom
    | +- Draenor
    | +- DragonIsles
    | +- EasternKingdoms
    | +- Events
    | +- Kalimdor
    | +- Maelstrom
    | +- Northrend
    | +- OutdoorPvP
    | +- Outland
    | +- Pandaria
    | +- Pet
    | +- Spells
    | +- VoiceChat
    | +- World
    |

Configuring done
Generating done

```

Then in my project to import I have a file cmakelists.txt in a folder scripts having added the library like this:

```auto
# Add the dynamic script modules to the worldserver as dependency
set(WORLDSERVER_DYNAMIC_SCRIPT_MODULES_DEPENDENCIES ${DYNAMIC_SCRIPT_MODULE_PROJECTS} PARENT_SCOPE)

ConfigureScriptLoader("static" SCRIPT_MODULE_PRIVATE_SCRIPTLOADER OFF ${STATIC_SCRIPT_MODULES})

add_library(scripts STATIC
  ScriptLoader.h
  ${SCRIPT_MODULE_PRIVATE_SCRIPTLOADER}
  ${PRIVATE_SOURCES})

target_link_libraries(scripts
  PRIVATE
    trinity-core-interface
  PUBLIC
    game-interface
    TSClientSdk)

target_include_directories(scripts
  PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR})

set_target_properties(scripts
  PROPERTIES
    FOLDER
      "scripts")

```

Does this look right to you?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 9, 2023, 1:32pm UTC](https://discourse.cmake.org/t/how-to-import-teamspeak-sdk-in-cmake/7211/4 "2023-01-09T13:32:38Z")

</div>

If it works, it looks fine to me.

---

<div class="post-metadata">

### Author: ![Tchoune](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/a4c791/32.png) [@Tchoune](https://discourse.cmake.org/u/Tchoune)
#### Post date: [January 9, 2023, 2:07pm UTC](https://discourse.cmake.org/t/how-to-import-teamspeak-sdk-in-cmake/7211/5 "2023-01-09T14:07:05Z")

</div>

Okay thanks, then I don’t understand why it doesn’t work. When I compile my project on Visual Studio 2022 I get this error:  
Error LNK1181 cannot open input file ‘TSClientSdk.lib’ worldserver C:\Users\tchou\Documents\BuildWow\src\serverworldserver\LINK 1

😕

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 9, 2023, 3:44pm UTC](https://discourse.cmake.org/t/how-to-import-teamspeak-sdk-in-cmake/7211/6 "2023-01-09T15:44:45Z")

</div>

Is there a `#pragma comment(TSClientSdk.lib)` in the TeamSpeak sources (called “autolinking”)? That tells the MSVC linker to also look for something; if you’re missing the link directory you’ll see something like this. There may be a define you can set it skip over it.

---

<div class="post-metadata">

### Author: ![xhustango](https://discourse.cmake.org/user_avatar/discourse.cmake.org/xhustango/32/1614_2.png) [@xhustango](https://discourse.cmake.org/u/xhustango)
#### Post date: [January 9, 2023, 4:12pm UTC](https://discourse.cmake.org/t/how-to-import-teamspeak-sdk-in-cmake/7211/7 "2023-01-09T16:12:27Z")

</div>

Hi there,  
Is the variable `"${TSClientSdk_LIBRARY}"` giving you the path to the library? It seems to me that the windows path is not set to the correct location.

Try to output the variable content with `message` in CMake to see what it contains.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 9, 2023, 6:40pm UTC](https://discourse.cmake.org/t/how-to-import-teamspeak-sdk-in-cmake/7211/8 "2023-01-09T18:40:02Z")

</div>

It was reported as a full path before:

> [@Tchoune](#):
>
> TSClientSdk\_LIBRARY : C:\Users\tchou\Downloads\ts3\_sdk\_3.1.1.0\ts3\_sdk\_3.1.1.0\lib\windows\win64\ts3client.lib

---

<div class="post-metadata">

### Author: ![xhustango](https://discourse.cmake.org/user_avatar/discourse.cmake.org/xhustango/32/1614_2.png) [@xhustango](https://discourse.cmake.org/u/xhustango)
#### Post date: [January 10, 2023, 2:41pm UTC](https://discourse.cmake.org/t/how-to-import-teamspeak-sdk-in-cmake/7211/9 "2023-01-10T14:41:17Z")

</div>

Yes, I saw it, I just was wondering if it was really found by CMake.

I had similar issues because of that, the path was even configured well the variable was empty. What it looks like to me is that CMake is trying to link with `TSClientSdk.lib` instead of `ts3client.lib`.

I have similar statements for importing already compiled libs, but I don’t get why it does not work for him, and is just looking for the incorrect library name.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 10, 2023, 2:47pm UTC](https://discourse.cmake.org/t/how-to-import-teamspeak-sdk-in-cmake/7211/10 "2023-01-10T14:47:12Z")

</div>

The full link line would clarify the issue. But this smells of autolinking to me.
