25

When I try it I get:

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/cscalelib.so, 2): Symbol not found: _glBindFramebufferEXT Referenced from: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/cscalelib.so Expected in: dynamic lookup

I've tried all sort of things in the setup.py file. What do I actually need to put in it to link to OpenGL properly? My code compiles fine so there's no point putting that on there. Here is setup.py

from distutils.core import setup, Extension

module1 = Extension('cscalelib',
              extra_compile_args = ["-framework OpenGL", "-lm", "-lGL", "-lGLU"],
                    sources = ['cscalelib.cpp'])

setup (name = 'cscalelib',
       version = '0.1',
       description = 'Test for setup_framebuffer',
       ext_modules = [module1])
ZnArK
  • 1,533
  • 1
  • 12
  • 23
Matthew Mitchell
  • 5,293
  • 14
  • 70
  • 122
  • How does your current approach to link look? – Georg Fritzsche May 02 '10 at 19:46
  • Well the current setup.py looks like: from distutils.core import setup, Extension module1 = Extension('cscalelib', extra_compile_args = ["-framework OpenGL", "-lm", "-lGL", "-lGLU"], sources = ['cscalelib.cpp']) setup (name = 'cscalelib', version = '0.1', description = 'Test for setup_framebuffer', ext_modules = [module1]) I've tried lots of different things. That was an attempt to add lots of gcc arguments that might work. – Matthew Mitchell May 02 '10 at 19:55
  • 3
    What are the actual compiler commands that are executed? ('python setup.py build -v' should show you, if it doesn't by default. Remove the 'build' directory if it decides not to rebuild anything.) '-framework' seems to be a linker option, not a compiler option, so you should probably put it in `extra_link_args` instead -- but I have no idea if it will matter. – Thomas Wouters May 02 '10 at 22:45
  • 3
    I didn't realise I had to remove the build directory. Now it imports correctly. Thank you for that. For anyone that needs to know you need: extra_link_args=['-framework', 'OpenGL'] Delete the build directory and try it again. It will work. – Matthew Mitchell May 03 '10 at 11:29
  • Yeah, the lack of proper dependency checking (or rather, the lack of correctly seeing the `setup.py` file and anything it imports as dependency) is a bit of a weakness in distutils. – Thomas Wouters May 03 '10 at 13:14
  • not sure whether this is helpful, python do have a pyOPENGL binding – zinking Jun 29 '12 at 10:26
  • 5
    @ThomasWouters, it appears to me that you answered this question. So perhaps you'll turn your comment into an answer, so it can be accepted this question doesn't appear as unanswered forever. – MvG Jul 05 '12 at 16:06

1 Answers1

4

I didn't realise I had to remove the build directory. Now it imports correctly.

For anyone that needs to know you need: extra_link_args=['-framework', 'OpenGL'] Delete the build directory and try it again. It will work.

Tim
  • 35,413
  • 11
  • 95
  • 121