Page 1 of 1

Unresolved External Symbol when using statically compiled .lib

Posted: Fri Mar 31, 2023 8:00 pm
by wimlover
Hey,

I'd like my executable to package in wimlib rather than having external dependencies such as the libwim dll. To do this, I statically compiled the project and then added the library to my cmake file.

I have been adding various Windows .lib files to try to satisfy the library's dependencies but they seem to be never-ending. Have you got any recommendations as to how I can build wimlib to include all these extra library dependencies?

Thanks!

Re: Unresolved External Symbol when using statically compiled .lib

Posted: Fri Mar 31, 2023 8:53 pm
by synchronicity
Have you tried wimlib v1.14.0-BETA2? It eliminates the dependencies on libxml2 and winpthreads.

See https://wimlib.net/downloads/index.html

Re: Unresolved External Symbol when using statically compiled .lib

Posted: Fri Mar 31, 2023 10:00 pm
by wimlover
Sorry, I may have been unclear. I can compile my test program to use wimlib just fine, using libwim.lib as a library in my cmakelists.txt file. However, the exe then requires the libwim-15.dll to be present in PATH.

So I have removed this line: https://github.com/ebiggers/wimlib/blob ... ld.sh#L205 and added libwim.a to my CMakeLists.txt libraries. This creates a Visual Studio solution but will not compile.

It requires ntdll.lib, then a few more, and then I got very lost. Is it possible to compile all of these external .lib dependencies in with wimlib, to begin with, so visual studio will not have to try and link these?

I have been reading some of the previous forum posts (eg viewtopic.php?p=630&hilit=static#p630) and can see people have had similar problems in the past but wondered if you might have a fix for my situation.

Sorry I'm very new to the compiler magic!

Re: Unresolved External Symbol when using statically compiled .lib

Posted: Fri Mar 31, 2023 10:07 pm
by synchronicity
Right, I forgot: the libwim.lib in the binary releases is an import library, not a real static library. You'll need to change the build script to build a static library instead.

BTW, have you checked whether wimlib's LGPL license is compatible with static linking into your program?