Note that there are some explanatory texts on larger screens.

plurals
  1. POcannot import module using boost.python
    primarykey
    data
    text
    <p>I'm trying to build a simple program using boost.python. <br /> I have the following code:</p> <pre><code>//greet.cpp #include &lt;iostream&gt; #include &lt;boost/python.hpp&gt; void greet() { std::cout &lt;&lt; "hello world!" &lt;&lt; std::endl; } BOOST_PYTHON_MODULE(greet) { using namespace boost::python; def("greet", greet); } </code></pre> <p>and the follwing <code>makefile</code>:</p> <pre><code>PYTHON_VERSION := 2.7 PYTHON_INC := /usr/include/python$(PYTHON_VERSION) PYTHON_LIB_LOCATION := /usr/lib/python${PYTHON_VERSION} PYTHON_LIB_FILE := python${PYTHON_VERSION} BOOST_INC := ~/boost_1_54_0 BOOST_LIB_LOCATION := /home/elyashiv/boost_1_54_0/stage/lib BOOST_LIB_FILE := boost_python CC := gcc CFLAGS := -c -fPIC CInc := -I ${BOOST_INC} -I ${PYTHON_INC} CLinkFlags = -shared -Wl,-soname,$@ -L${BOOST_LIB_LOCATION} -l${BOOST_LIB_FILE} -L${PYTHON_LIB_LOCATION} -l${PYTHON_LIB_FILE} greet.o: greet.cpp %.so: %.o gcc ${CLinkFlags} -o $@ $^ %.o: %.cpp ${CC} ${CFLAGS} ${CInc} $^ </code></pre> <p>running <code>make greet.so</code> runs with just a few warnings (redefinition in some boost files). </p> <p>when I try to import the module in python I get the following:</p> <pre><code>Python 2.7.3 (default, Apr 10 2013, 05:46:21) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import greet Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; ImportError: ./greet.so: undefined symbol: _ZNK5boost6python7objects21py_function_impl_base9max_arityEv </code></pre> <p>what I have done wrong and how to fix it?</p> <p><strong>edit</strong></p> <p>the output of <code>ldd greet.so</code>:</p> <pre><code>linux-gate.so.1 =&gt; (0x001ee000) libgcc_s.so.1 =&gt; /lib/i386-linux-gnu/libgcc_s.so.1 (0x0055d000) libc.so.6 =&gt; /lib/i386-linux-gnu/libc.so.6 (0x0058e000) /lib/ld-linux.so.2 (0x003a2000) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload