Installing GLEW and using it with Xcode - 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.

Related

Override system library in 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.

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.

Add dynamic library to firebreath

I'm developing a plugin for mac. I'm trying to use afnetworking and other frameworks which needs arc. I'm trying to create a .a(library) for the framework and access it in firebreath. I tried adding the directory which contains .a using include_directories in projectdef.cmake then linking it in target_link_libraries. Please lemme know how to add this and whether the framework can be used in firebreath without any pitfalls
I have used external libraries in firebreath. Though I have used editors to link the libraries. You need to specify .h files for the function prototypes, along with .a files which will dynamically link to .dylib
Try adding these via Xcode and see if that works.

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

Boost library static linking on Xcode 4

I am using the Boost library on OS X using Xcode. Boost was installed on my system using macports. I have successfully built my app by adding the 3 boost libraries I need (for example, libboost_thread-mt.a) to that Targets 'Link Binary With Libraries' list. However I need to link these libraries statically so that the app will run on other computers without the boost library needing to be installed.
How do I do this exactly? Through my numerous google searches I'm finding I might need to add '-static' - where do I add this in Xcode?
If you've linked with a .a library, then you have already linked statically. You never need to ship .a libraries. They're just bundles of objects.
EDIT: Your error strongly suggests that you're linking the dylib rather than the .a. If you have libfoo.dylib and libfoo.a in your library path, even if you say "link libfoo.a" in Xcode, and even if libfoo.a is earlier in the search path, it will still link libfoo.dylib. This is because Xcode's linking is totally broken and passes -lfoo to the linker (you should never use -l for something you built and have the exact path to). I always recommend linking libraries you built in LDFLAGS in an xcconfig file rather than using the build pane. You pass the exact path you want rather than using -l. See Abandoning the Build Panel for more of my thoughts on xcconfig. It's out of date now, since it was written for Xcode3, but the basics still apply.
Using the build pane, you can also pass the entire path to the library in "Other Linker Flags." But this still has all the problems of the build pane.
The quicker (but less robust) solution is sometimes to add -Wl,-search_paths_first to the "Other Linker Flags." This changes the behavior so that each library path is searched for both .dylib and .a before going on (the default behavior is to search everywhere for .dylib and only then search for .a). So if your .a is in a different directory from your .dylib, and that directory is earlier in the search path, this will work.
This question finally got me to open a radar on this, which I should have done years ago. I recommend that others open duplicates.

Resources