0

I've been working on a C++ project. I have been using 2 Windows PCs for building it and both worked fine with the same (kinda janky) setup. I recently got a new computer and I get a linker error. My build process uses prebuilt .a files for the dependencies I am using. Differences: new laptop is Windows 11 and not Windows 10 and compiler version might be a bit newer. However, I don't think this can explain it.

The error I get is:
C:/ProgramData/mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: include_windows/openssl/lib\libcrypto.a(libcrypto-lib-cryptlib.obj):cryptlib.c:(.text+0x536): undefined reference to `__imp__vsnprintf'

My build command in the make file has:
CXXFLAGS = -std=c++17 -Wall -O3 -I include -I include_windows -I src
LDFLAGS = -static -static-libgcc -static-libstdc++ -L include_windows/GLFW/lib -L include_windows/openssl/lib -lglfw3 -lopengl32 -lglu32 -lgdi32 -lssl -lcrypto -lcrypt32 -lws2_32 -lwsock32

11
  • 2
    Recommendation: Save yourself some trouble and look into MSYS2 and using its package manager to manage your compiler and libraries. It'll make sure the versions of everything line up correctly. Commented 2 hours ago
  • Differences: new laptop is Windows 11 and not Windows 10 and compiler version might be a bit newer. However, I don't think this can explain it. Believe it. This seems relevant: learn.microsoft.com/en-us/cpp/porting/… "If the library is a third-party library for which source isn't available, you should either request an updated binary from the third party or encapsulate your usage of that library into a separate DLL that you compile with the older version of the compiler and libraries." Commented 2 hours ago
  • It looks like the prebuilt .a files you have are not compatible with the different version of the compiler you are using. I agree with the first comment. Save yourself this hassle of downloading compiled binaries that may or may not be compatible and use msys2 which will always give you the right binaries for the version of the compiler that is in the package manager. Commented 1 hour ago
  • BTW. the error message is telling me that the linker expects to link to a dll (or dll.a) that implements the standard library not a static library implementation. When you see __imp__ this Microsoft behavior is to link to an import library however gcc / g++ can link to dll or dll.a unlike Microsoft's compiler that needs a .lib for the import library in native c++ Commented 1 hour ago
  • 1
    @indjev99 undefined reference to __imp__vsnprintf -- My build process uses prebuilt .a files -- You need to know exactly what options a static library was built with before attempting to use it. These details should have been noted at whatever site you obtained the library (otherwise that is a fail by the provider by the library). Obviously the one you chose was built assuming that any calls made to the C++ standard library will be made to the dll version of the standarad library. Commented 1 hour ago

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.