Vega-strike-engine-source: Python2 is deprecated -- ensure that VS can (optionally) be built against Python3 out of the box

Created on 30 Apr 2020  路  8Comments  路  Source: vegastrike/Vega-Strike-Engine-Source

Just tried building VS against python3 using both the included boost-1.72 and the system boost (1.66 in my case on Solus).

For the included boost-1.72 I get the following error:

[ 50%] Linking CXX executable vegaserver
/usr/bin/ld: cannot find -lboost_python

For the system boost-1.66 I get the following errors:

[ 63%] Linking CXX executable vegaserver
/usr/bin/ld: CMakeFiles/vegaserver.dir/src/cmd/script/director_server.cpp.o: in function `PyInit_Base':
director_server.cpp:(.text+0x1e): undefined reference to `boost::python::detail::init_module(PyModuleDef&, void (*)())'
/usr/bin/ld: director_server.cpp:(.text+0x49): undefined reference to `boost::python::detail::init_module(PyModuleDef&, void (*)())'
/usr/bin/ld: CMakeFiles/vegaserver.dir/src/cmd/script/director_server.cpp.o: in function `PyInit_Briefing':
director_server.cpp:(.text+0xa6): undefined reference to `boost::python::detail::init_module(PyModuleDef&, void (*)())'
/usr/bin/ld: director_server.cpp:(.text+0xd1): undefined reference to `boost::python::detail::init_module(PyModuleDef&, void (*)())'
/usr/bin/ld: libengine_com.a(unit_wrapper.cpp.o): in function `PyInit_VS':
unit_wrapper.cpp:(.text+0x86): undefined reference to `boost::python::detail::init_module(PyModuleDef&, void (*)())'
/usr/bin/ld: libengine_com.a(unit_wrapper.cpp.o):unit_wrapper.cpp:(.text+0xb1): more undefined references to `boost::python::detail::init_module(PyModuleDef&, void (*)())' follow
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_Size'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyUnicodeUCS4_FromEncodedObject'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyFile_FromString'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_Type'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyInt_Type'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_FromString'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyUnicodeUCS4_AsWideChar'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_FromStringAndSize'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `Py_InitModule4_64'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_FromFormat'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyNumber_Divide'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceDivide'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyInt_AsLong'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_InternFromString'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyClass_Type'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_AsString'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyInt_FromLong'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyFile_AsFile'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/vegaserver.dir/build.make:596: vegaserver] Error 1
make[1]: *** [CMakeFiles/Makefile2:185: CMakeFiles/vegaserver.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
# ... end of build
[100%] Linking CXX executable vegastrike
/usr/bin/ld: CMakeFiles/vegastrike.dir/src/cmd/base_init.cpp.o: in function `PyInit_Base':
base_init.cpp:(.text+0x16): undefined reference to `boost::python::detail::init_module(PyModuleDef&, void (*)())'
/usr/bin/ld: base_init.cpp:(.text+0x41): undefined reference to `boost::python::detail::init_module(PyModuleDef&, void (*)())'
/usr/bin/ld: CMakeFiles/vegastrike.dir/src/python/briefing_wrapper.cpp.o: in function `PyInit_Briefing':
briefing_wrapper.cpp:(.text+0x23e): undefined reference to `boost::python::detail::init_module(PyModuleDef&, void (*)())'
/usr/bin/ld: briefing_wrapper.cpp:(.text+0x269): undefined reference to `boost::python::detail::init_module(PyModuleDef&, void (*)())'
/usr/bin/ld: libengine_com.a(unit_wrapper.cpp.o): in function `PyInit_VS':
unit_wrapper.cpp:(.text+0x86): undefined reference to `boost::python::detail::init_module(PyModuleDef&, void (*)())'
/usr/bin/ld: libengine_com.a(unit_wrapper.cpp.o):unit_wrapper.cpp:(.text+0xb1): more undefined references to `boost::python::detail::init_module(PyModuleDef&, void (*)())' follow
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyClass_Type'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_FromString'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyFile_AsFile'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_Size'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_FromStringAndSize'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `Py_InitModule4_64'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_InternFromString'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyInt_Type'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyInt_FromLong'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyUnicodeUCS4_AsWideChar'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyInt_AsLong'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyFile_FromString'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyNumber_Divide'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_Type'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_AsString'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyString_FromFormat'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyUnicodeUCS4_FromEncodedObject'
/usr/bin/ld: /usr/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceDivide'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/vegastrike.dir/build.make:3082: vegastrike] Error 1
make[1]: *** [CMakeFiles/Makefile2:296: CMakeFiles/vegastrike.dir/all] Error 2
make: *** [Makefile:104: all] Error 2

... help?

All 8 comments

Don't know if this is in any way useful:

https://github.com/Taose/Vegastrike-taose/commit/84a72eb9fa9b77dcfde1c04159f69caa7f0f32b5

EDIT: Nevermind. I see that this has already been merged. =)

I had VS building with python 3 for windows. I didn't deal with the linux side so never tested.

@ermo I had no issues with that on Arch.
I'll have to recheck the compilation log later because I do remember cmake complaining about something. Though not failing.

I succeded in building against boost-1.66 w/py3 per the notes in https://wiki.vega-strike.org/HowTo:Compile_from_SVN_on_Linux#Using_Python_3

On Solus, it was a question of building VS with py3 against Boost_PYTHON_LIBRARY_RELEASE=/usr/lib/libboost_python3.soinstead of Boost_PYTHON_LIBRARY_RELEASE=/usr/lib/libboost_python.so.

In terms of CMakeLists.txt, if USE_PYTHON_3=ON, I need to find a way to persuade cmake to change the Boost_PYTHON_LIBRARY_RELEASE variable automagically which probably involves searching for a list of plausible .so names or something like that...

Whether it runs is another matter; that's up next!

Don't know how useful it is, but the link below has a boost c++ example for working with python unicode strings?

https://wiki.python.org/moin/boost.python/EmbeddingPython

Also of note: There is a package on Ubuntu (18.04?) called 2to3, which can assist in converting Python 2 code to Python 3 code. (There are other differences besides the string types.)

Also of note: There is a package on Ubuntu (18.04?) called 2to3, which can assist in converting Python 2 code to Python 3 code. (There are other differences besides the string types.)

To be clear, this issue is only about the CMake and C++ part of building VS, not the python data modules.

2to3 is a Python package available in Python's pip; many distros do include it but you can always get the lasts from pip; just don't do pip install --upgrade on your system python as that'll break a tone of things. 2to3 updates the imports, strings, and gives warnings about stuff that'll break compatibility.

six also provides a compatibility layer to help with things moving around; it's also pip installable.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BenjamenMeyer picture BenjamenMeyer  路  3Comments

BenjamenMeyer picture BenjamenMeyer  路  6Comments

BenjamenMeyer picture BenjamenMeyer  路  3Comments

nabaco picture nabaco  路  4Comments

nabaco picture nabaco  路  3Comments