SOIL linker errors - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: SOIL linker errors (/thread-10274.html)
SOIL linker errors - kropcke - Aug 30, 2012 11:50 AM
Happy to make my first post here, after already finding plenty of help prior to registering. As the subject suggests, I'm having trouble properly linking to SOIL.
After following the advice from this thread: http://www.idevgames.com/forums/thread-1114-page-3.html , I am now properly creating a new Mac-compatible lib (thanks AnotherJake !!!)
At this point, I go ahead and try to load a texture into memory using the following code:
This yields 7 errors of the following variety:
I've tried to resolve these errors in a variety of ways...
1. dragging lib onto my xcode target
2. placing lib in the same group as my main.cpp
3. both copying/not copying to destination group folder
4. verified header/library search paths are correct in Build Settings
5. always search user paths set to 'yes'
6. tried both import/include SOIL.h header file in main.cpp
7. copied remaining *.h and *.c files into project folder
8. used "make install" in addition to just "make"
9. tried compiling the simple working glut demo AnotherJake provided in that earlier thread
10. deleting/recreating lib a number of times
I think I'm really close, but I'm not sure if I'm missing something in xcode, maybe my code is incomplete, or perhaps I need to update something in SOIL.c like:
... is this perhaps outdated?
I'm using xcode4.0.2, and am running OSX 10.6.8.
GLUT | OpenGL | C++
Please forgive me if I've not included enough information, I'm pretty new to OpenGL and C++. And I ask for your help/nudge/etc ever so humbly.
Thank you kindly in advance.
RE: SOIL linker errors - AnotherJake - Aug 30, 2012 01:01 PM
The ld message saying it couldn't find the symbol ___CFConstantStringClassReference suggests to me that you forgot to add system frameworks to your project. My guess is that adding OpenGL.framework and GLUT.framework will probably fix it for you.
RE: SOIL linker errors - kropcke - Aug 30, 2012 02:33 PM
Hi AnotherJake! - thank you deeply for the response.
Under 'Link Library With Libraries', the following already exist:
When I manually dragged/dropped my new SOIL library onto my xcode target, it was automatically added to the 'Link Library With Libraries' list as well - for a total of three items.
Target Dependencies: 0 items
Compile Sources: main.cpp
Copy Files: 0 items
Is there somewhere else that I should be adding these frameworks to?
RE: SOIL linker errors - AnotherJake - Aug 30, 2012 03:07 PM
That appears to be correct. Uhh... I am not sure why it is giving you grief. Try adding CoreFoundation.framework, I guess... If that doesn't work then we have something a little less obvious going wrong, such as perhaps building a 64 bit binary against a 32 bit library or maybe you added the frameworks to one target and are trying to build another, or something.
RE: SOIL linker errors - kropcke - Aug 30, 2012 03:31 PM
Adding the CoreFoundation.framework did the trick - I am error and warning free
From my understanding, this framework provides a very large blanket of software that perhaps might not be necessary if I update my versions of xcode/osx?
Just curious what led you to that conclusion. Thank you again. Happy shading ahead! I really appreciate your help.
-kropcke (Loyal member of idevgames)
RE: SOIL linker errors - AnotherJake - Aug 30, 2012 03:52 PM
Sorry, I should have suggested CoreFoundation at first instead of OpenGL and GLUT frameworks, which have nothing to do with CoreFoundation. I don't know what I was thinking... Glad we found it anyway
CFConstantStringClassReference starts with the prefix "CF", which is what all the calls and type definitions in CoreFoundation have. When you get symbols not found by the linker and you don't recognize what library or framework they may be from, you can always google them and usually come up a hint that way.
Yes, CoreFoundation is a large and basic framework on Mac OS, as well as AppKit. Most applications will need use of one or both of them.
With Xcode, it depends on the project template and other things which may or may not be hidden from obvious view. I believe that if you started your GLUT project from the Cocoa app template, then in the project settings you'd find -framework Foundation and -framework AppKit under Other Linker Flags, which is another less obvious way of including those frameworks. If you started with an empty project, then I think you have to either do that yourself in the project settings, or include them under "Link Library With Libraries" (I don't recall what stuff Xcode includes automatically for you).
Whenever you find ld (the linker program) spitting out a message about a symbol not found in a .o file (an object file which has been compiled), then you can be pretty sure that you didn't tell the compiler about a library or framework, somehow, or the one you linked to doesn't contain what you expect it to contain, such as 32 or 64 bits, etc. There are other less likely ways for this to happen too, such as the library or framework is defective, like if you are making your own library and providing a header definition for a call but not actually writing the function for it. ... or maybe you included a header which does not match the compiled library.
RE: SOIL linker errors - kropcke - Aug 30, 2012 09:38 PM
Awesome... that straightens many things out - thank you kindly for your in-depth response
You are correct in that I started with an empty project, and it is clear now that I need to add CoreFoundations.framework manually.
I haven't begun a GLUT project before from the Cocoa app template... probably worth exploring/investigating on my end.
Thank you again!