SOIL not linking correctly [duplicate]
Asked Answered
B

3

7

I am linking SOIL in my library but when I compile I get these linker errors:

1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libSOIL.lib(stb_image_aug.o) : error LNK2019: unresolved external symbol __alloca referenced in function _stbi_zlib_decode_noheader_buffer
1>libSOIL.lib(image_helper.o) : error LNK2019: unresolved external symbol _sqrtf referenced in function _RGBE_to_RGBdivA2

I did link libSOIL.lib in the addition dependencies.

Baggott answered 9/3, 2012 at 5:26 Comment(0)
N
6

The unresolved symbol errors, error LNK2019, are from the symbols in libgcc.lib or another standard library implementation (see here for the Microsoft Options) not being linked to. alloca and sqrtf are both standard library functions.

If you aren't linking to a standard library, then link to one by adding it to your linker library path.

From the warning above warning LNK4098, it is more likely you are linking to a standard library but the linker doesn't know which on to load.

Recommend LINKER arguments to make this problem go away (tell the linker to choose a specific standard library) are /NODEFAULTLIB:"MSVCRT" /NODEFAULTLIB:"LIBCMT.

See the following links for additional information and resources

Nutritious answered 9/3, 2012 at 10:28 Comment(1)
Hmm, adding /NODEFAULTLIB:MSVCRT fixed the warning but the same errors are still there.Baggott
B
7

Fixed the error.

Although I'm using VC2010, I built the VC8 libraries. I then added SOIL.lib instead of libSOIL.lib. Errors went away.

Baggott answered 10/3, 2012 at 6:2 Comment(2)
I was using VC2012 (called VC11) and building VC9 solution worked too.Shin
I was using VC2013 and building VC8 solution workedAnecdotic
N
6

The unresolved symbol errors, error LNK2019, are from the symbols in libgcc.lib or another standard library implementation (see here for the Microsoft Options) not being linked to. alloca and sqrtf are both standard library functions.

If you aren't linking to a standard library, then link to one by adding it to your linker library path.

From the warning above warning LNK4098, it is more likely you are linking to a standard library but the linker doesn't know which on to load.

Recommend LINKER arguments to make this problem go away (tell the linker to choose a specific standard library) are /NODEFAULTLIB:"MSVCRT" /NODEFAULTLIB:"LIBCMT.

See the following links for additional information and resources

Nutritious answered 9/3, 2012 at 10:28 Comment(1)
Hmm, adding /NODEFAULTLIB:MSVCRT fixed the warning but the same errors are still there.Baggott
G
4

I was having the same issue (using Visual Studio 2013 with vc120 toolset), I solved it downloading the SOIL library from the official site and instead of renaming libSOIL.a to SOIL.lib I ran the VC8 solution inside the official zip (that creates you the SOIL.lib)´then I copied it to my project and the problems went away.

Gherkin answered 25/4, 2014 at 3:4 Comment(1)
This worked for me too. VC8 instead of VC9 for VS 2013Anecdotic

© 2022 - 2024 — McMap. All rights reserved.