libpandadna icon indicating copy to clipboard operation
libpandadna copied to clipboard

Problems compiling libpandadna on Ubuntu 18.10 with Panda3D 1.10

Open Maxwell175 opened this issue 6 years ago • 3 comments

Hello,

I am attempting to build libpandadna on Ubuntu 18.10 using Panda3D 1.10.

At first, I tried to just compile it using the usual cmake ., but I received the following output:

$ cmake .
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.6m.so (found version "3.6.7") 
-- Found PythonInterp: /usr/bin/python3.6 (found version "3.6.7") 
/bin/sh: 1: /stuff/tt/libpandadna/bin/interrogate: not found
Interrogating base

The following command return a non-zero value (127): /stuff/tt/libpandadna/bin/interrogate -D__inline -DCPPPARSER -DP3_INTERROGATE=1 -D__cplusplus -fnames -string -refcount -assert -S /stuff/tt/libpandadna/include/parser-inc -S /stuff/tt/libpandadna/include -I /stuff/tt/libpandadna/include -I/stuff/tt/libpandadna/src/base -I/stuff/tt/libpandadna/src/suit -I/stuff/tt/libpandadna/src/components -srcdir /stuff/tt/libpandadna/src/base -oc /stuff/tt/libpandadna/src/base_igate.cxx -od /stuff/tt/libpandadna/src/base.in -python-native -DCPPPARSER -D__STDC__=1 -D__cplusplus -D__inline -longlong __int64 -D_X86_ -DWIN32_VC -DWIN32 -module libpandadna -library base -Dvolatile= DNAStorage.h dnabase.h DNALoader.h config_dna.h
-- GCC Version: 8

-- libp3interrogatedb not found
-- libp3pandatoolbase not found
-- Configuring done
CMake Error at CMakeLists.txt:178 (add_library):
  Cannot find source file:

    src/base_igate.cxx

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx


CMake Error at CMakeLists.txt:178 (add_library):
  No SOURCES given to target: pandadna


-- Build files have been written to: /stuff/tt/libpandadna

First thing that I notice is that it is not correctly detecting where interrogate is installed. After making the following change,

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 93e7c02..6152ce8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,6 +24,9 @@ endif()
 if (WIN32)
     SET(PANDA_DIR "C:\\Panda3D-1.10.0" CACHE STRING "Panda3D directory.")
 endif()
+if (UNIX)
+    SET(PANDA_DIR "/usr" CACHE STRING "Panda3D directory.")
+endif (UNIX)
 SET(BUILD_STATIC_LIB OFF CACHE BOOL "If true, will build a static lib")
 execute_process(COMMAND ${PYTHON2_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/run_interrogate.py" "${PANDA_DIR}")

I get a different error:

$ cmake .
Warning: ignoring deprecated -longlong option.
/stuff/tt/libpandadna/src/base/config_dna.h:22:20: error: syntax error, unexpected IDENTIFIER, expecting ')'
NotifyCategoryDecl(dna, EXPCL_DNA, EXPTP_DNA);
                   ^~~
Error parsing file: 'DNAStorage.h'
Interrogating base

The following command return a non-zero value (1): /usr/bin/interrogate -D__inline -DCPPPARSER -DP3_INTERROGATE=1 -D__cplusplus -fnames -string -refcount -assert -S /usr/include/parser-inc -S /usr/include -I /usr/include -I/stuff/tt/libpandadna/src/base -I/stuff/tt/libpandadna/src/suit -I/stuff/tt/libpandadna/src/components -srcdir /stuff/tt/libpandadna/src/base -oc /stuff/tt/libpandadna/src/base_igate.cxx -od /stuff/tt/libpandadna/src/base.in -python-native -DCPPPARSER -D__STDC__=1 -D__cplusplus -D__inline -longlong __int64 -D_X86_ -DWIN32_VC -DWIN32 -module libpandadna -library base -Dvolatile= DNAStorage.h dnabase.h DNALoader.h config_dna.h
-- GCC Version: 8

-- libp3interrogatedb not found
-- libp3pandatoolbase not found
-- Configuring done
CMake Error at CMakeLists.txt:181 (add_library):
  Cannot find source file:

    src/base_igate.cxx

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx


CMake Error at CMakeLists.txt:181 (add_library):
  No SOURCES given to target: pandadna


-- Build files have been written to: /stuff/tt/libpandadna

Next, I opened up the makepanda script that is used to build Panda3D and inferred the following interrogate commands by recreating the commands executed from there:

interrogate -srcdir /stuff/tt/libpandadna/src/base -DCPPPARSER -D__STDC__=1 -D__cplusplus=201103L -D__attribute__\(x\)= -D_LP64 -oc /stuff/tt/libpandadna/src/base_igate.cxx -od /stuff/tt/libpandadna/src/base.in -fnames -string -refcount -assert -python-native -S/stuff/tt/panda3d/built/include/parser-inc -I/stuff/tt/libpandadna/src/base -S/stuff/tt/panda3d/built/tmp -S/stuff/tt/panda3d/built/include -S/usr/include/eigen3 -I../components -S../components -I../suit -S../suit -module libpandadna -library base DNAStorage.h dnabase.h DNALoader.h config_dna.h
interrogate -srcdir /stuff/tt/libpandadna/src/suit -oc /stuff/tt/libpandadna/src/suit_igate.cxx -od /stuff/tt/libpandadna/src/suit.in -DCPPPARSER -D__STDC__=1 -D__cplusplus=201103L -D__attribute__\(x\)= -D_LP64 -fnames -string -refcount -assert -python-native -S/stuff/tt/panda3d/built/include/parser-inc -I/stuff/tt/libpandadna/src/base -I/stuff/tt/libpandadna/src/suit -S/stuff/tt/panda3d/built/tmp -S/stuff/tt/panda3d/built/include -S/usr/include/eigen3 -I../components -module libpandadna -library suit -Dvolatile= DNASuitPoint.h DNASuitEdge.h SuitLeg.h SuitLegList.h DNASuitPath.h
interrogate -srcdir /stuff/tt/libpandadna/src/components -oc /stuff/tt/libpandadna/src/components_igate.cxx -od /stuff/tt/libpandadna/src/components.in -DCPPPARSER -D__STDC__=1 -D__cplusplus=201103L -D__attribute__\(x\)= -D_LP64 -fnames -string -refcount -assert -python-native -S/stuff/tt/panda3d/built/include/parser-inc -I/stuff/tt/libpandadna/src/base -I/stuff/tt/libpandadna/src/suit -I/stuff/tt/libpandadna/src/components -S/stuff/tt/panda3d/built/tmp -S/stuff/tt/panda3d/built/include -S/usr/include/eigen3 -I../components -module libpandadna -library suit -library components -Dvolatile= DNAInteractiveProp.h DNABattleCell.h DNAAnimProp.h DNANode.h DNAWall.h DNASign.h DNAStreet.h DNACornice.h DNAWindows.h DNAFlatDoor.h DNAFlatBuilding.h DNAVisGroup.h DNAAnimBuilding.h DNALandmarkBuilding.h DNAProp.h DNADoor.h DNAGroup.h DNASignGraphic.h DNASignBaseline.h

After executing each command in the appropriate folder src/base, src/suit and src/components, each completed successfully and created their respective output files:

$ ls
base            components            run_interrogate.py  suit.in
base_igate.cxx  components_igate.cxx  suit
base.in         components.in         suit_igate.cxx

Then I commented out the following 2 lines in run_interrogate.py in order to get the final interrogate_module command to run:

#for module in ('base', 'suit', 'components'):
#    interrogate(module)

After that, cmake . worked perfectly. Finally, I had to make a few other changes to the CMakeLists.txt to get it to see p3interrogatedb (I also had to get it to use Python 2, but that can be ignored):

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 93e7c02..b44f121 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,16 +1,19 @@
 cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
 project(libpandadna)
 
-find_package(PythonLibs)
-if (NOT PYTHONLIBS_FOUND)
-    message(FATAL_ERROR "Python libs not found.")
-endif()
+set(PythonLibs_FIND_VERSION 2.7)
+set(PYTHONVERSION 2)
 
 find_package(PythonInterp)
 if(NOT PYTHONINTERP_FOUND)
     message(FATAL_ERROR "Python interpreter not found.")
 endif()
 
+find_package(PythonLibs 2)
+if (NOT PYTHONLIBS_FOUND)
+    message(FATAL_ERROR "Python libs not found.")
+endif()
+
 if(PYTHON_VERSION_MAJOR EQUAL 2)
     set(PYTHON2_EXECUTABLE "${PYTHON_EXECUTABLE}")
 else()
@@ -24,6 +27,9 @@ endif()
 if (WIN32)
     SET(PANDA_DIR "C:\\Panda3D-1.10.0" CACHE STRING "Panda3D directory.")
 endif()
+if (UNIX)
+    SET(PANDA_DIR "/usr" CACHE STRING "Panda3D directory.")
+endif (UNIX)
 SET(BUILD_STATIC_LIB OFF CACHE BOOL "If true, will build a static lib")
 execute_process(COMMAND ${PYTHON2_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/run_interrogate.py" "${PANDA_DIR}")
 
@@ -103,9 +109,11 @@ include_directories(src/base)
 include_directories(src/suit)
 include_directories(src/components)
 include_directories(${PANDA_DIR}/include)
+include_directories(${PANDA_DIR}/include/panda3d)
 include_directories(${PYTHON_INCLUDE_DIR})
 include_directories(/usr/include/eigen3)
 link_directories(${PANDA_DIR}/lib)
+link_directories(/usr/lib/x86_64-linux-gnu/panda3d)
 
 set(LIBPFX "")
 if(WIN32)
@@ -138,8 +146,9 @@ if (NOT BUILD_STATIC_LIB)
 
     # Add p3interrogatedb, if it exists
     find_library(HAVE_P3INTERROGATEDB
-                 ${LIBPFX}p3interrogatedb
-                 HINTS ${PANDA_DIR}/lib)
+	         ${LIBPFX}p3interrogatedb
+	         PATHS /usr/lib/x86_64-linux-gnu/panda3d
+	         HINTS ${PANDA_DIR}/lib) 
                  
     if (HAVE_P3INTERROGATEDB)
         message(STATUS "libp3interrogatedb found")
@@ -151,6 +160,7 @@ if (NOT BUILD_STATIC_LIB)
     # Add p3pandatoolbase, if it exists
     find_library(HAVE_P3PANDATOOLBASE
                  ${LIBPFX}p3pandatoolbase
+		 PATHS /usr/lib/x86_64-linux-gnu/panda3d
                  HINTS ${PANDA_DIR}/lib)
 
     if (HAVE_P3PANDATOOLBASE)

Finally after all these actions, I was able to build libpandadna and successfully ran the tests.

I am sure many of these things should be generalized, which is why I am not going to simply submit a pull request at this point.

For example, the linking part of the panda3d problems can possibly be solved by actually using the find_library output. I am not much of a CMake buff so some of this stuff is not "my thing".

I just want to share my experience in case it will help others.

Maxwell175 avatar Jan 28 '19 00:01 Maxwell175

Really hope at some point official linux support is added at some point. Still broken to this day

DarthMDev avatar Dec 21 '21 05:12 DarthMDev

I got it to mostly work with changes I made to run_interrogate and cmakelists.txt But when running the make command I get a bunch of errors regarding different objects " not declared in this scope" This is with the latest panda3d from upstream merged into my custom panda3d The file in question is base_igate.cxx I am also running Ubuntu 21.10 with GCC version 11

here's examples of the errors: there's a lot more as well https://pastebin.com/LqrsD4ei

DarthMDev avatar Jan 11 '22 05:01 DarthMDev

An easy workaround for this issue is defining PANDA_DIR to the Panda3D built directory, which is similar in structure to the install structures of Windows and macOS. This will allow libpandadna to be built on Linux platforms.

So for example: cmake -DPANDA_DIR="/home/user/panda3d-src/built" .

Alternatively, you can add something like:

if (UNIX)
    SET(PANDA_DIR "/home/user/panda3d-src/built" CACHE STRING "Panda3D directory.")
endif (UNIX)

to your CMakeLists.txt file right below line 14.

It should not be considered a permanent solution however. (I think something permanent would be a rewrite to the interrogate process.)

ComradeNapCali avatar Jan 25 '22 02:01 ComradeNapCali