Including headers in an Xcode 4.2.1 project
Asked Answered
D

2

7

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)

Displacement answered 17/5, 2012 at 16:1 Comment(0)
R
9

.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.

Redware answered 15/12, 2012 at 15:50 Comment(2)
I have have added the files in the correct way unlike @Terribad it seems. The error still remainsCaban
I assume you mean the linker error as opposed to the "skipping file" message? Can you find SOIL_load_OGL_texture defined inside one of the files that are being built (SOIL.c for example)?Redware
D
1

Try adding -framework to your framework's name in the "Other Linker Flags" such as:

-framework SOIL
Downbow answered 16/12, 2012 at 21:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.