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

  • SEARCH
  • Home
  • 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 1808616
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:17:01+00:00 2026-05-17T06:17:01+00:00

I’m just trying to compile the hello world example of boost.python WITHOUT using all

  • 0

I’m just trying to compile the “hello world” example of boost.python WITHOUT using all the bjam magic. My boost.python installation is working, I did succesfully build the example with bjam and passed the test suite.

Now for my project I need to use all this stuff in a plain Make environment. I don’t want to port to another build tool.

So my naive approach is of course to just point the include path to the right headers and link against the right library. I built boost python as system-layout, static, runtime-static, which means it is just a libboost_python.a that resides in /usr/local/lib.

Unfortunately, I get unresolved external symbols in the resulting .so library.

Here is my try to build the example from libs/python/example/tutorial/hello.cpp:

$ cat hello.cpp
//  Copyright Joel de Guzman 2002-2004. Distributed under the Boost
//  Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt
//  or copy at http://www.boost.org/LICENSE_1_0.txt)
//  Hello World Example from the tutorial
//  [Joel de Guzman 10/9/2002]

#include <boost/python/module.hpp>
#include <boost/python/def.hpp>

char const* greet()
{
   return "hello, world";
}

BOOST_PYTHON_MODULE(hello_ext)
{
    using namespace boost::python;
    def("greet", greet);
}

$ g++ -I/usr/local/include -I/usr/include/python -fpic -c -o hello.o
hello.cpp
$ g++ -shared -Wl,-soname,"libhello.so" -L/usr/local/lib -lboost_python -fpic -o libhello.so hello.o
$ nm -u libhello.so
                 U PyString_Type
                 w _Jv_RegisterClasses
                 U _Py_NoneStruct
                 U _Unwind_Resume@@GCC_3.0
                 U _ZN5boost6python6detail11init_moduleEPKcPFvvE
                 U _ZN5boost6python6detail12gcc_demangleEPKc
                 U
_ZN5boost6python6detail17scope_setattr_docEPKcRKNS0_3api6objectES3_
                 U
_ZN5boost6python7objects15function_objectERKNS1_11py_functionE
                 U _ZN5boost6python7objects21py_function_impl_baseD2Ev
                 U _ZN5boost6python9converter19do_return_to_pythonEPKc
                 U _ZN5boost6python9converter8registry5queryENS0_9type_infoE
                 U
_ZNK5boost6python7objects21py_function_impl_base9max_arityEv
                 U
_ZNK5boost6python9converter12registration25expected_from_python_typeEv
                 U _ZTIN5boost6python7objects21py_function_impl_baseE
                 U _ZTIPKc@@CXXABI_1.3
                 U _ZTIc@@CXXABI_1.3
                 U _ZTVN10__cxxabiv120__si_class_type_infoE@@CXXABI_1.3
                 U _ZTVN5boost6python7objects21py_function_impl_baseE
                 U _ZdlPv@@GLIBCXX_3.4
                 U _Znwm@@GLIBCXX_3.4
                 U __cxa_atexit@@GLIBC_2.2.5
                 w __cxa_finalize@@GLIBC_2.2.5
                 U __cxa_guard_abort@@CXXABI_1.3
                 U __cxa_guard_acquire@@CXXABI_1.3
                 U __cxa_guard_release@@CXXABI_1.3
                 w __gmon_start__
                 U __gxx_personality_v0@@CXXABI_1.3
$ python
>>> import libhello
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: ./libhello.so: undefined symbol:
_ZNK5boost6python7objects21py_function_impl_base9max_arityEv

So what is the big magic of bjam that when bjam links libboost_python.a
I get no undefined symbols, but when i do it “by hand” i get these?

  • 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-05-17T06:17:01+00:00Added an answer on May 17, 2026 at 6:17 am

    Well, I was obiously stupid. To link one has to put the object BEFORE the library with the symbols. So turning

    g++ -shared -Wl,-soname,"libhello.so" -L/usr/local/lib -lboost_python -fpic -o libhello.so hello.o
    

    into

    g++ -shared -Wl,-soname,"libhello.so" -L/usr/local/lib hello.o -lboost_python -fpic -o libhello.so
    

    Gave me the expected result, after I recompiled boost.python with cxxflags=-fPIC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.