Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS X ld: library not found for -lpython3

I'm trying to follow the steps to compile some C code to import into Python from the example given here: http://csl.sublevel3.org/C-functions-from-Python/

I can compile it using the suggested invocation:

gcc -dynamiclib -I/usr/include/python2.3/ -lpython2.3 -o myModule.dylib myModule.c

But I'm using Python 3, I've muddled through and resolved a bunch of compiler errors, to end up with this:

gcc -dynamiclib -I/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m/ -lpython3.2m -o myModule.dylib myModule.c

But now I'm stuck, this gives the following error:

ld: library not found for -lpython3.2m

From my limited knowledge I tried some things out. I've found that I have two locations where Python versions exist:

/System/Library/Frameworks/Python.framework/Versions

and also:

/Library/Frameworks/Python.framework/Versions

Python 3.2 is located in the second place, so I think that somehow I need to tell gcc where to search to resolve the -lpython3.2m? Or that -lpython3.2m is wrong, I've tried -lpython3.2 but I get the same type of error from ld.

Other facts that might help:

Mac OS 10.6.8

Python 3.2 installed from the DMG that you get from Python.org

If there is any other information that I can give you to help you to help me then please let me know

like image 312
ilikeprogramming Avatar asked Jun 13 '12 13:06

ilikeprogramming


1 Answers

To tell gcc additional directories to search for libraries, you use the -L option, similar to the -I option you're already using. Something like -L/Library/Frameworks/Python.framework/Versions/3.2/lib, I would guess.

like image 98
Ken Thomases Avatar answered Nov 12 '22 03:11

Ken Thomases