Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Build Qt project with boost.python


I'm trying to compile this example but getting errors about undefined reference to PyInt_Type/PyString_FromString/PyNumber_Divide etc. I have already linked my build against boost_python and python3.6m.

I'm building it with g++ example.cpp -L/usr/include -lpython3.6m -L/usr/include/boost/python -lboost_python -I/usr/include/boost/python/ -I/usr/include/python3.6m



using namespace boost::python;

int main() {

object main_module = import("__main__");
object main_namespace = main_module.attr("__dict__");

object ignored = exec("hello = file('hello.txt', 'w')\n"
"hello.write('Hello world!')\n"

Note :

  1. I have python3.6-dev installed
  2. I was able to run this example using the same project and include directives
  3. Full list of errors
  4. I'm using Ubuntu 16.04

Also: If i understand correctly following thing happening: When i'm linking my build with lboost_python it uses some functions PyInt_Type, PyString_FromString. It has information about their return types and input parameters, but not their real definitions i.e. function body, that is defined in some other library (In my case it is python library) and i have to tell linker about this library to be include it in build. Is my understanding correct ? If yes then why linking against python3.6m didn't help ?

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered

This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Build Qt project with boost.python


Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription