I'm trying to use the Python module on Boost. However, I'm getting an error that I cannot find what to do with.
It seems a missing switch or something, but I really could not find...
Does anyone have a clue?
Thanks!!!
/usr/include/python3.8/object.h|478|undefined reference to `_Py_Dealloc'|
System data:
Using Code::blocks, Python 3.8, Linux Mint, installed Boost by apt-get
Build log:
g++ -Wall -fexceptions -g -I/usr/lib/x86_64-linux-gnu/ -I/usr/include/python3.8/ -I/home/tavares/Downloads/boost/boost_1_77_0/stage/lib -c /home/tavares/Trabalho/pesquisa/softwares/optpipeline/PyOPY/PyOPI/bark.cpp -o obj/Debug/bark.o
g++ -Wall -fexceptions -g -I/usr/lib/x86_64-linux-gnu/ -I/usr/include/python3.8/ -I/home/tavares/Downloads/boost/boost_1_77_0/stage/lib -c /home/tavares/Trabalho/pesquisa/softwares/optpipeline/PyOPY/PyOPI/main.cpp -o obj/Debug/main.o
g++ -L/usr/lib/x86_64-linux-gnu/ -o bin/Debug/PyOPI obj/Debug/bark.o obj/Debug/main.o -lboost_program_options -lboost_system -lboost_python38
/usr/bin/ld: obj/Debug/bark.o: in function `_Py_DECREF':
/usr/include/python3.8/object.h:478: undefined reference to `_Py_Dealloc'
/usr/bin/ld: obj/Debug/bark.o: in function `boost::python::detail::none()':
/usr/local/include/boost/python/detail/none.hpp:16: undefined reference to `_Py_NoneStruct'
/usr/bin/ld: /usr/local/include/boost/python/detail/none.hpp:16: undefined reference to `_Py_NoneStruct'
/usr/bin/ld: obj/Debug/bark.o: in function `boost::python::api::object::object()':
/usr/local/include/boost/python/object_core.hpp:400: undefined reference to `_Py_NoneStruct'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu//libboost_python38.so: undefined reference to `PyExc_ValueError'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu//libboost_python38.so: undefined reference to `PyLong_AsLong'
This is kinda old, but try adding
$(python3.10-config --ldflags --embed)
to the commands at the linking phase.
Your link command becomes something like
g++ -L/usr/lib/x86_64-linux-gnu/ -o bin/Debug/PyOPI obj/Debug/bark.o obj/Debug/main.o -lboost_program_options -lboost_system -lboost_python38
$(python3.10-config --ldflags --embed)
Hope this helps someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With