2
votes

I am trying to link the GLEW library to an Xcode project, but I have been running into an issue. Whenever I set up my build to link with libGLEW.a, I will immediately get a crash on startup, with an error output reading:

yld: Library not loaded: /usr/lib/libGLEW.1.12.0.dylib Referenced from: /Users/xxx/Library/Developer/Xcode/DerivedData/xcode-test/Products/Debug/manualWindow.app/Contents/MacOS/manualWindow Reason: image not found

I have not written any code to request that my application load this dynamic library. This behavior seems like perhaps my GLEW library is actually an import library, and is attempting to load the dylib. I did build GLEW myself, and I can see that "-DGLEW_STATIC" was specified on the command line, when generating the objects for the static library.

Does anybody know how I might be able to tell if my GLEW library (libGLEW.a) is actually an import library for the dylib? And as a follow-up, how to build the library properly to avoid that?

1

1 Answers

5
votes

It looks like something else was actually happening here.

When I built the static GLEW library, it also built the dynamic version right next to it. Based on some other searches I made online, it seems that Xcode will automatically attempt to load up the dynamic version of a library, if a version of the same name exists in the library search path.

Once I deleted the dynamic version in my build folder ( libGLEW.dylib ), then the load error when away and I could link and invoke the static library functions without a problem.