没有为-lpython3找到的库

时间:2022-08-11 02:39:54

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/

我正在尝试按照以下步骤编译一些C代码以从这里给出的示例导入到Python中: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:

但是我用的是Python 3,我把一堆编译错误搞混了,然后解决了,结果是:

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:

从我有限的知识中,我尝试了一些东西。我发现我有两个Python版本存在的位置:

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

/系统/图书馆/框架/ Python.framework /版本

and also:

还有:

/Library/Frameworks/Python.framework/Versions

/图书馆/框架/ Python.framework /版本

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.

Python 3.2位于第二位置,所以我认为我需要告诉gcc在哪里搜索来解析- lpython320 ?或者-lpython3。2是错的,我试过-lpython3。2,但是我从ld中得到了相同类型的错误。

Other facts that might help:

其他可能有用的事实:

Mac OS 10.6.8

Mac OS 10.6.8

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

Python 3.2安装自您从Python.org获得的DMG

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

如果有任何其他的信息我可以给你帮助我,然后请让我知道

1 个解决方案

#1


2  

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.

要告诉gcc其他目录搜索库,您可以使用-L选项,类似于您正在使用的-I选项。比如-L/Library/ framework/ Python.framework/ version /3.2/lib。

#1


2  

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.

要告诉gcc其他目录搜索库,您可以使用-L选项,类似于您正在使用的-I选项。比如-L/Library/ framework/ Python.framework/ version /3.2/lib。