FreeOrion

Forums for the FreeOrion project
It is currently Fri Jul 25, 2014 8:57 am

All times are UTC




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Tue May 15, 2012 1:09 pm 
Offline
Space Floater

Joined: Thu May 28, 2009 10:08 pm
Posts: 42
FreeOrion/AI/PythonAI.cpp: In constructor 'PythonAI::PythonAI()':
FreeOrion/AI/PythonAI.cpp:195:29: error: 'initfreeOrionLogger' was not declared in this scope
FreeOrion/AI/PythonAI.cpp:196:34: error: 'initfreeOrionAIInterface' was not declared in this scope

initXXX() are supposed to be provided by BOOST_PYTHON_MODULE(). I'm guessing here, but I think it has been changed to provide PyInit_XXX() instead in new versions (as I managed to get compiler errors from such a function after doing some modifications). Googling for examples also reveals that while everyone says that BOOST_PYTHON_MODULE() does define initXXX() those examples never explicitly call it. I cannot find definitive documentation, but it seems that initXXX() functions are just internal detail of handling these modules one is not supposed to call.

However, after I had just removed those lines compilation still failed due to another problem in same module, so I cannot say if their removal fixes or breaks things.


Top
 Profile  
 
PostPosted: Fri May 18, 2012 2:35 am 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 9732
Location: Munich
Use Boost 1.47 and things should work. Otherwise, you're on your own until FO updates the supported versions.


Top
 Profile  
 
PostPosted: Mon Jul 23, 2012 7:02 pm 
Offline
Space Krill

Joined: Mon Jul 23, 2012 6:56 pm
Posts: 6
I don't think that this is related to boost, it is rather related to the user having python-3 active, at least I can perfectly reproduce the error messages with this:

Code:
make -f client/human/CMakeFiles/freeorion.dir/build.make client/human/CMakeFiles/freeorion.dir/depend
make[2]: Entering directory `/var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890_build'
cd /var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890_build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890/FreeOrion /var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890/FreeOrion/client/human /var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890_build /var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890_build/client/human /var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890_build/client/human/CMakeFiles/freeorion.dir/DependInfo.cmake --color=
Dependee "/var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890_build/client/human/CMakeFiles/freeorion.dir/DependInfo.cmake" is newer than depender "/var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890_build/client/human/CMakeFiles/freeorion.dir/depend.internal".
Dependee "/var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890_build/client/human/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890_build/client/human/CMakeFiles/freeorion.dir/depend.internal".
Scanning dependencies of target freeorion
In file included from /usr/include/boost-1_48/boost/python/detail/wrap_python.hpp:50:0,
                 from /usr/include/boost-1_48/boost/python/detail/prefix.hpp:13,
                 from /usr/include/boost-1_48/boost/python/args.hpp:8,
                 from /usr/include/boost-1_48/boost/python.hpp:11,
                 from /var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890/FreeOrion/AI/PythonAI.h:3,
                 from /var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890/FreeOrion/AI/PythonAI.cpp:1:
/usr/include/python3.2/pyconfig.h:1182:0: warning: "_POSIX_C_SOURCE" redefined
/usr/include/features.h:164:0: note: this is the location of the previous definition
/usr/include/python3.2/pyconfig.h:1204:0: warning: "_XOPEN_SOURCE" redefined
/usr/include/features.h:166:0: note: this is the location of the previous definition
/var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890/FreeOrion/AI/PythonAI.cpp: In constructor ‘PythonAI::PythonAI()’:
/var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890/FreeOrion/AI/PythonAI.cpp:195:29: error: ‘initfreeOrionLogger’ was not declared in this scope
/var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890/FreeOrion/AI/PythonAI.cpp:196:34: error: ‘initfreeOrionAIInterface’ was not declared in this scope
/usr/include/boost-1_48/boost/system/error_code.hpp: At global scope:
/usr/include/boost-1_48/boost/system/error_code.hpp:214:35: warning: ‘boost::system::posix_category’ defined but not used
/usr/include/boost-1_48/boost/system/error_code.hpp:215:35: warning: ‘boost::system::errno_ecat’ defined but not used
/usr/include/boost-1_48/boost/system/error_code.hpp:216:35: warning: ‘boost::system::native_ecat’ defined but not used
make[2]: *** [client/AI/CMakeFiles/freeorionca.dir/__/__/AI/PythonAI.cpp.o] Error 1
make[2]: Leaving directory `/var/tmp/portage/games-strategy/freeorion-0.3.17_p4890/work/freeorion-0.3.17_p4890_build'
make[1]: *** [client/AI/CMakeFiles/freeorionca.dir/all] Error 2


make sure you have python-2 active/installed/however you do that on your distro

This is a bug in the build system actually (which uses FindPythonLibs.cmake module). It should not allow the user to build with unsupported versions and give a meaningful error message.


Top
 Profile  
 
PostPosted: Mon Jul 23, 2012 7:31 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 9732
Location: Munich
hasufell wrote:
This is a bug in the build system actually (which uses FindPythonLibs.cmake module). It should not allow the user to build with unsupported versions and give a meaningful error message.
Can you suggest modifications to /client/AI/CMakeLists.txt that would restrict it to only accepting Python 2.x?
Code:
find_package(PythonLibs)
if (PYTHONLIBS_FOUND)
    include_directories(${PYTHON_INCLUDE_PATH})
else ()
    message(FATAL_ERROR " library not found.")
endif ()


Top
 Profile  
 
PostPosted: Tue Jul 24, 2012 8:40 pm 
Offline
Space Krill

Joined: Mon Jul 23, 2012 6:56 pm
Posts: 6
Code:
--- client/AI/CMakeLists.txt
+++ client/AI/CMakeLists.txt
@@ -33,6 +33,20 @@
 find_package(PythonLibs)
 if (PYTHONLIBS_FOUND)
     include_directories(${PYTHON_INCLUDE_PATH})
+    SET(_VERSION_REGEX
+      "^#define[ \t]+PY([A-Z_]*_VERSION)[ \t]+[\"]*([0-9A-Za-z\\.]+)[\"]*[ \t]*$")
+    FILE(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" _VERSION_STRINGS
+       LIMIT_COUNT 10 REGEX ${_VERSION_REGEX})
+    FOREACH(_VERSION_STRING ${_VERSION_STRINGS})
+        STRING(REGEX REPLACE ${_VERSION_REGEX} "PYTHON\\1"
+           _VERSION_VARIABLE "${_VERSION_STRING}")
+        STRING(REGEX REPLACE ${_VERSION_REGEX} "\\2"
+           _VERSION_NUMBER "${_VERSION_STRING}")
+        SET(${_VERSION_VARIABLE} ${_VERSION_NUMBER})
+    ENDFOREACH(_VERSION_STRING ${_VERSION_STRINGS})
+    IF(PYTHON_MAJOR_VERSION EQUAL 3)
+        MESSAGE(FATAL_ERROR "Python 3 is not supported!")
+    ENDIF()
 else ()
     message(FATAL_ERROR " library not found.")
 endif ()


tested it and seems to work (on Linux). Code taken from http://www.cmake.org/pipermail/cmake/20 ... 45292.html


Top
 Profile  
 
PostPosted: Tue Jul 24, 2012 11:01 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 9732
Location: Munich
What does it do, exactly? Find the python version for the specific python include directory, or of an include directory found on the system? That is, does specifying a particular location for python 2.7 make it work even if more than one version is installed?


Top
 Profile  
 
PostPosted: Wed Jul 25, 2012 1:10 pm 
Offline
Space Krill

Joined: Mon Jul 23, 2012 6:56 pm
Posts: 6
Quote:
+# look in PYTHON_INCLUDE_DIR for patchlevel.h, which contains the
+# version number macros in all versions of python from 1.5 through
+# at least version 3.2, and set these vars: PYTHON_VERSION,
+# PYTHON_MAJOR_VERSION, PYTHON_MINOR_VERSION, PYTHON_MICRO_VERSION.


where PYTHON_INCLUDE_DIR is simply the one found by the cmake module "FindPythonLibs" which is already used in your code


Top
 Profile  
 
PostPosted: Wed Oct 03, 2012 2:34 am 
Offline
Space Floater

Joined: Thu May 28, 2009 10:08 pm
Posts: 42
The change made here just added more meaningful error message (that "python3 is not supported") but the error remains that when have several python versions installed, find_package() may find python3 and consequently leads to this error though python2 is available. It should be simply matter of specifying version 2 (and not default "any") for find_package(). I'm testing this.


Top
 Profile  
 
PostPosted: Wed Oct 03, 2012 3:06 am 
Offline
Space Floater

Joined: Thu May 28, 2009 10:08 pm
Posts: 42
With the attached patch I finally got compilation to pass on system with python3 as preferred python version (while still having python2 available)


Attachments:
RequirePython2.patch [1.28 KiB]
Downloaded 10 times
Top
 Profile  
 
PostPosted: Wed Oct 03, 2012 3:53 am 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 9732
Location: Munich
Presumably the error message should say something about Python 2.x not being found, rather than just Python not found, since it will reject Python 3.x ?

And did you test that it actually builds and runs when configuring after that change when python 3 is present?


Top
 Profile  
 
PostPosted: Wed Oct 03, 2012 11:16 am 
Offline
Space Krill

Joined: Mon Jul 23, 2012 6:56 pm
Posts: 6
nice, I didn't even know the module takes a version argument

I will test it shortly too


Top
 Profile  
 
PostPosted: Wed Oct 03, 2012 8:49 pm 
Offline
Space Floater

Joined: Thu May 28, 2009 10:08 pm
Posts: 42
Geoff the Medio wrote:
Presumably the error message should say something about Python 2.x not being found, rather than just Python not found, since it will reject Python 3.x ?


Yes, that occurred to me too, but only after I had already sent the patch.

Geoff the Medio wrote:
And did you test that it actually builds and runs when configuring after that change when python 3 is present?


Yes. I have python2.6, python2.7, and python3.2 present in this system. Without the patch it aborts with "python3 not supported" message. With the patch it builds, and game launches.


Top
 Profile  
 
PostPosted: Wed Oct 03, 2012 8:51 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 9732
Location: Munich
cazfi wrote:
Geoff the Medio wrote:
Presumably the error message should say something about Python 2.x not being found, rather than just Python not found, since it will reject Python 3.x ?
Yes, that occurred to me too, but only after I had already sent the patch.
Could you update accordingly and re-attach?


Top
 Profile  
 
PostPosted: Wed Oct 03, 2012 9:12 pm 
Offline
Space Floater

Joined: Thu May 28, 2009 10:08 pm
Posts: 42
Geoff the Medio wrote:
cazfi wrote:
Geoff the Medio wrote:
Presumably the error message should say something about Python 2.x not being found, rather than just Python not found, since it will reject Python 3.x ?
Yes, that occurred to me too, but only after I had already sent the patch.
Could you update accordingly and re-attach?

Here


Attachments:
RequirePython2.patch [1.28 KiB]
Downloaded 7 times
Top
 Profile  
 
PostPosted: Wed Oct 03, 2012 9:17 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 9732
Location: Munich
Thanks. I'll commit that later when I have a chance, unless someone else want to do so before I can.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group