Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8909499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:26:43+00:00 2026-06-15T03:26:43+00:00

I wanted to start using boost:python to embed python in my C++ program, but

  • 0

I wanted to start using boost:python to embed python in my C++ program, but I am already having problems with this simple code:

#include <boost/python.hpp> //boost libraries
#include <Python.h> //python libraries

using namespace boost::python;

int main()
{
    Py_Initialize();

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

    return 0;
}

I’m just starting the interpreter and importing the main module but the compiler already have problems with that:

/home/i7941878/Code/pythonTest/main.cpp:-1: error: undefined reference to `boost::python::detail::str_base::str_base(char const*)'

/home/i7941878/Code/pythonTest/main.cpp:-1: error: undefined reference to `boost::python::import(boost::python::str)'

/home/i7941878/Code/pythonTest/main.cpp:-1: error: undefined reference to `boost::python::api::getattr(boost::python::api::object const&, char const*)'

I don’t have a clue why I am getting those errors. I am pretty sure boost:python is built correctly.

Anyone able to enlight me?

I am using QT creator to build and compile.
If I compile using G++ with -I/usr/include -I/usr/include/python2.6 main.cpp I get:

/tmp/ccI8x97b.o: In function `main':
main.cpp:(.text+0xc): undefined reference to `Py_Initialize'
main.cpp:(.text+0x30): undefined reference to `boost::python::import(boost::python::str)'
/tmp/ccI8x97b.o: In function `boost::python::api::object::object()':
main.cpp:(.text._ZN5boost6python3api6objectC2Ev[_ZN5boost6python3api6objectC5Ev]+0xd): undefined reference to `_Py_NoneStruct'
/tmp/ccI8x97b.o: In function `boost::python::api::const_attribute_policies::get(boost::python::api::object const&, char const*)':
main.cpp:(.text._ZN5boost6python3api24const_attribute_policies3getERKNS1_6objectEPKc[boost::python::api::const_attribute_policies::get(boost::python::api::object const&, char const*)]+0x26): undefined reference to `boost::python::api::getattr(boost::python::api::object const&, char const*)'
/tmp/ccI8x97b.o: In function `boost::python::str::str(char const*)':
main.cpp:(.text._ZN5boost6python3strC2EPKc[_ZN5boost6python3strC5EPKc]+0x1f): undefined reference to `boost::python::detail::str_base::str_base(char const*)'
collect2: ld returned 1 exit status
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:26:45+00:00Added an answer on June 15, 2026 at 3:26 am

    I think we really need the way in which you are compiling the code. Have you specified the boost includes?

    g++ code.cpp -lboost_python -lboost_system
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to start using the Amazon Simple Notification Service ( http://aws.amazon.com/sns/ ), but
just wanted to start some C++ and created these simple class: Ellipsoid.h #ifndef __Ellipsoid__Ellipsoid__
Being new to maglev I wanted to start with a small, but still useful
I am using boost::program_options and want to pass domain-like options to my program. Such
I wanted to start using attr_accessible with my models to stop the problem with
In an effort to write better code, I've committed to using boost's smart pointers.
Im checking the examples google gives on how to start using python; especifically the
Im fairly new to Oauth2.0. I wanted to start using the Google Plus api.
I am sure this Question has been asked a lot of time. But wanted
I am considering to start using Pexpect. On Pexpects homepage I find this: Q:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.