jarikomppa / soloud

Free, easy, portable audio engine for games
http://soloud-audio.com
Other
1.69k stars 270 forks source link

SoLoud dynamic libraries do not work #342

Open haya3218 opened 2 years ago

haya3218 commented 2 years ago

Expected behavior:

SoLoud being dynamically linked using cmake

Actual behavior:

Multiple linker errors about how it could not find SoLoud functions

Steps to reproduce the problem:

Compile SoLoud as a dynamic library using GENie.

SoLoud version, operating system, backend used, any other potentially useful information:

SoLoud version 20200207 Windows 10 21H2 Microsoft VC++ 14.2 Miniaudio and SDL2 backends

Most linker errors go like this: error LNK2019: unresolved external symbol "public: void __cdecl SoLoud::AudioSource::setLooping(bool)" (?s etLooping@AudioSource@SoLoud@@QEAAX_N@Z)

EDIT: Static linking DOES work, however dynamically does not.

yuriy-chumak commented 2 years ago

Maybe this can help?

index 831fe75..99c21db 100644                                                                                                                                                                                                                --- a/contrib/src.cmake
+++ b/contrib/src.cmake                                                                                                                                                                                                                      @@ -287,7 +287,7 @@ if (SOLOUD_C_API)
 endif()
                                                                                                                                                                                                                                              if (SOLOUD_DYNAMIC)
-       add_library(${TARGET_NAME} ${TARGET_SOURCES})
+       add_library(${TARGET_NAME} SHARED ${TARGET_SOURCES})
 endif ()
                                                                                                                                                                                                                                              if (SOLOUD_STATIC)