在没有 GUI 的情况下构建 SUMO

Build SUMO without GUI

是否可以在没有 GUI 的情况下构建 SUMO,即没有 Fox 工具包 (libfox)?

我的 Docker 图片真的不需要它。我从 SUMO 的构建说明 (https://sumo.dlr.de/docs/Installing/Linux_Build.html) 知道可以通过为 cmake 定义 -D FOX_CONFIG= 来实现。然而,当构建版本 1.2.0(可能更高)时,构建在 make 上失败,因为它仍然试图寻找 fx.h.

编辑(添加构建日志):

sumo-1.2.0/build/cmake-build 中,以下是输出:

  1. cmake ../..
-- Setting build type to 'Release' as none was specified.
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is Clang 10.0.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
-- CMAKE_BINARY_DIR: /home/sumo-1.2.0/build/cmake-build
-- CMAKE_SOURCE_DIR: /home/sumo-1.2.0
--
-- Platform:
--     Host: Linux-4.19.76-linuxkit x86_64
--     Target: Linux-4.19.76-linuxkit x86_64
--     CMake: 3.16.3
--     CMake generator: Unix Makefiles
--     CMake build tool: /usr/bin/make
--     Compiler: Clang 10.0.0
--
-- Found PythonInterp: /usr/bin/python (found version "2.7.18")
-- Found Python: /usr/bin/python
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
-- Found XercesC: /usr/lib/x86_64-linux-gnu/libxerces-c.so (found version "3.2.2")
-- Found Proj: /usr/lib/x86_64-linux-gnu/libproj.so
-- Could NOT find Fox. GUI and threading will not be available. If it is installed, try to set the environment variables FOX_INCLUDE_DIR and FOX_LIBRARY.
-- Found Fox:
-- Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)
-- Found GDAL: /usr/lib/libgdal.so (found version "3.0.4")
-- Could NOT find suitable FFmpeg.
-- Could NOT find osgGA (missing: OSGGA_LIBRARY OSGGA_INCLUDE_DIR)
-- Could NOT find osgViewer (missing: OSGVIEWER_LIBRARY OSGVIEWER_INCLUDE_DIR)
-- Could NOT find osgUtil (missing: OSGUTIL_LIBRARY OSGUTIL_INCLUDE_DIR)
-- Could NOT find osgDB (missing: OSGDB_LIBRARY OSGDB_INCLUDE_DIR)
-- Could NOT find osgText (missing: OSGTEXT_LIBRARY OSGTEXT_INCLUDE_DIR)
-- Could NOT find osg (missing: OSG_LIBRARY OSG_INCLUDE_DIR)
-- Could NOT find OpenThreads (missing: OPENTHREADS_LIBRARY OPENTHREADS_INCLUDE_DIR)
-- Could NOT find OpenSceneGraph (missing: OPENSCENEGRAPH_LIBRARIES OPENSCENEGRAPH_INCLUDE_DIR) (Required is at least version "3.4.0")
-- Could NOT find GL2PS (missing: GL2PS_LIBRARY GL2PS_INCLUDE_DIR)
-- Found SWIG: /usr/bin/swig4.0 (found suitable version "4.0.1", minimum required is "3.0")
-- Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
-- Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
CMake Warning at src/libsumo/CMakeLists.txt:73 (message):
  ENABLE_JAVA_BINDINGS is set but Java or JNI was not found.


-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
CMake Warning at src/libsumo/CMakeLists.txt:116 (message):
  ENABLE_PYTHON_BINDINGS is set but python libraries were not found.


-- Could NOT find Git (missing: GIT_EXECUTABLE)
-- Enabled features: Linux-4.19.76-linuxkit x86_64 Clang 10.0.0 Release Proj GDAL SWIG
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sumo-1.2.0/build/cmake-build
r
  1. cmake -D CHECK_OPTIONAL_LIBS=OFF -D FOX_CONFIG= ../..
-- Setting build type to 'Release' as none was specified.
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is Clang 10.0.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
-- CMAKE_BINARY_DIR: /home/sumo-1.2.0/build/cmake-build
-- CMAKE_SOURCE_DIR: /home/sumo-1.2.0
--
-- Platform:
--     Host: Linux-4.19.76-linuxkit x86_64
--     Target: Linux-4.19.76-linuxkit x86_64
--     CMake: 3.16.3
--     CMake generator: Unix Makefiles
--     CMake build tool: /usr/bin/make
--     Compiler: Clang 10.0.0
--
-- Found PythonInterp: /usr/bin/python (found version "2.7.18")
-- Found Python: /usr/bin/python
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
-- Found XercesC: /usr/lib/x86_64-linux-gnu/libxerces-c.so (found version "3.2.2")
-- Found Proj: /usr/lib/x86_64-linux-gnu/libproj.so
-- Could NOT find Fox. GUI and threading will not be available. If it is installed, try to set the environment variables FOX_INCLUDE_DIR and FOX_LIBRARY.
-- Found Fox:
-- Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)
-- Could NOT find Git (missing: GIT_EXECUTABLE)
-- Enabled features: Linux-4.19.76-linuxkit x86_64 Clang 10.0.0 Release Proj
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sumo-1.2.0/build/cmake-build
  1. cmake -D FOX_CONFIG= ../..
-- Setting build type to 'Release' as none was specified.
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is Clang 10.0.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
-- CMAKE_BINARY_DIR: /home/sumo-1.2.0/build/cmake-build
-- CMAKE_SOURCE_DIR: /home/sumo-1.2.0
--
-- Platform:
--     Host: Linux-4.19.76-linuxkit x86_64
--     Target: Linux-4.19.76-linuxkit x86_64
--     CMake: 3.16.3
--     CMake generator: Unix Makefiles
--     CMake build tool: /usr/bin/make
--     Compiler: Clang 10.0.0
--
-- Found PythonInterp: /usr/bin/python (found version "2.7.18")
-- Found Python: /usr/bin/python
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
-- Found XercesC: /usr/lib/x86_64-linux-gnu/libxerces-c.so (found version "3.2.2")
-- Found Proj: /usr/lib/x86_64-linux-gnu/libproj.so
-- Could NOT find Fox. GUI and threading will not be available. If it is installed, try to set the environment variables FOX_INCLUDE_DIR and FOX_LIBRARY.
-- Found Fox:
-- Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)
-- Found GDAL: /usr/lib/libgdal.so (found version "3.0.4")
-- Could NOT find suitable FFmpeg.
-- Could NOT find osgGA (missing: OSGGA_LIBRARY OSGGA_INCLUDE_DIR)
-- Could NOT find osgViewer (missing: OSGVIEWER_LIBRARY OSGVIEWER_INCLUDE_DIR)
-- Could NOT find osgUtil (missing: OSGUTIL_LIBRARY OSGUTIL_INCLUDE_DIR)
-- Could NOT find osgDB (missing: OSGDB_LIBRARY OSGDB_INCLUDE_DIR)
-- Could NOT find osgText (missing: OSGTEXT_LIBRARY OSGTEXT_INCLUDE_DIR)
-- Could NOT find osg (missing: OSG_LIBRARY OSG_INCLUDE_DIR)
-- Could NOT find OpenThreads (missing: OPENTHREADS_LIBRARY OPENTHREADS_INCLUDE_DIR)
-- Could NOT find OpenSceneGraph (missing: OPENSCENEGRAPH_LIBRARIES OPENSCENEGRAPH_INCLUDE_DIR) (Required is at least version "3.4.0")
-- Could NOT find GL2PS (missing: GL2PS_LIBRARY GL2PS_INCLUDE_DIR)
-- Found SWIG: /usr/bin/swig4.0 (found suitable version "4.0.1", minimum required is "3.0")
-- Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
-- Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
CMake Warning at src/libsumo/CMakeLists.txt:73 (message):
  ENABLE_JAVA_BINDINGS is set but Java or JNI was not found.


-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
CMake Warning at src/libsumo/CMakeLists.txt:116 (message):
  ENABLE_PYTHON_BINDINGS is set but python libraries were not found.


-- Could NOT find Git (missing: GIT_EXECUTABLE)
-- Enabled features: Linux-4.19.76-linuxkit x86_64 Clang 10.0.0 Release Proj GDAL SWIG
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sumo-1.2.0/build/cmake-build
r

make 的相同输出如下:

...
[ 12%] Linking CXX static library libutils_options.a
[ 12%] Built target utils_options
[ 12%] Building CXX object src/utils/shapes/CMakeFiles/utils_shapes.dir/Shape.cpp.o
[ 12%] Building CXX object src/utils/shapes/CMakeFiles/utils_shapes.dir/SUMOPolygon.cpp.o
[ 12%] Building CXX object src/utils/shapes/CMakeFiles/utils_shapes.dir/PolygonDynamics.cpp.o
In file included from /home/sumo-1.2.0/src/utils/shapes/PolygonDynamics.cpp:24:
/home/sumo-1.2.0/src/foreign/rtree/SUMORTree.h:26:10: fatal error: 'fx.h' file not found
#include <fx.h>
         ^~~~~~
1 error generated.
make[2]: *** [src/utils/shapes/CMakeFiles/utils_shapes.dir/build.make:89: src/utils/shapes/CMakeFiles/utils_shapes.dir/PolygonDynamics.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2973: src/utils/shapes/CMakeFiles/utils_shapes.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

以下是

的构建日志
...
[ 12%] Linking CXX static library libutils_options.a
[ 12%] Built target utils_options
Scanning dependencies of target utils_shapes
[ 12%] Building CXX object src/utils/shapes/CMakeFiles/utils_shapes.dir/Shape.cpp.o
[ 12%] Building CXX object src/utils/shapes/CMakeFiles/utils_shapes.dir/SUMOPolygon.cpp.o
[ 12%] Building CXX object src/utils/shapes/CMakeFiles/utils_shapes.dir/PolygonDynamics.cpp.o
In file included from /home/sumo-1.2.0/src/utils/shapes/PolygonDynamics.cpp:24:
/home/sumo-1.2.0/src/foreign/rtree/SUMORTree.h:26:10: fatal error: 'fx.h' file not found
#include <fx.h>
         ^~~~~~
1 error generated.
make[2]: *** [src/utils/shapes/CMakeFiles/utils_shapes.dir/build.make:89: src/utils/shapes/CMakeFiles/utils_shapes.dir/PolygonDynamics.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2973: src/utils/shapes/CMakeFiles/utils_shapes.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

最简单的解决方案可能是安装 fox16-devel,即使您不需要 GUI。一个快速修复可能是从 src/utils/shapes/PolygonDynamics.cpp 中删除 SUMORTree.h 的包含,请参阅 https://github.com/eclipse/sumo/commit/09c5530b38085c6feb0283aba7b4113a74c9031a