Friday, December 20, 2013

XCode's # include <> header file search order problem

Just learning XCode, version 3.2.1
The virtual machine is equipped with Snow Leopard.

Because you want to compile a C + + library on this platform to third parties. This library contains some source cpp header file unistd.h.
Code is
# Include

The following third-party library source directory with unistd.h.
MAC system directory under / usr / include also unistd.h

From the C + + syntax is. Meaning of the sentence is to start the system environment should go to the directory and then go look for unistd.h cpp source directory under it?
Objective-C syntax should support it?

However, the actual compilation will be problems, because the problems cited unistd.h third-party libraries cpp source directory under.
And I expect that allow the compiler to find / usr / include under unistd.h, unistd.h deleted if the third-party libraries cpp source directory where the compiler will find the system directory unistd.h. So compiler can not go wrong.

I try to modify the project settings properties Search Paths in the Header Serch Paths to / usr / include Always Search User Paths (YSE or NO) are invalid.
Other C + + Flags join -I/usr/include also invalid.

Solving!
XCODE down with # include <> manner and # include "" efficient way to do the same?





Reply:
Also I passed vi ~ /. Bash_profile set up environment variables.
export PATH = $ {PATH} :/ usr / include

Then
source ~ /. bash_profile
Then reboot.

Oh no.

And then the strange thing is I XCODE the Project Setting, fill $ PATH in Search Header Paths in. Displayed but not / usr / include, or the path of the original value.

When compiling error, see the information compiled in the front part of it nor setenv PATH / usr / include
Compiler error message the first few lines as follows:
CompileC build/vtl.build/Debug-iphonesimulator/vtl.build/Objects-normal/i386/fstream.o Source / vtl / fstream.cpp normal i386 c + + com.apple.compilers.gcc.4_2
cd / Users / warpo / Desktop / vtl
setenv LANG en_US.US-ASCII
setenv PATH "/ Developer / Platforms / iPhoneSimulator.platform / Developer / usr / bin :/ Developer / usr / bin :/ usr / bin :/ bin :/ usr / sbin :/ sbin"

Feel very strange.
Solving ...
Reply:
xcode header file search is not very clear, but if it is your own header files should not be defined with the same library file
Reply:
Xcode uses the currently selected SDK as a base path, which it prefixes on to system includes. So if your SDK is / Developer/SDKs/MacOSX10.6.sdk then it will look under / Developer/SDKs/MacOSX10.6.sdk / usr / include by default for system includes.
Reply:
And the order is not the same as the method call.
Reply:
Solve their problems, because unfamiliar development environment, so that later in the project file list in his own header file unistd.h rightmost hook cancel it. Was it!
Scattered points.
Reply:
The main reason figured out.

In the Project SettingIf you need to use your own system libraries and header files of the same name. Specify header files Header Search the directory entry can.
If you need to use the system with its own namesake library header files, Header Search items do not set your own header file directory can be the same name.

No comments:

Post a Comment