Fail building wrapp.cpp.o
AlexisLeC opened this issue · 2 comments
AlexisLeC commented
Dear all
I tried to build Boost.NumPy with python3.4, np 1.8.1 and boost 1.55.0 on ubuntu
First build with CMake-init.sh went right but when i tried to "make" in the created build directory I came up againt an error when building the wrap.cpp.o in the example directory?
[ 68%] Building CXX object libs/numpy/example/CMakeFiles/wrap.dir/wrap.cpp.o
../libs/numpy/example/wrap.cpp: In function ‘int main(int, char**)’:
../libs/numpy/example/wrap.cpp:114:40: error: ‘initexample’ was not declared in this scope
PyImport_AppendInittab("example", &initexample);
^
make[2]: *** [libs/numpy/example/CMakeFiles/wrap.dir/wrap.cpp.o] Erreur 1
make[1]: *** [libs/numpy/example/CMakeFiles/wrap.dir/all] Erreur 2
make: *** [all] Erreur 2
termoshtt commented
In boost/python/module_init.hpp
, the name of this initation function is generated as init
+ example
(module name) for Python2 and PyInit_
+ example
(module name) for Python3.
When I replace initexample
with PyInit_example
, it works.
This function name is generated as a part of function definition,
and there is no macro to generate function name only.
Only way to avoid this is to switch the function name using preprocessor:
# if PY_VERSION_HEX >= 0x03000000
PyImport_AppendInittab("example", &PyInit_example);
# else
PyImport_AppendInittab("example", &initexample);
# endif