[英]embedding python into c++ library
I want to embed python into an shared library. 我想将python嵌入共享库中。
I use elmer to create the c code from a python script. 我使用elmer从python脚本创建c代码。 This code I compile into a static library. 我将此代码编译到静态库中。 I used python2.7-config --cflags --ldflags
to get the compiler and linker flags for my system . 我使用python2.7-config --cflags --ldflags
来获取系统的编译器和链接器标志 。
Now when I want to test this static library with a test application I get many undefined reference to
errors (for every Py
- and el
-function). 现在,当我想使用测试应用程序测试此静态库时,我得到了许多undefined reference to
错误undefined reference to
(对于每个Py
和el
-function)。 These errors are located in the (from elmer) generated c file. 这些错误位于(来自elmer)生成的c文件中。
I know there is an issue with embedding python. 我知道嵌入python存在问题 。 I got this to work in the past one time (without linking my test application to python or elmer) but I do not know how... (yeah, it is better to document something like this^^ ) 我在过去的一遍中就做到了这一点(没有将我的测试应用程序链接到python或elmer),但是我不知道如何...(是的,最好记录这样的东西^^)
thanks to nm I got the answer: 感谢nm我得到了答案:
I learned that while building a static lib the linker is not invoked. 我了解到,在构建静态库时,不会调用链接器。 So moving the cflags and ldflags to the next shared lib/application solved the problem. 因此,将cflags和ldflags移至下一个共享的lib /应用程序即可解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.