Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile OpenGL with a python C++ extension using distutils on Mac OSX?

Tags:

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])
like image 248
Matthew Mitchell Avatar asked May 02 '10 18:05

Matthew Mitchell


1 Answers

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.

like image 78
Tim Avatar answered Sep 20 '22 04:09

Tim