Including headers in an Xcode 4.2.1 project

opengl, soil, xcode

Solution

.h and .c files aren't libraries. Add the .c files to the compile phase and just `#import` the .h files where needed.

To verify linking I have done the following:

- Create a new Mac Cocoa application.

- Add 10 files from the SOIL `src` folder: SOIL.c, image_DXT.h, stbi_DDS_aug.h, SOIL.h, image_helper.c, stb_image_aug.c, stbi_DDS_aug_c.h, image_DXT.c, image_helper.h, and stb_image_aug.h.

- Tell Xcode to copy them to my project.

- Add one line to my app delegate's `applicationDidFinishLaunching:` method: `SOIL_load_OGL_texture( "img_test.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, 0 );`.

- Build the target for running.

Although there are a variety of compiler warnings about data conversion, these steps produce an executable with no linker errors.

Problem

I'm trying to use a library, specifically SOIL (Simple OpenGL Image Library) in Xcode 4.2.1. Under Build Phases -> Link Library with Libraries I add all the .h and .c files that came with the SOIL zip archive. When I build the project, I get the following error message for every .h and .c file added: warning: skipping file '/Users/saw/XcodeProjects/Assignment01 copy/Assignment01/image_DXT.c' (unexpected file type 'sourcecode.c.c' in Frameworks & Libraries build phase) and a linker error: "_SOIL_load_OGL_texture", referenced from: Init() in main.o Symbol(s) not found for architecture x86_64 Clang: error: linker command failed with exit code 1 (use -v to see invocation)

Original source