|
Boost : |
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2021-07-11 23:43:00
On 7/9/21 1:09 PM, maths soso via Boost wrote:
> I'm new to boost, I decided installing it by following instructions
> provided at SO:
> https://stackoverflow.com/a/24086375/10213771
> (The only difference is that I used version 1.76)
> Everything went fine, then I decided to compile this C++ file:
>
> char const* greet(){
> return "hello, world";}
> #include <boost/python.hpp>
>
> BOOST_PYTHON_MODULE(hello_ext){
> using namespace boost::python;
> def("greet", greet);}
>
>
> Since boost.python is not header only library, I needed to link to it on
> compilation, I used the following compile command:
> g++ -I ~/Desktop/boost_1_76_0/ -I /usr/include/python2.7/ main.cpp -o prog
> ~/Desktop/boost_1_76_0/stage/lib/libboost_python27.a
>
> but I get the following errors:
> /usr/bin/ld:
> /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in
> function `_start':
> (.text+0x24): undefined reference to `main'
> /usr/bin/ld:
> /home/sofiane/Desktop/boost_1_76_0/stage/lib/libboost_python27.a(registry.o):
> in function `boost::python::converter::registration::get_class_object()
> const':
> ...
> /usr/bin/ld: function_doc_signature.cpp:(.text+0x1de): undefined reference
> to `PyObject_IsTrue'
> /usr/bin/ld: function_doc_signature.cpp:(.text+0x23e): undefined reference
> to `PyInt_FromLong'
> /usr/bin/ld: function_doc_signature.cpp:(.text+0x28b): undefined reference
> to `PyInt_FromLong'
I'm not a Python expert, but it looks like:
1. You are not linking to the python library that implements the missing
symbols.
2. You are missing `main` function or the -c compiler option to indicate
that you want to only compile the file, not link it.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk