# OpenGL can't get SOIL2 to work with XCODE

## Recommended Posts

Getting OpenGL to work with XCODE (on a Macbook) is a wrestling match.  But I've managed to get everything to work except the image managing library SOIL2.

Has anyone had success with this?

I have done the following steps:

• compiled soil2 with premake and make on the Mac.
• added all the header files to /usr/local/include/SOIL2
• added a reference to /usr/local/include to Header Search Paths in Build Settings
• added a reference to the directory containing the libsoil2-debug.a file to "Link Binary with libraries" under Build Phases
• added "#include <SOIL2/SOIL2.h> to the program

The error message I get is from the linker, that it can't find the soil2 library.

I tried adding a path to the .a file also to the Library Search Paths, but then I get lots more errors.

After a couple of days going in circles, I'm really stuck.  Had no problem getting soil2 working on the PC under VS.  Any ideas for XCODE?

##### Share on other sites

I didn't use SOIL but my main environment is macOS and Xcode, if you set Library Search Path correctly then what error are you getting now? Did you set Other Linker Flags e.g. -lSOIL ?

##### Share on other sites
Posted (edited)

23 minutes ago, recp said:

I didn't use SOIL but my main environment is macOS and Xcode, if you set Library Search Path correctly then what error are you getting now? Did you set Other Linker Flags e.g. -lSOIL ?

Thanks for the reply!  I'm getting tons of messages of the form "_CFxxxxxx" referenced from: xxxxx in libsoil2-debug.a(SOIL2.o).

So, I'm guessing that it's finding the .a file, but not the stuff that it in turn references?  Would adding a linker flag help?  The soil documentation doesn't mention needing to add one.

By the way, I think soil2 is a static library.

Edited by scottgordon

##### Share on other sites
Posted (edited)

If you added .a file by drag and drop Xcode may do it for you. If it is not presents in Linked Frameworks and Libraries then I suggest add that flag. Probably -lSOIL2 if it is libSOIL2.a I would add that. Probably it will fix your issue

Also if you don't set linker flags then there is no reason to set search library path I think.

EDIT:
It seems lib name is libsoil2-debug.a so it must be -lsoil2-debug

Edited by recp

##### Share on other sites

It's already listed in Linked Frameworks and Libraries.

Tried adding the other linker flag, no change.

##### Share on other sites
11 minutes ago, scottgordon said:

It's already listed in Linked Frameworks and Libraries.

Tried adding the other linker flag, no change.

I tried for you; I downloaded SOIL2 and compiled, linked to my existing project (C99 + ObjectiveC (for UI) ) with drag / drop. I didn't get any linker errors. Also I removed it from Linked Frameworks and Libraries and set it manually in Other Linker Flags then it worked again.

NOTE: I used premake4 xcode4 for compiling

You said you got error like _CFxxxxxx. AFAIK CF stands for Apple's CoreFoundation.framework maybe your linker errors are not related to SOIL2 itself?

##### Share on other sites
Posted (edited)

That was a huge hint.  I went back into "Link Binary with Libraries", and added the CoreFoundation framework.  It then built successfully.

It's having other issues, but thank you that looks like it got me past one hump.

Is it normal to have to specify that manually like that?

EDIT:  BTW, a HUGE thank you for actually trying it yourself.  That was very nice of you.

EDIT2:  Got everything else to work too.  recp, I owe you one.

For the benefit of anyone stumbling on this thread, here are all the shenanigans I had to do to get SOIL2 to finally work in XCODE:

• compiled soil2 with premake and make on the Mac.  I used the command that sets up for make, rather than for xcode, and used "make" rather than xcode to build soil2.  This resulted in a soil2-debug.
• added all the header files to /usr/local/include/SOIL2 (had to use sudo for this)
• added a reference to /usr/local/include to Header Search Paths in Build Settings
• added a reference to the directory containing the libsoil2-debug.a file to "Link Binary with libraries" under Build Phases
• added the path to the .a file also to the Library Search Paths
• searched for and added CoreFoundation framework into the "Link Binary with Libraries" (under Build Phases)
• added "#include <SOIL2/SOIL2.h> to the program
Edited by scottgordon

##### Share on other sites

Thanks so much!! I've been trying to link it correctly for the past 3 days with no luck. I couldn't find anything on the web... I was just missing the CoreFoundation lib. Thanks again!

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 9
• 27
• 20
• 14
• 14
• ### Forum Statistics

• Total Topics
633385
• Total Posts
3011603
• ### Who's Online (See full list)

There are no registered users currently online

×