Followers 0

## 7 posts in this topic

I'm trying to load textures with soil and my code is compiling fine but throwing errors when linking.

[code]C:\SourceCode\Libraries\SOIL\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to glGetString@4'|
C:\SourceCode\Libraries\SOIL\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to glGetString@4'|
C:\SourceCode\Libraries\SOIL\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to glGetString@4'|
C:\SourceCode\Libraries\SOIL\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to glGetString@4'|
C:\SourceCode\Libraries\SOIL\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to glGetString@4'|
C:\SourceCode\Libraries\SOIL\lib\libSOIL.a(SOIL.o):SOIL.c|| more undefined references to glGetString@4' follow|
||=== Build finished: 7 errors, 0 warnings ===|[/code]

I'm using CodeBlocks 10 with gcc on W7. I tried rebuilding the soil.a but it made no difference. What libraries should I link with to make soil work?
0

##### Share on other sites
Are you linking to -lopengl32 ? Would be nice if you could tell us all the libraries you link to.
0

##### Share on other sites
Ah right. Not sure how many need to be there still, the base code gets reused a lot, but this is all of them.

[img]http://img26.imageshack.us/img26/2460/libn.png[/img]
0

##### Share on other sites
That seemed really strange to me, as you are linking against all the windows and opengl related libraries, so I tried it in C::B myself and got the same errors.

After struggling with it a while I found the solution: you have to link to SOIL before opengl32!

I didn't know that the order of the libraries matters at all, but that seems to be the proof Hope that works for you too!
1

##### Share on other sites
Awesome, that fixed it. Is there a rule for which order I should link in or is it a bit hit and miss?
0

##### Share on other sites
Hi folks,

I am using Code::BLocks, too. But actually I don't have a clue how to link SOIL.

Would be thankfull for any advice.

Greets

plusnoir
0

##### Share on other sites
[quote name='plusnoir' timestamp='1322136227' post='4887217']I am using Code::BLocks, too. But actually I don't have a clue how to link SOIL.
[/quote]

A general answer can be found here: [url="http://www.learncpp.com/cpp-tutorial/a3-using-libraries-with-codeblocks/"]http://www.learncpp.com/cpp-tutorial/a3-using-libraries-with-codeblocks/[/url]
Whatever IDE you use, always be sure to know how to add libraries and include directories as this is a crucial skill in programming!
0

##### Share on other sites

After struggling with it a while I found the solution: you have to link to SOIL before opengl32!

Very helpful - I would have messed around quite a while before doing this.  Worked for me too.

0

## Create an account

Register a new account