Closed cole-io closed 5 months ago
ah, if you are linking through find_package, the target should carry over winmm. this is a bug, I don't know why CMake didn't add it to the config, it should...
What you can do right now is try to add winmm
here:
target_link_libraries(test PRIVATE "${LIBREMIDI_LIB}" winmm)
oh wait, you are doing find_library
, not find_package
this is why. When you link against a static library directly, it's your responsibility as end-user to link to all the dependent libraries. CMake find_package
automates this step but if you do it manually through find_library, you have to pass them yourself to the linker. So adding winmm
to target_link_libraries is in your case the correct thing to do.
Another option is to create a .dll of libremidi instead of a static library - if you use a shared library instead of a static library, it already knows which other libraries it should link to.
You can do this by passing -DBUILD_SHARED_LIBS=1
when building libremidi itself.
Thank you!
CMakeLists.txt:
test.cpp:
Everything goes fine until linking.
C:/bridge/lib
is a valid path that contains an MSVC-compiledlibremidi.lib
(see -D flag below)Attempting to link the executable fails with a bunch of undefined symbols inside
libremidi.lib
:There is probably something obvious that I am missing. Any help?