linking glfw static library with Xcode 4 - static-libraries

Okay I've been searching for hours to try and solve this but nothing has worked. This problem is very similar to other posts, but I none of their solutions work.
So I am writing an OpenGL program using glew and glfw and for some reason I am unable to get the program to compile. The error is on the include statement:
#include <GL/glfw.h>
and the error says 'GL.glfw.h' file not found.
I have followed all the instructions on the
GLFW-2.7.8 Release Notes
web page, which includes making glfw, and then importing the static library libglfw.a into Xcode. The library does show up under Build Phases -> Link Binary with Libraries, but apart from that Xcode doesn't seem to recognize it. For example, under the File Inspector it detects the file type as "Default - data".
The static library is configured for 64-bit architecture, which I am running.
I have tried changing the search paths under Build Settings.
I have the following frameworks included: Cocoa, OpenGL, and IOKit.
Please let me know if there is any more information you need to help me solve this problem and thank you for reading.

It turns out my glew was not importing correctly and so glfw did not work either.
These are the steps I took:
Changed the Base SDK from Latest OSX (10.8) to Current OSX.
After doing this, I "reduced" the error to an Apple Mach-O Linker (Id) error. Next:
Added -lGLEW to Other Linker Flags.
Added /opt/local/include/ to the header search paths
Added /opt/local/lib/ to the library search paths
Here is where I found my answer.

Related

OpenCV Xcode 9.2: "ld: library not found for -lopencv_core.3.3.1"

Im getting this error message:
ld: library not found for -lopencv_core.3.3.1
But I linked OpenCV in "Header Search Paths":
_/usr/local/include_ and in Library Search Paths: _/usr/local/Cellar/opencv/3.4.0_1/lib_ (Compiler wrote it by himself, I wrote: _/usr/local/lib_)
Although i added all the frameworks i need in "Other Linker Flags" and put them also in "Linked Frameworks and Libraries" (General).
I really don't know ho to solve this problem. Is it possible that the version of the opencv_core, he wants to include, could be a problem? He is searching for version: 3.3.1 but I included opencv_core3.4.0. How is it possible that he can find this version?
I tried to unistalled OpenCV and Xcode but that won't solve the problem.
I hope that you guys can help me with that problem.
Ok I solved the problem.
For those who want to know the Solution:
I created a new Xcode Project
Included all the needed OpenCV Frameworks (Right Click on Project)
Added the Header Search Path: /usr/local/include
After that I started the application without an error. The library search path was automatically added by the compiler.

Usign OS X SDK 10.7 with Xcode 7.3 and CMake

I have a serious issue getting Xcode 7.3 to compile a Project against Mac SDK 10.7 with LLVM (7+) and C++11. The source of the issue seems to be Xcode or the fact that I'm running OS X 10.11. Some colleagues of mine don't have the same issue compiling the same issue with older Xcode Versions (6). Here is the general setup:
The needed Libraries and Headers are linked with CMake. The Include paths of everything got checked multiple times. The created Xcode Project also seems to be ok, we've compared all important settings (C++ dialect, std library , target, defines etc) against systems where the project does compile.
The actual error comes when compiling vecLib source.It seems to be a set of random error messages I would trace back to the lack of c++ std headers.. Here are a few examples:
Explicite specialization of non-template class 'complex'
Redifinition of complex as different kind of symbol
Did anybody run into similar problems when working with newer Xcodes against older SDKs?
EDIT
Here is some more informations. After checking what was behind the redifinition, I found that for some odd reason, the complex definition that was interfering with the forward declaration in the file comes from /usr/include/c++/4.2.1. I think that the header is outdated or at least not compatible with c++11. I checked again what the compiler used and the lib / language (std=c++11 and stdlib=libc++) where correctly set. I have the strange feeling that the source in user/include isn't supposed to be included but I don't know how to fix it.
EDIT 2
I've checked the standard include paths with cpp -v and got the following list:
/usr/local/include
/Applications/XCode/.../XCodeDefault.xtoolchain/usr/bin/../lib/clang/7.3.0/include
/Applications/XCode/.../XCodeDefault.xtoolchain/usr/include
/usr/include
/System/Library/Frameworks
/Library/Frameworks
The definition of complex in the Xcode toolchain (3rd entry) is the correct one, the definition in /usr/include is the one that seems to be used while compiling, leading to the error messages. The definition of complex uses structs.
What is the issue here? Is the issue that Xcode / Clang or what ever decides to go with usr/include instead of the toolchain include? I've checked the project settings and the compiler output and there was no explicit include of this path.
It seems like AppleClang 7+ and libc++ just doesn't support vecLib from OS X SDK 10.7. I had to go back to Xcode 6 to get it to build.

Beginning an openGL project with XCode. Error: "ld: library not found for -lglfw3.3.1"

I am beginning openGL in xcode. I followed the instructions on how to begin detailed here.
In short, I linked the libglfw3.3.1.dylib, libGLEW.1.13.0.dylib and OpenGL framework under build settings, and added /usr/local/include to header search paths.
However, I run into the following error:
ld: library not found for -lglfw3.3.1
I saw other posts about 'library not found' errors recommending linking the frameworks which I assumed to have done from build settings with the 3 libraries mentioned above.
Does anyone have any advice?
You need to add /usr/local/lib to your library search paths as well, assuming that you have installed GLFW there, and assuming that it is in fact libglfw3.3.1.dylib or libglfw3.3.1.a that you have installed there.

XCode Project - ld: library not found for -llib

Recently I ran into a CMake problem that can be found in this thread:
Cmake on OSX Yosemite 10.10.3 - GLEW: package 'gl' not found
Eventually it got solved, maybe partly due to my inexperience in XCode and CMake. (I mainly used visual studio to compile projects in the past.)
After the alteration in the linked thread I got warning about my GLEW libs in CMake
(Is this something I should be worried about or is it not important?):
MACOSX_RPATH is not specified for the following targets:
GLEW_MX_shared
GLEW_shared
I simply ignored it and tried to compile my project in XCode with the ALL_BUILD target selected. In the sparky target it said the include files in main could not be found so I added the .h files into the inc folder of my project.
When I compiled again the compiler started complaining again
(I don't know what this error means and how I can fix it.):
ld: library not found for -llib
Googled it for the entire day now and I can't find anything to solve this issue.
It's so frustrating working with XCode as an IDE but I really want to learn more about different platforms and their most popular IDE's so I can make multi platform applications from the start instead of porting it afterwards.
And if it matters I am using OSX Yosemite 10.10.3.
To make my issue easier to understand, I've put a zip of my project on my dropbox.
https://www.dropbox.com/s/xnrh90kuih9ia5a/SPARKY%202.zip?dl=0
Feel free to ask questions if I explained things to briefly and again, thanks to everyone who contributes here. I really learned allot after discovering these forums.
EDIT: Alright I booted up my windows machine, generated a visual studio environment and tried to build it on there. Seems that the same problem also happens here. I looked at the linker attributes/flags and saw a lib.lib file added to the linking process which doesn't look right at all.
When removing the file, the error disappeared and many others arrived! (Which are simply solved by linking the appropriate libs so I wont handle those here.)
I misunderstood the error on my mac and thought it was referring to a random library which I needed to hunt down but actually it's a inconsistency in one of my CMake files.
EDIT2: Now I only have to find out where the lib.lib comes from and how I can ditch the flags from the project so I can generate my environment and build right away!
So moral of the story. Sometimes the solution is right in front of you and still ends up more like looking for a needle in a haystack.
I removed the following from my root CMakeLists.txt file and the random lib.lib library was gone from my generated projects
SET( PROJ_LIBRARIES "lib" )
I thought this added a folder containing libraries but actually what it did was adding another flag for a specific library because this variable was being fed to:
TARGET_LINK_LIBRARIES( ${PROJ_NAME} ${PROJ_LIBRARIES} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} )

Xcode 4 and Allegro 5.1 - Linker can't find Framework

I know there are several other questions here regarding the Linker and Xcode 4, but they don't really relate to my problem.
I've built Allegro 5.1 and it took me a while because of FreeType, but eventually it worked. Now I've written a little Space Invader game using Allegro. But somehow the linker can't find the framework.
What I've done so far:
The Frameworks are located at /Library/Frameworks/ and they have the same structure like all the other frameworks in that place
I've added the frameworks to the "Link Binary With Libraries" tab of my target
I've added them in a "Copy Files" tab on my target with Destination "Frameworks"
I've added the correct path settings in the Build Settings, so the header files can be found
I've done all the right steps, but still I get:
ld: framework not found Allegro-5.1
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I already had a working framework, but it was installed as shared libs and not in "framwork mode". But adding the framework components to the project was kinda hard because they were stored in /usr/local/lib, which can't be selected with the file dialog...
So... I have no idea what else there should be to do. When I had the shared libs it worked, but now with the same setting but different location it doesn't anymore. Tell me if you need more information, I'll provide it!
So, in case someone lands here, with the help of elias in the Allegro IRC I've found the "error":
In my targets Build Settings I had to specify the Framework Search Paths as /Library/Frameworks.
This doesn't really make sense to me, since this is the default directory for the Frameworks on Mac OS X, but whatever...

Resources