Override system library in Xcode - xcode

I am trying to override the headers that Xcode uses for a specific third party library because the one bundled with OS X / Xcode is out of date and am having trouble getting Xcode to choose the correct headers.
Right now the library is included via #include <pcap/pcap.h>. I can't change this because the code is cross platform and this is where the library should be. I have the latest version of the libpcap library headers located at ~/software/pcap/. Including ~/software/ in the "Header Search Paths" results in my other third party libraries (that don't exist at the system level) being found and used, but Xcode is still using the bundled/internal (old) version of the libpcap headers. I've tried adjusting the order in which the "Header Search Paths" list is set up with no luck.
I've tried "always search user paths" but this results in dozens and dozens of other local project headers being substituted for system/other library headers. I only want the headers for this specific library to override the system ones.
Is there a way to force Xcode to use a non-bundled set of library headers in place of the bundled ones for a single specific library?

It seems that Xcode does not follow aliases. Replacing the alias with actual files & folders and ensuring that the "Header Search Path" order has your overridden files listed before the Xcode level ones seems to resolve this issue.

Related

Xcode add libraries to the library browser

I don't know how to ask for it, but whenever I type xcode and library in google, it shows me "how to link to a library with xcode".
My question is how do I add the libraries from /usr/local/lib (or custom ones) to the default proposed libraries or frameworks when I go to "build phase" and the + of "link binary with libraries" ?
I tried first to add the library or frameworks search path, but seems not to affect the default proposed libraries and frameworks. The default ones I have are in two folders "OSX 10.11" and "Developper Frameworks".
I know i can add other and then cmd+maj+G to my /usr/local/lib, or even drag and drop the libraries but it means i have to go the correct path which is pretty the same steps. Then I think it is a waste of time when the major part of the libraries I use is located into /usr/local/lib.
I didn't find any options in the xcode settings ? Is there any way to do that ? maybe an xcode plugin ?

Why do i have to specifically include headers in some OSX frameworks with Eclipse?

I'm new to OSX and i'm getting used to the way frameworks work.
In c++ projects, when i want to link a preinstalled framework, for example OpenGL.framework, i just type "-framework OpenGL" and i'm good to go.
On the other side, when i copy a new framework into for example /Library/Frameworks, and i go "-framework MyFramework", the framework is linked but i need to manually include the header files.
Why can this be? Aren't the headers supposed to be inside the framework already?
Why do i need to include them for some frameworks but not for others?
-framework is a linker option. It has no effect on the header search path. You can convince yourself that this is the case by trying to remove the -framework option for a system framework you are using. You will see that the headers are still found, but there will be missing symbol errors at link time.
The -F option can be used to specify additional paths where framework headers are searched. For example, say you have a framework named MyFramework containing a header MyHeader.h, and install this framework in /Library/Frameworks. The header can then be found at /Library/Frameworks/MyFramework/Headers/MyHeader.h, where Headers is a symbolic link to a version specific directory. The actual location of the header would then for example be /Library/Frameworks/MyFramework/Versions/A/Headers/MyHeader.h.
To include this header, the #include in the source file looks like this:
#incude <MyFramework/MyHeader.h>
and you can compile the source file using:
clang -F/Library/Frameworks foo.cpp -framework MyFramework
Note that the location of headers for system frameworks in Mac OS changed a couple of releases ago (I think it started around Xcode 4). The headers used to be within their framework directories, which are mostly in /System/Library/Frameworks, but that is not the case anymore. The headers are now in the SDK directories that are part of the Xcode installation.
For example, for Mac OS 10.9, the framework headers are in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks.
Aside from separating files used at build time from files used at runtime, this newer setup has the advantage that you can have multiple SDKs, and can choose to build against specific SDKs. To choose a SDK other than the default, use the -isysroot compiler option.

firebreath mac osx, bundle - link binary with libraries disable

I working with Firebreath 1.7, MacOSX 10.8.3, Xcode 4.6.3.
I want add boost::chrono as static library to my plugin.
After running prepmac.sh i have my_plugin bundle target. I choose my_plugin target in project/targets tab and don't see option "Link binary With Libraries".
How i can add boost::chrono library to my_plugin by another method?
Changing things manually there is not the correct way to do it; you should never change the project files without changing the cmake files, because eventually you'll need to rerun the prep script.
First of all, are you using system boost? boost::chrono is not part of the boost that firebreath includes, which is a subset of the boost features to keep size down for those who don't want to deal with it. If you are using part firebreath boost and part your own, you could have problems.
If you've configured system boost correctly, you should be able to just add this to the end of your PluginConfig.cmake file and rerun the prep script:
add_boost_library(chrono)
Barring that, you could also just do it using cmake directly, which would mean adding a target_link_libraries command to your CMakeLists.txt or Mac/projectDef.cmake file at the end, something like:
target_link_libraries(${PROJECT_NAME} boost_chrono)
(you'd need to find out for sure what the library name is; you might even need to use find_library to locate it).

Installing GLEW and using it with Xcode

So I already downloaded the lastest glew v. 1.9 from the site and make it in the terminal, what I cant figure out is how to add it successfully to a GLUT OpenGL Xcode project. I can add the OpenGl and GLUT frameworks very easily but I cant find any glew frameworks or something similar.
Main problem is that one of my files has #include GL/glew.h and it cant find it.
While using 'Frameworks' is the Apple way of doing things, XCode will let you specify header paths and a shared library (as is the convention in Nixlike environments).
1) Go to your target's properties,
2) look for header search paths field and add your Glew headers to that.
3) Then look for the GLEW shared library (typically a '.a' or '.so' file) in the directory where you compiled GLEW. Add this directory to your target's library search paths and
4) then finally link against this library in your dependencies list.

Mac Ogre Xcode project can't find headers

While trying to get the template Xcode 4 ogre project to work, the build fails because it can't find OgreCamera.h.
I've installed Ogre to /opt/local/lib/OGRE, and specified that as the Ogre SDK location when creating the Xcode 4 project.
Needless to say, the header and framework include paths in the project settings point exactly to where all the header files are, yet not one of them can be found. I've tried commenting out the include of OgreCamera.h, and upon trying to run, the next include, OgreEntity.h, cannot be found. Commenting that out and running again, the next include can't be found, and so on (these includes are in OgreFramework.h.
I don't understand why these headers, which clearly exist when I go look for them in the Finder or Terminal, can't be found by the project, even when I specify their full path like this:
#include </opt/local/lib/OGRE/lib/release/Ogre.framework/Versions/1.7.4/Headers/OgreCamera.h>
Did I somehow install the Ogre SDK incorrectly? (I copied it from the DMG into placeā€¦)
I had the same problem, and found partial success by following rjstelling's answer from this thread:
why can't Xcode find this header file?
That solved the OgreCamera.h include issues, but now I'm stuck on including the boost libraries. They are not picked up on the search paths, or in the Indexing group as suggested in the thread above.
Basically it looks like a bug in XCode4 that has to be worked around until a patch is released. There is also more information here:
Compile, Build or Archive problems with Xcode 4 (and dependencies)

Resources