Including headers in an Xcode 4.2.1 project

I am trying to use a library, specifically SOIL (Simple OpenGL Image Library) in Xcode 4.2.1. In the section "Assembly phases" → Library links with libraries. I add all the .h and .c files that come with the ZIP archive.

When I create a project, I get the following error message for each .h and .c file:

warning: skip the file '/ Users / saw / XcodeProjects / Assignment01 copy / Assignment01 / image_DXT.c' (unexpected file type "sourcecode.cc" in the phase of building frameworks and libraries)

and linker error:

"_ SOIL_load_OGL_texture" referenced: Init () in main.o Characters not found for x86_64 architecture Clang: error: linker command failed with exit code 1 (use -v to call the call)

+7
source share
2 answers

The .h and .c files are not libraries. Add .c files to the compilation phase and just #import .h files where necessary.

To check the connection, I did the following:

  • Create a new Cocoa Mac app.
  • 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 delegate method applicationDidFinishLaunching: SOIL_load_OGL_texture( "img_test.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, 0 ); .
  • Create a goal to run.

Although there are many warnings about the compiler about data conversion, these steps create an executable file without linker errors.

+9
source

Try adding the framework to the frame name in the "Other linker flags", for example:

 -framework SOIL 
+1
source

All Articles