2

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?

jujumbura
  • 425
  • 3
  • 9

1 Answers1

5

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.

jujumbura
  • 425
  • 3
  • 9
  • This! I just experienced the same thing. Any idea why this happen? Are there any config options one can do instead of deleting the dylib files? – thomthom Dec 20 '16 at 09:19
  • Ah, found this: https://developer.apple.com/library/content/qa/qa1393/_index.html "Note: There is no way to choose a static library over a corresponding dylib if both libraries are in the same directory without using the -l linker option and absolute paths to each library." Seems like an absolute path is required. – thomthom Dec 20 '16 at 09:33