Closed Try closed 1 month ago
Please verify that 86df366 works for you @Try.
Works, but not quite. Now we have a problem of duplicating symbols:
gamemusic.cpp.obj:-1: ошибка: LNK2019: unresolved external symbol __imp_DmSegment_release referenced in function "public: virtual void __cdecl GameMusic::GothicKitMusicProvider::playTheme(struct zenkit::IMusicTheme const &,enum GameMusic::Tags)" (?playTheme@GothicKitMusicProvider@GameMusic@@UEAAXAEBUIMusicTheme@zenkit@@W4Tags@2@@Z)
gamemusic.cpp.obj:-1: ошибка: LNK2019: unresolved external symbol __imp_DmPerformance_create referenced in function "public: __cdecl GameMusic::GothicKitMusicProvider::GothicKitMusicProvider(unsigned short,unsigned short)" (??0GothicKitMusicProvider@GameMusic@@QEAA@GG@Z)
gamemusic.cpp.obj:-1: ошибка: LNK2019: unresolved external symbol __imp_DmPerformance_release referenced in function "public: virtual __cdecl GameMusic::GothicKitMusicProvider::~GothicKitMusicProvider(void)" (??1GothicKitMusicProvider@GameMusic@@UEAA@XZ)
gamemusic.cpp.obj:-1: ошибка: LNK2019: unresolved external symbol __imp_DmPerformance_playTransition referenced in function "public: virtual void __cdecl GameMusic::GothicKitMusicProvider::playTheme(struct zenkit::IMusicTheme const &,enum GameMusic::Tags)" (?playTheme@GothicKitMusicProvider@GameMusic@@UEAAXAEBUIMusicTheme@zenkit@@W4Tags@2@@Z)
gamemusic.cpp.obj:-1: ошибка: LNK2019: unresolved external symbol __imp_DmPerformance_renderPcm referenced in function "public: virtual void __cdecl GameMusic::GothicKitMusicProvider::renderSound(short *,unsigned __int64)" (?renderSound@GothicKitMusicProvider@GameMusic@@UEAAXPEAF_K@Z)
gamemusic.cpp.obj:-1: ошибка: LNK2019: unresolved external symbol __imp_DmPerformance_setVolume referenced in function "public: virtual void __cdecl GameMusic::GothicKitMusicProvider::playTheme(struct zenkit::IMusicTheme const &,enum GameMusic::Tags)" (?playTheme@GothicKitMusicProvider@GameMusic@@UEAAXAEBUIMusicTheme@zenkit@@W4Tags@2@@Z)
Note, that "unresolved external" in mingw is just any link error in fact, on mac - it's duplicated symbol. Don't really know how to avoid such in static library.
if (${DM_BUILD_STATIC})
add_library(dmusic STATIC)
else ()
add_library(dmusic SHARED)
endif ()
Can it be simplified to add_library(dmusic)
?
Hm, seems weird. Doing it both ways works for me without linker issues. I need to be able to build it as a shared lib so I can't get rid of that entirely. There are two possibilities I can see here but you'd need to test it since I can't reproduce this issue.
if (${DM_BUILD_STATIC})
add_library(dmusic)
else ()
add_library(dmusic SHARED)
endif ()
__declspec(dllexport)
markers mess things up. In that case you could try removing the visibility modifiers at the top of dmusic.h
and replacing them with
-#if defined(_WIN32) || defined(__CYGWIN__)
- #ifdef DM_BUILD
- #ifdef __GNUC__
- #define DMAPI DM_EXTERN __attribute__((dllexport))
- #else
- #define DMAPI DM_EXTERN __declspec(dllexport)
- #endif
- #else
- #ifdef __GNUC__
- #define DMAPI DM_EXTERN __attribute__((dllimport))
- #else
- #define DMAPI DM_EXTERN __declspec(dllimport)
- #endif
- #endif
- #define DMINT
-#else
- #define DMAPI DM_EXTERN __attribute__((visibility("default")))
- #define DMINT DM_EXTERN __attribute__((visibility("hidden")))
-#endif
+#define DMAPI DM_EXTERN
+#define DMINT DM_EXTERN
Solution 2 didn't change much, but error is more descriptive now:
dmusic-tsf.lib(tsf.c.obj) : error LNK2005: tsf_load_memory already defined in hydra.cpp.obj
dmusic-tsf.lib(tsf.c.obj) : error LNK2005: tsf_load already defined in hydra.cpp.obj
dmusic-tsf.lib(tsf.c.obj) : error LNK2005: tsf_copy already defined in hydra.cpp.obj
dmusic-tsf.lib(tsf.c.obj) : error LNK2005: tsf_close already defined in hydra.cpp.obj
dmusic-tsf.lib(tsf.c.obj) : error LNK2005: tsf_reset already defined in hydra.cpp.obj
Basically:
In opengothic there are tsf_load_memory
symbold, due to use of the tfs and in dmusic you also using same library, resulting in a conflict.
I need to check on my end, if it's possible to hide tsf on opengothic side
Found partial, but probably good enough solution:
in 33f837e I've made TSF symbols static in opengothic, so it doesn't have conflict anymore. On dmusic side: __declspec(dllexport)
is an issue in case of static library, so need to productise option 2 from your previous comment.
You could try this
if (${DM_BUILD_STATIC}) add_library(dmusic) else () add_library(dmusic SHARED) endif ()
No need to do this, according to https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html#variable:BUILD_SHARED_LIBS,
add_library(dmusic)
is enough.
@Try Please verify.
Tested on windows, with MSVC and MINGW - works; CI - green. Cant test on apple now, but probably works. Thanks!
Generally in opengothic only engine intended to be .dll (doesn't quite work like that due to C++ runtine and DX12). Also causes issues on iOS (and possibly on android, in future):
(dev-team is selected for ovarall project)