我正在使用CentOS 7,并且一直在尝试纠正构建说明中的问题,尤其是在尝试查找glfw库时。按照 HOWTOBUILD.txt 文件(可从SB7 git repo获得)中的说明进行操作,在运行make
命令时,我经常收到错误消息:
[sweet_ass_user_name@bitchin_camaro build]$ make
Scanning dependencies of target sb7
[ 1%] Building CXX object CMakeFiles/sb7.dir/src/sb7/sb7.cpp.o
[ 1%] Building CXX object CMakeFiles/sb7.dir/src/sb7/sb7color.cpp.o
[ 2%] Building CXX object CMakeFiles/sb7.dir/src/sb7/sb7ktx.cpp.o
[ 2%] Building CXX object CMakeFiles/sb7.dir/src/sb7/sb7object.cpp.o
/usr/local/opengl/SDK_Sandbox/sb7code/src/sb7/sb7object.cpp: In member function ‘void sb7::object::render_sub_object(unsigned int, unsigned int, unsigned int)’:
/usr/local/opengl/SDK_Sandbox/sb7code/src/sb7/sb7object.cpp:212:77: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
(void*)sub_object[object_index].first,
^
[ 3%] Building CXX object CMakeFiles/sb7.dir/src/sb7/sb7shader.cpp.o
[ 4%] Building CXX object CMakeFiles/sb7.dir/src/sb7/sb7textoverlay.cpp.o
[ 4%] Building C object CMakeFiles/sb7.dir/src/sb7/gl3w.c.o
[ 5%] Linking CXX static library lib/libsb7.a
[ 5%] Built target sb7
Scanning dependencies of target wrapmodes
[ 6%] Building CXX object CMakeFiles/wrapmodes.dir/src/wrapmodes/wrapmodes.cpp.o
[ 7%] Linking CXX executable ../bin/wrapmodes
/usr/bin/ld: cannot find -lglfw3
collect2: error: ld returned 1 exit status
make[2]: *** [../bin/wrapmodes] Error 1
make[1]: *** [CMakeFiles/wrapmodes.dir/all] Error 2
make: *** [all] Error 2
为了使事情更加混乱,我已经安装了以下软件包:
使用rpm -qa | grep glfw
检查安装的glfw软件包时,系统返回:
glfw-3.2.1-2.el7.x86_64
glfw-devel-3.2.1-2.el7.x86_64
很明显,已安装的glfw库是glfw
库的版本3。
但是,为什么系统无法识别它?
OS: centos-release-7-5.1804.4.el7.centos.x86_64
OpenGL: 4.6.0 NVIDIA 396.37
GPU: GV100
Optix: 5.1
CUDA: 9.2
CMake: cmake3, cmake3-gui
OpenGL libraries:
mesa-libGLU-9.0.0-4.el7.x86_64
mesa-libGLES-17.2.3-8.20171019.el7.x86_64
mesa-libGLU-devel-9.0.0-4.el7.x86_64
mesa-libwayland-egl-17.2.3-8.20171019.el7.x86_64
mesa-libGL-17.2.3-8.20171019.el7.x86_64
mesa-filesystem-17.2.3-8.20171019.el7.x86_64
mesa-libEGL-17.2.3-8.20171019.el7.x86_64
mesa-dri-drivers-17.2.3-8.20171019.el7.x86_64
mesa-libglapi-17.2.3-8.20171019.el7.x86_64
mesa-libxatracker-17.2.3-8.20171019.el7.x86_64
mesa-libGL-devel-17.2.3-8.20171019.el7.x86_64
mesa-libgbm-17.2.3-8.20171019.el7.x86_64
Graphics Misc Libs:
libX11-common-1.6.5-1.el7.noarch
libX11-1.6.5-1.el7.x86_64
libX11-devel-1.6.5-1.el7.x86_64
libXinerama-1.1.3-2.1.el7.x86_64
libXinerama-devel-1.1.3-2.1.el7.x86_64
glfw-3.2.1-2.el7.x86_64
glfw-devel-3.2.1-2.el7.x86_64
答案 0 :(得分:0)
事实证明,由于有关 glfw软件包和 glfw版本之间差异的命名问题令人困惑,答案只是修改CMakeLists.txt
文件(此处链接:SB7 CMakeLists.txt)
第28行需要删除一个字符。将 glfw3 更改为 glfw 。
也不要从上面的行中重命名 glfw3 名称。我只能假定这是指glfw3的版本,而不是软件包的名称。
现在,代码已构建,并且所有构建都可以正常运行。
对于centos7系统,并且为了使用CUDA的当前构建规则,您需要运行cmake3 ..
(而不是cmake
)
cmake_minimum_required (VERSION 2.6)
project (superbible7)
LINK_DIRECTORIES( ${CMAKE_SOURCE_DIR}/lib )
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
# Second, for multi-config builds (e.g. msvc)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_SOURCE_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_SOURCE_DIR}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_SOURCE_DIR}/lib )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
find_package(OpenGL)
set (CMAKE_DEBUG_POSTFIX "_d")
if(WIN32)
set(COMMON_LIBS sb7 optimized glfw3 debug glfw3_d ${GLFW_LIBRARIES} ${OPENGL_LIBRARIES})
elseif (UNIX)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLFW REQUIRED glfw3)
set(COMMON_LIBS sb7 glfw X11 Xrandr Xinerama Xi Xxf86vm Xcursor GL rt dl)
else()
set(COMMON_LIBS sb7)
endif()