Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are static library headers not found?

I've used Clint Harris' tutorial to set up code sharing between projects, and everything works just as expected on my computer. But on my co-worker's machine, it seems the compiler doesn't find the header file from the static library project when he builds.

My co-worker got my project by cloning a git repository. We've gone through all relevant build flags and XCode settings n times, but the project simply refuses to compile on his machine.

This is what I asked my co-worker to do, mostly copied and pasted from the tutorial:

  1. Make sure there is NO blank space in the complete path to the projects' directory.
  2. Inside the projects directory, create another folder called "build_output".
  3. In XCode, under “XCode > Preferences" choose the "Building” tab and set “Place Build Projects in” to “Customized location” and specify the path to the common build directory you created.
  4. Set “Place Intermediate Build Files in” to “With build products.”
  5. Choose the “Source Trees” tab and create a new Source Tree variable by clicking on the “+” button and filling in the columns. In both "Setting Name" and "Display Name", put [the name of the shared project which created the static library]. In path, you put the full path to the framework folder.

Following these steps, the project that uses the static library should compile the same on his machine as on mine. But it doesn't. Basically, the error he gets is:

error: TheFrameworkHeader.h: No such file or directory

and then a string of other errors caused by the missing header.

Any strategies for trouble-shooting this? Or anyone who had a similar experience and could share some hard-earned knowledge? Is anything missing from the instructions I've summarized? Do I need to set the roles of headers in the Copy Headers build phase when compiling a static library?

like image 448
Felixyz Avatar asked Jul 07 '09 23:07

Felixyz


People also ask

Do static libraries need headers?

Static libraries allow you to create a library and use that library in many projects. The need for header files: Since the project using the library is programmed and compiled independent of the library, that program needs to know the declaration of the things you're using.

What creates static libraries?

Static libraries are created using some type of archiving software, such as ar. ar takes one or more object files (that end in .o), zips them up, and generates an archive file (ends in . a) — This is our “static library”. Now that we have the object file(s), we can archive them and make a static library using ar.

What is in a static library?

In computer science, a static library or statically-linked library is a set of routines, external functions and variables which are resolved in a caller at compile-time and copied into a target application by a compiler, linker, or binder, producing an object file and a stand-alone executable.


2 Answers

Despite some helpful advice, I never figured this one out, but here's a little info for anyone in a similar situation. I created the library and dependent project by splitting an original project into two. At first, the library and application were just two targets within the same project. Later, I moved the app to a separate project. Everything seemed to work, and I pushed both projects to remote git repositories. When these were cloned on other computers, however, the library headers were not found.

Later, I discover that the same error occurred when I cloned the projects on the original computer. After a lot of struggle, I pinned it down to one scary detail: the name of the dependent project's folder! (That is, the project with the application, not the library.) Not the name of the .xcodeproject package, not the application identifier, but the name of the containing folder. As soon as I change that, everything works. If I change it back to the original name (on any computer), again the headers are not found.

If anyone has any insight on this, please post an answer!

EDIT: Since I posted this, the same problem occured with another project, and again, merely renaming the folder that contains the .xcodeproject folder fixed the problem.

like image 192
Felixyz Avatar answered Oct 03 '22 02:10

Felixyz


I don't think it is Git, I think it's xcode. I got a very similar problem here, where xcode / xcodebuild resolves an include path falsely (making it a simple .) With the exactly the same library project and xcconfig files (clean checkout from svn repo) but another containing folder - it works. So, thanx for the solution and don't blame Git anymore ;-)

like image 34
mvd Avatar answered Oct 03 '22 00:10

mvd