SOIL linker errors

Posts: 6
Joined: 2012.08
Post: #1
Howdy Everyone!

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: , 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:

GLuint tex_2d = SOIL_load_OGL_texture

This yields 7 errors of the following variety:

Undefined symbols for architecture x86_64:
  "___CFConstantStringClassReference", referenced from:
      CFString in lib(SOIL.o)

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

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:

#elif defined(__APPLE__) || defined(__APPLE_CC__)
    /*    I can't test this Apple stuff!    */
    #include <OpenGL/gl.h>
    #include <Carbon/Carbon.h>
    #define APIENTRY
    #include <GL/gl.h>
    #include <GL/glx.h>

... 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.
Quote this message in a reply
Posts: 3,591
Joined: 2003.06
Post: #2
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.
Quote this message in a reply
Posts: 6
Joined: 2012.08
Post: #3
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.

Additional Info:

Target Dependencies: 0 items
Compile Sources: main.cpp
Copy Files: 0 items

Is there somewhere else that I should be adding these frameworks to?
Quote this message in a reply
Posts: 3,591
Joined: 2003.06
Post: #4
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.
Quote this message in a reply
Posts: 6
Joined: 2012.08
Post: #5

Adding the CoreFoundation.framework did the trick - I am error and warning free Smile

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)
Quote this message in a reply
Posts: 3,591
Joined: 2003.06
Post: #6
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 Wink

(Aug 30, 2012 03:31 PM)kropcke Wrote:  Just curious what led you to that conclusion.

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.
Quote this message in a reply
Posts: 6
Joined: 2012.08
Post: #7
Awesome... that straightens many things out - thank you kindly for your in-depth response Smile Smile

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!

Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Using SOIL on Mac Talyn 1 6,103 Jan 9, 2009 06:52 PM
Last Post: Oddity007
  Problem with SOIL in OpenGL RingoEST 12 19,183 Aug 12, 2008 09:30 PM
Last Post: RingoEST
  Linker Probs in PB - GLUT seedjar 2 5,091 May 11, 2003 07:04 PM
Last Post: seedjar