🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

LNK2019 Error

Started by
2 comments, last by pbivens67 3 years, 2 months ago

Error LNK2019 unresolved external symbol __alloca referenced in function _stbi_zlib_decode_noheader_buffer Project1 C:\Users\Owner\Desktop\Project1 - Copy\Project1\SOIL.lib(stb_image_aug.o) 1

Error LNK2019 unresolved external symbol _sqrtf referenced in function _RGBE_to_RGBdivA2 Project1 C:\Users\Owner\Desktop\Project1 - Copy\Project1\SOIL.lib(image_helper.o) 1

I am getting the above linker errors.

Advertisement

Probably you've got an old version of the library, or are mixing a debug and release library, or are mixing C and C++ code with different name mangling.

Those functions are implemented as intrinsics on modern Visual Studio versions. That means when the compiler generates them they're not functions at all, but the code is generated directly inline. Your SOIL library is expecting them to exist as standalone functions, but your compiler has optimized them away so there's nothing to link against.

The best option is to compile the library with settings that match your project. Then the library will have the more optimized version.

Another option is to attempt to get MSVC to generate the functions is to place a #pragma in one of your implementation files. This would possibly do it:

#pragma function(alloca, sqrtf)

The fact that the C++ name mangling isn't present means you might also be mixing it in with extern “C” blocks. It isn't pretty and is usually only managed by library maintainers. That's why the best option is to compile the library with the same settings you are using on your project.

I used the pragama function above but am still getting the same error, there has to be a way to adjust vs 2017 to fix this problem.

This topic is closed to new replies.

Advertisement