- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在编译 OpenGL Superbible, 6th ed 提供的示例代码时遇到问题.我正在使用 Ubuntu 19.04 和 CMake 3.13.4。我拥有所有必要的依赖项。 CMake 执行没有问题(“cmake .”),但是当我输入 make 命令时它失败了。
我的印象是它与 GLFW 有关,但我不知道如何更改 CMake 以使其正常工作。
这是示例代码的链接。 https://github.com/openglsuperbible/sb6code
我已经在 CMakeLists.txt 文件的第 13 行修复了这个问题,但它仍然无法编译。
来自:
if(WIN32)
set(COMMON_LIBS sb6 optimized GLFW_r32 debug GLFW_d32)
elif (UNIX)
set(COMMON_LIBS sb6 glfw ${GLFW_LIBRARIES} GL rt dl)
else()
set(COMMON_LIBS sb6)
收件人:
if(WIN32)
set(COMMON_LIBS sb6 optimized GLFW_r32 debug GLFW_d32)
else()
set(COMMON_LIBS sb6 glfw ${GLFW_LIBRARIES} GL rt dl)
我已经尝试将 find_package(glfw3 3.2 REQUIRED) 添加到文件的开头,但仍然没有成功。
这是我当前的 CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
project (SuperBible6)
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_BINARY_DIR}/bin)
if(WIN32)
set(COMMON_LIBS sb6 optimized GLFW_r32 debug GLFW_d32)
else()
set(COMMON_LIBS sb6 glfw ${GLFW_LIBRARIES} GL rt dl)
endif()
IF(APPLE)
INCLUDE_DIRECTORIES(/System/Library/Frameworks)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
FIND_LIBRARY(OpenGL_LIBRARY OpenGL)
FIND_LIBRARY(IOKit_LIBRARY IOKit)
MARK_AS_ADVANCED(COCOA_LIBRARY OpenGL_LIBRARY)
SET(EXTRA_LIBS ${COCOA_LIBRARY} ${IOKit_LIBRARY} ${OpenGL_LIBRARY})
SET(EXTRA_LIBS ${EXTRA_LIBS} /usr/local/lib/libglfw.a)
ENDIF(APPLE)
set(COMMON_LIBS ${COMMON_LIBS} ${EXTRA_LIBS})
add_library(sb6
src/sb6/sb6.cpp
src/sb6/sb6ktx.cpp
src/sb6/sb6object.cpp
src/sb6/sb6shader.cpp
src/sb6/gl3w.c
)
set(RUN_DIR ${PROJECT_SOURCE_DIR}/bin)
set(EXAMPLES
alienrain
basicfbo
blendmatrix
blinnphong
bumpmapping
clipdistance
csflocking
cubemapenv
cubicbezier
deferredshading
depthclamp
dispmap
dof
envmapsphere
equirectangular
fragcolorfrompos
fragmentlist
grass
gsculling
gslayered
gsquads
gstessellate
hdrbloom
hdrexposure
hdrtonemap
indexedcube
instancedattribs
julia
ktxview
linesmooth
movingtri
msaanative
multidrawindirect
multimaterial
multiscissor
multiviewport
noise
noperspective
normalviewer
objectexploder
perf-readpixels
perpixelgloss
phonglighting
polygonsmooth
prefixsum
prefixsum2d
programinfo
raytracer
rimlight
sampleshading
# sb6mrender
shadowmapping
shapedpoints
simpleclear
simpletexcoords
simpletexture
singlepoint
singletri
sparsetexture
spinnycube
springmass
ssao
starfield
stereo
subroutines
tessellatedcube
tessellatedgstri
tessellatedtri
tessmodes
tesssubdivmodes
toonshading
tunnel
wrapmodes
)
if (WIN32)
set(EXAMPLES ${EXAMPLES} win32raw)
endif()
#if(UNIX)
# add_executable(xraw src/xraw/xraw.c)
# target_link_libraries(xraw GL X11 m)
#endif(UNIX)
foreach(EXAMPLE ${EXAMPLES})
add_executable(${EXAMPLE} WIN32 src/${EXAMPLE}/${EXAMPLE}.cpp)
target_link_libraries(${EXAMPLE} ${COMMON_LIBS})
if(MSVC)
configure_file(${PROJECT_SOURCE_DIR}/build/vs2010/VisualStudioUserFile.vcproj.user.in ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.vcproj.user @ONLY)
configure_file(${PROJECT_SOURCE_DIR}/build/vs2010/VisualStudioUserFile.vcxproj.user.in ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.vcxproj.user @ONLY)
endif(MSVC)
endforeach(EXAMPLE)
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LINUX")
ENDIF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
include_directories( include )
include_directories( extern/glfw-2.7.6/include )
ADD_CUSTOM_TARGET(debug ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE:STRING=Debug ${PROJECT_SOURCE_DIR})
ADD_CUSTOM_TARGET(release ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE:STRING=Release ${PROJECT_SOURCE_DIR})
这是我遇到的错误:
myron@myron-UX430UA:~/Desktop/sb6/sb6code-master$ make V=1
Scanning dependencies of target sb6
[ 1%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6.cpp.o
[ 2%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6ktx.cpp.o
[ 2%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6object.cpp.o
[ 3%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6shader.cpp.o
[ 4%] Building C object CMakeFiles/sb6.dir/src/sb6/gl3w.c.o
[ 4%] Linking CXX static library lib/libsb6.a
[ 4%] Built target sb6
Scanning dependencies of target wrapmodes
[ 5%] Building CXX object CMakeFiles/wrapmodes.dir/src/wrapmodes/wrapmodes.cpp.o
[ 6%] Linking CXX executable bin/wrapmodes
/usr/bin/ld: CMakeFiles/wrapmodes.dir/src/wrapmodes/wrapmodes.cpp.o: in function `sb6::application::run(sb6::application*)':
wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x8b): undefined reference to `glfwOpenWindowHint'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xa1): undefined reference to `glfwOpenWindowHint'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xb0): undefined reference to `glfwOpenWindowHint'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xbf): undefined reference to `glfwOpenWindowHint'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xd5): undefined reference to `glfwOpenWindowHint'
/usr/bin/ld: CMakeFiles/wrapmodes.dir/src/wrapmodes/wrapmodes.cpp.o:wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xf5): more undefined references to `glfwOpenWindowHint' follow
/usr/bin/ld: CMakeFiles/wrapmodes.dir/src/wrapmodes/wrapmodes.cpp.o: in function `sb6::application::run(sb6::application*)':
wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x133): undefined reference to `glfwGetDesktopMode'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x18b): undefined reference to `glfwOpenWindow'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x1e9): undefined reference to `glfwOpenWindow'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x25b): undefined reference to `glfwSetMousePosCallback'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x267): undefined reference to `glfwSetMouseWheelCallback'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x280): undefined reference to `glfwEnable'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x289): undefined reference to `glfwDisable'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x29a): undefined reference to `glfwGetWindowParam'
/usr/bin/ld: wrapmodes.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x3bc): undefined reference to `glfwGetWindowParam'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/wrapmodes.dir/build.make:85: bin/wrapmodes] Error 1
make[1]: *** [CMakeFiles/Makefile2:137: CMakeFiles/wrapmodes.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
编辑:虽然我看不到任何附加信息,但运行“make V=1”。
最佳答案
我已经更改了代码和 cmake 文件以使用 GLFW3。现在项目编译并运行。我在这里上传到github:https://github.com/mlioz/sb6code_fixed
关于c++ - 如何修复 OpenGL Superbible 第 6 版书籍提供的 CMake 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55634364/
运行 pip install cmake 时出现上述错误在 alpine linux (WSL) 上。 完整错误: /home/user# pip install cmake Collecting c
我的项目依赖 mariadb-connector-c我正在尝试使用 cmake 自动化下载、构建和链接过程。 我目前将项目下载到一个目录中,然后尝试执行生成忍者文件并运行它们,但我根本无法运行 cma
我正在尝试像这样在 cmake 中执行 execute_process execute_process(COMMAND ${CMAKE_COMMAND} -P myScript.cmake 这仅在文件
我想知道如果我没有给它任何变量告诉它在哪里找到它,cmake 如何找到我的 llvm cmake 配置。 我是 LLVM 新手。我正在构建一个 Hello World LLVM pass。我在 Ubu
我正在开发一个使用 CMake 的项目。顶CMakeLists.txt文件包含以下行: cmake_minimum_required(VERSION 3.7.2) # Kittens will die
我正在使用 Meego 1.2 工具链使用 cmake 运行构建(长话短说)。这个特定的工具链需要使用 --sysroot 选项来查找它需要的任何库。 set (CMAKE_CXX_FLAGS "-f
我们有一些源代码处理工具,可以从多个“片段”生成原始汇编文件等内容。 当使用 make 中的这些工具时,我们可以通过让源处理工具发出“依赖文件”来确保最新的构建,就像 gcc 一样-MD 标志。 例如
如何在 MSYS2 中安装和配置“cmake”?我尝试安装以下 MSYS 包 我在运行任何 cmake 命令时都收到以下错误 '''CMakeLists.txt:5 (cmake_minimum_re
有没有办法在 CMake 中得到一个变量列表?具体来说,我想要做的是调用一个现有函数,该函数接受多个变量并检查它们的计算结果是否为 true。 在某些情况下,其中一些变量将是空列表(计算结果为 fal
我有两组测试(功能测试和单元测试),我希望能够指定通过 cmake 运行哪一组。 一组测试是我想通过“make test”运行的单元测试。 另一组测试是我想通过“制作功能测试”来运行的功能测试。 目前
我的目标是查看有关调用 g++ 的详细信息由 cmake 直接调用从命令行。我不关心 make 的输出就这个问题而言。 根据official FAQ和 the accepted answer on a
我有一个生成库的CMake项目。我已经编写了一个CMake脚本FindXXX.cmake来帮助我的图书馆的用户。这样,他们可以使用find_package(XXX)并获取所需的变量。到现在为止还挺好。
当我看到带有命名空间的 CMake 库时,它们总是在表单中Parent::Component . 如果我有一个足够大的库,那么该库的子部分可能包含组件。我想知道是否可以/适合做 ParentProje
CMake 变量和属性似乎完成了非常相似的事情,我一直无法理解它们之间的区别。 它们每个都有自己的文档部分,但两者都会影响构建系统,两者都是“预先存在的”,并且两者都可以基于其他 CMake 命令动态
我有一个包含多个子目录的 CMake 项目,例如: dir1 subdir11 subdir12 dir2 subdir21 subdir22 根 CMakeLists
如果您想将静态库链接到共享库或可执行文件,同时保持所有符号可见(例如,您可以稍后打开它以找到它们),在 Linux/BSD 上执行此操作的一种非可移植方式是使用标志-Wl,--whole-archiv
CMake 自动创建一个 FooTarget.cmake文件例如添加 install(EXPORT FooTargets FILE FooTargets.cmake NAMESPACE Foo
在CMake中,ELSE和ENDIF控制流函数将表达式作为参数。根据文档,这些是optional。那么这些目的是什么?仅仅是为了维护目的而使原始IF表达式更清晰,还是提供某些功能? 最佳答案 正如您所
我是 cmake 的新手,我发现它非常令人沮丧。我试图在构建运行时评估的文件路径中使用通配符,而不是在生成构建时。 我创建了一个构建,它使用 SWIG 为某些 C++ 代码生成 Java 包装器。我可
我可能在谷歌上搜索错误,但我无法找到 .cmake 文件的用途。 我刚刚偶然发现了一个我必须使用的项目的 CMake 工具,我很难理解它是如何工作的。我明白在包含 CMakeLists.txt 的目录
我是一名优秀的程序员,十分优秀!