I’m trying to link irrKlang to my CMake project. For that, I’ve started to follow this example.
Also, I’ve downloaded a 64-bit archive from the official website and put it in the third-party directory in my project, it looks like this (I expanded the directories that I consider necessary for further explanation):
I copied the code, fixed paths, and it builds successfully:
cmake_minimum_required(VERSION 3.28)
project(template)
...
set(THIRD_PARTY_DIR ${CMAKE_SOURCE_DIR}/third-party)
set(IRRKLANG_DIR ${THIRD_PARTY_DIR}/irrklang)
...
target_link_libraries(${PROJECT_NAME} ${IRRKLANG_DIR}/lib/Winx64-visualStudio/irrKlang.lib)
target_include_directories(${PROJECT_NAME} PUBLIC ${IRRKLANG_DIR}/include)
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${IRRKLANG_DIR}/bin/winx64-visualStudio/irrKlang.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/irrKlang.dll"
)
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${IRRKLANG_DIR}/bin/winx64-visualStudio/ikpFlac.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/ikpFlac.dll"
)
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${IRRKLANG_DIR}/bin/winx64-visualStudio/ikpMP3.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/ikpMP3.dll"
)
I use CLion in Windows 11, in Toolchains I see this:
CLion sees headers (I can include irrKlang.h), but this is not working:
#include "irrKlang.h"
irrklang::ISoundEngine *SoundEngine = irrklang::createIrrKlangDevice();
An error says: undefined reference to __imp__ZN8irrklang20createIrrKlangDeviceENS_21E_SOUND_OUTPUT_DRIVEREiPKcS2_
Also I tried to add #pragma comment(lib, "irrKlang.lib")
after the header, but it’s not working either.
DLL’s are copied to my exe path successfully.
As I understand it, this solution is not working for the GNU toolchain.
I’m not very good in connecting libraries in C++. What should I do?
Also, I tried to target_link_libraries
with .so
from bin/linux-gcc-64
and .exp
files from lib/Winx64-visualStudio
, but unsuccessfully.