0

I am trying to build SDL2_mixer (2.0.2) using Microsoft Visual C++ in Visual Studio, it appears that I have properly configured it.

But seems that the two example projects playmus and playwave return errors (17 in total for each) regarding unresolved external symbols regarding FLAC(Free Lossless Audio Codec) and modplug.

Seems that I have properly linked them by adding modplug.lib and libFLAC_static.lib in the additional linker dependencies column for both the example projects.

I have been trying to solve this problem because it is obvious that if these two example projects fail, then my project using SDL2_mixer will also fail with these unresolved external symbol errors.

And in the end, I was right. It happened... when I used it.

So gracefully, is there a way to get rid of these linker errors (seems that I have properly linked them though).

The errors are here (if you please):

Error LNK2019: unresolved external symbol __imp__ModPlug_Load referenced in function _MODPLUG_Load

Error LNK2019: unresolved external symbol __imp__FLAC__stream_decoder_process_until_end_of_stream referenced in function _FLAC_Load

Error LNK2019: unresolved external symbol __imp__FLAC__stream_decoder_process_until_end_of_metadata referenced in function _FLAC_Load

Error LNK2019: unresolved external symbol __imp__FLAC__stream_decoder_process_single referenced in function _FLAC_Load

Error LNK2019: unresolved external symbol __imp__FLAC__stream_decoder_flush referenced in function _FLAC_Load

Error LNK2019: unresolved external symbol __imp__FLAC__stream_decoder_finish referenced in function _FLAC_Load

Error LNK2019: unresolved external symbol __imp__FLAC__stream_decoder_init_stream referenced in function _FLAC_Load

Error LNK2019: unresolved external symbol __imp__FLAC__stream_decoder_get_state referenced in function _FLAC_Load Error LNK2019: unresolved external symbol __imp__FLAC__stream_decoder_delete referenced in function _FLAC_Load

Error LNK2019: unresolved external symbol __imp__FLAC__stream_decoder_new referenced in function _FLAC_Load

Error LNK2019: unresolved external symbol __imp__ModPlug_SetMasterVolume referenced in function _MODPLUG_Load

Error LNK2019: unresolved external symbol __imp__ModPlug_SetSettings referenced in function _MODPLUG_Load

Error LNK2019: unresolved external symbol __imp__ModPlug_GetSettings referenced in function _MODPLUG_Load

Error LNK2019: unresolved external symbol __imp__ModPlug_Seek referenced in function _MODPLUG_Load

Error LNK2019: unresolved external symbol __imp__ModPlug_Read referenced in function _MODPLUG_Load Error LNK2019: unresolved external symbol __imp__ModPlug_Unload referenced in function _MODPLUG_Load

Error LNK2019: unresolved external symbol __imp__FLAC__stream_decoder_seek_absolute referenced in function _FLAC_Load

Error LNK1120: 17 unresolved externals

Additional Dependencies: (which I added while trying to solve these errors helplessly):-

winmm.lib
version.lib
libmpg123-0.lib
modplug.lib
libFLAC_static.lib

Preprocessor Settings: (Inside SDL2_mixer project):- (I suspect this might have something to do with this error but still looks all too well):-

MUSIC_WAV
MUSIC_MOD_MODPLUG
MUSIC_OGG
MUSIC_FLAC
MUSIC_MP3_MPG123
MUSIC_MID_TIMIDITY
MUSIC_MID_NATIVE

The errors are almost the same for both the projects.

I grabbed modplug on GitHub from here, so it is not official.

"And believe me, it is always a pain to build SDL_mixer from scratch."

Thank you for taking your time to read this.

Community
  • 1
  • 1
Ruks
  • 3,886
  • 1
  • 10
  • 22
  • I don't know the answer but that name `libFLAC_static.lib` is suspicious to me. It suggests static linking, while it's clear from your errors that you are trying to link with a DLL. Maybe there's a different version of that library that you should be linking with. – john Aug 25 '18 at 06:44
  • @john I have changed the project type from *Dynamic Library* to *Static Library* and also deleted all the dynamic preprocessors from the *SDL2_mixer* project inside the solution (because they build successfully). The example projects are actually failing. – Ruks Aug 25 '18 at 06:47
  • Are you building it as C code? – user7860670 Aug 25 '18 at 06:59
  • @VTT Yes, I am building it as C code. I changed the tag from *C++* to *C*. – Ruks Aug 25 '18 at 07:09
  • 1
    @Ruks Names such as `__imp__ModPlug_Seek` are a clear indication that the linker is trying to link with an import library. If that's not the intention then something is wrong in your project settings. – john Aug 25 '18 at 07:52
  • @john But that is where the problem lies, as I have added the names of the libraries (all are static libraries built solely by me from scratch) it mentions inside the additional dependencies, hoping should it properly link and also the project settings seem all fine to me. – Ruks Aug 25 '18 at 07:53
  • @Ruks Do you understand the difference between an import library and a static library? – john Aug 25 '18 at 07:57
  • @john A library which is imported externally (along with its exported functions and structures) dynamically (with DLLs) or statically (without DLLs) inside a program/another library is an import library while a static library is a library that builds its source code inside the main target application instead of having to link with a dynamic link library(DLL) externally. – Ruks Aug 25 '18 at 07:57
  • @john Yes, all the libraries that are being linked are static libraries (**not** dynamic libraries) and I don't see where it mentions anything as expecting a DLL instead (because I removed all the dynamic preprocessors too). Fortunately, there aren't any errors inside the main projects, only inside the example projects (*playmus*, *playwave*) (which show the same errors as that when linked in an application itself). – Ruks Aug 25 '18 at 08:04
  • 1
    You need to have `FLAC__NO_DLL` macro defined if you want to link with static FLAC libraries. For modplug you need to define `MODPLUG_STATIC`. – n. m. could be an AI Aug 25 '18 at 08:46
  • @n.m. Thank you for your answer, it worked. But can you please tell how to build and link mpg123 statically? Because it appears to require the mpg123 DLL when ran (Though it looks like it is really difficult to build it from scratch because it does not have a configure or a MakeFile). I did find this: https://stackoverflow.com/questions/15225894/windows-mp3-decode-library-c-c, but it really doesn't explain it clearly (like about how to set up YASM or just build it from the solution inside the ports folder). – Ruks Aug 25 '18 at 10:10
  • Sorry I have very little idea about building on Windows. It would appear you need to compile with BUILD_MPG123_DLL and LINK_MPG123_DLL undefined, but I can't tell you much beyond that. – n. m. could be an AI Aug 25 '18 at 10:30
  • @n.m. Okay, thank you for replying. – Ruks Aug 25 '18 at 11:05

0 Answers0