#32 improper setting of -install_name on darwin

Jack Howarth

Currently glew, when built on darwin, produces....

[MacPro:/opt/local/lib] howarth% ls -l libGLEW*dylib
-rw-r--r-- 1 root admin 426800 Apr 30 16:01 libGLEW.1.6.0.dylib
lrwxr-xr-x 1 root admin 19 Apr 30 16:01 libGLEW.1.6.dylib -> libGLEW.1.6.0.dylib
lrwxr-xr-x 1 root admin 19 Apr 30 16:01 libGLEW.dylib -> libGLEW.1.6.0.dylib


[MacPro:/opt/local/lib] howarth% otool -L libGLEW.1.6.0.dylib
/opt/local/lib/libGLEW.1.6.0.dylib (compatibility version 0.0.0, current version 0.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.0.0)

This means that each time glew is updated, any program which has linked against the libGLEW shared library has to be relinked. Fink has worked around this by changing the install name of libGLEW.1.6.0.dylib to libGLEW.1.dylib using the approach in the attached patch. The patch also addresses the missing settings of the current version and compatibility version of libGLEW. Still to be addressed is fixing the Makefile to create the missing symlink for libGLEW.1.dylib pointing at libGLEW$(SO_VERSION).dylib. These changes would allow libGLEW to be linked into binaries as libGLEW.1.dylib so that upgrades would not break pre-existing programs linked against libGLEW (like the recent pymol 1.4 release).


  • Jack Howarth
    Jack Howarth

    fix to install name for libGLEW

  • Nigel Stewart
    Nigel Stewart

    Does this look right? (Patch attached)

    $ make
    mkdir lib
    cc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude -no-cpp-precomp -dynamic -fno-common -fPIC -o src/glew.pic_o -c src/glew.c
    cc -dynamiclib -install_name /usr/lib/libGLEW.1.7.0.dylib -current_version 1.7.0 -compatibility_version 1.7 -o lib/libGLEW.1.7.0.dylib src/glew.pic_o -framework AGL -framework OpenGL
    ln -sf libGLEW.1.7.0.dylib lib/libGLEW.1.7.dylib
    ln -sf libGLEW.1.7.0.dylib lib/libGLEW.dylib
    cc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude -no-cpp-precomp -dynamic -fno-common -o src/glew.o -c src/glew.c
    ar cr lib/libGLEW.a src/glew.o
    sed \ -e "s|@prefix@|/usr|g" \ -e "s|@libdir@|/usr/lib|g" \ -e "s|@exec_prefix@|/usr/bin|g" \ -e "s|@includedir@|/usr/include/GL|g" \ -e "s|@version@|1.7.0|g" \ -e "s|@cflags@||g" \ -e "s|@libname@|GLEW|g" \ < glew.pc.in > glew.pc
    cc -DGLEW_NO_GLU -DGLEW_MX -O2 -Wall -W -Iinclude -no-cpp-precomp -dynamic -fno-common -fPIC -o src/glew.mx.pic_o -c src/glew.c
    cc -dynamiclib -install_name /usr/lib/libGLEWmx.1.7.0.dylib -current_version 1.7.0 -compatibility_version 1.7 -o lib/libGLEWmx.1.7.0.dylib src/glew.mx.pic_o -framework AGL -framework OpenGL
    ln -sf libGLEWmx.1.7.0.dylib lib/libGLEWmx.1.7.dylib
    ln -sf libGLEWmx.1.7.0.dylib lib/libGLEWmx.dylib
    cc -DGLEW_NO_GLU -DGLEW_MX -O2 -Wall -W -Iinclude -no-cpp-precomp -dynamic -fno-common -o src/glew.mx.o -c src/glew.c
    ar cr lib/libGLEWmx.a src/glew.mx.o
    sed \ -e "s|@prefix@|/usr|g" \ -e "s|@libdir@|/usr/lib|g" \ -e "s|@exec_prefix@|/usr/bin|g" \ -e "s|@includedir@|/usr/include/GL|g" \ -e "s|@version@|1.7.0|g" \ -e "s|@cflags@|-DGLEW_MX|g" \ -e "s|@libname@|GLEWmx|g" \ < glew.pc.in > glewmx.pc
    mkdir bin
    cc -c -O2 -Wall -W -Iinclude -no-cpp-precomp -dynamic -fno-common -o src/glewinfo.o src/glewinfo.c
    cc -O2 -Wall -W -Iinclude -no-cpp-precomp -dynamic -fno-common -o bin/glewinfo src/glewinfo.o -Llib -lGLEW -framework AGL -framework OpenGL
    cc -c -O2 -Wall -W -Iinclude -no-cpp-precomp -dynamic -fno-common -o src/visualinfo.o src/visualinfo.c
    src/visualinfo.c: In function ‘VisualInfo’:
    src/visualinfo.c:583: warning: unused parameter ‘ctx’
    cc -O2 -Wall -W -Iinclude -no-cpp-precomp -dynamic -fno-common -o bin/visualinfo src/visualinfo.o -Llib -lGLEW -framework AGL -framework OpenGL

    $ otool -L lib/libGLEW.1.7.0.dylib
    /usr/lib/libGLEW.1.7.0.dylib (compatibility version 1.7.0, current version 1.7.0)
    /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)

  • Nigel Stewart
    Nigel Stewart

    Jack, what's the motivation for a libGLEW.dylib and libGLEW.1.dylib?
    The idea is that libGLEW.1.7.x.dylib supports the 1.7.0 API.
    GLEW hasn't changed the major version number ever.

  • Benjamin Reed
    Benjamin Reed

    So a binary linked against libGLEW.1.6.x.dylib is not supposed to run against libGLEW.1.7.x.dylib? That's how the default makefiles work on Mac OS X. OSX always encodes rpath into things that link against a library.

    That first line in the otool -L output from the original comment means, "if something links against this binary, it will expect to always find a compatible library at /opt/local/lib/libGLEW.1.6.0.dylib

    So when GLEW 1.7 comes out, existing binaries linked against libGLEW.1.6.0.dylib would break, because the new library would be called /opt/local/lib/libGLEW.1.7.0.dylib



Cancel   Add attachments