我试图编译Qt库的osgQt,因为它没有提供在预编译的软件包(至less不是Windows 7(x64)和MSVS 11 – x64)。 因此,我遵循这些指示:
注意:这个库是OSG源代码的一部分,但它不是预先构build的二进制文件的一部分。 有必要下载整个OSG项目来构buildosgQt库。
I.下载osg 3.0.1源码。
II。 用CMake生成Visual Studio解决scheme。
- 在cmake find模块中处理释放/debugging库的最佳实践
- CMake不在Windows上链接库
- PATH环境如何影响我使用msvcr90到msvcr80的正在运行的可执行文件?
- CMake:运行链接命令时出错:%1不是有效的Win32应用程序
- cmake找不到java,但是已经安装了
要做到这一点,你可以运行预备的batch file – 它创buildVS解决scheme没有任何osg依赖。 (希望足够) – 有必要在文件头中设置variables。 – 运行后,应该有与OpenSceneGraph.sln文件和src / osgQt目录的生成文件夹。
我无法使用这个batch file,因为它没有可用性和其他软件条件(MSVS 2008,Qt 4.7.4),因此必须使用我自己的CMake来构build它。
III。 在Visual Studio中打开OpenSceneGraph.sln
IV。 selectdebuggingwin32(或其他你想要的configuration)
V.selectosgQt项目
VI。 从菜单中selectBuild,Build osgQt
结果:osgQt的lib和dll文件…复制他们旁边预build的osg库。
但是我在第二步遇到麻烦了:
当使用CMake 2.8.11.2时,我收到以下错误:
CMake Error at D:/Programme/QT/5.1.0/msvc2012_64_opengl/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:14 (message): Failed to find "glu32" in "". Call Stack (most recent call first): D:/Programme/QT/5.1.0/msvc2012_64_opengl/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:48 (_qt5gui_find_extra_libs) D:/Programme/QT/5.1.0/msvc2012_64_opengl/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:127 (include) D:/Programme/QT/5.1.0/msvc2012_64_opengl/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:83 (find_package) CMakeLists.txt:570 (FIND_PACKAGE)
因为许多其他人在遵循这个指令之前就有这个问题( http://qt-project.org/forums/viewthread/30006/ ):
所以它适用于我(至less是CMakeconfiguration,没有尝试实际使用它在编译尚未)。 重现步骤:
- 我使用了Qt 5.1的预编译版本(使用VS2012的OpenGL x64)。 使用它应该对你来说很好,因为Qt 5.1应该支持OpenGL3.2 + profiles,我不认为你需要使用Glew,只要看看http://qt-project.org/doc/qt – > 5.1 / qtgui / qabstractopenglfunctions.html层次结构
- 安装了Win SDK 8.0。 但我认为7.0可以罚款。
- (CMAKE_PREFIX_PATH“C:\ Program Files(x86)\ Windows Kits \ 8.0 \ Lib \ win8 \ um \ x64”)行添加到我的cmake文件。 这就是glu32.lib和类似文件的位置。
- 运行cmake-gui configure&generate,使用VS 11 win64作为生成器。
它尝试了两个(不是在同一个build设过程中):
set(CMAKE_PREFIX_PATH “D:\Programme\Microsoft SDKs\Windows\v7.0\Lib\x64”) set(CMAKE_PREFIX_PATH “C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64”)
我得到上面发布的错误和以下警告:
CMake Warning (dev) at CMakeLists.txt:4 (set): Syntax error in cmake code at D:/OpenSceneGraph-3.2.0/OpenSceneGraph/CMakeLists.txt:4 when parsing string "C:\Program Invalid escape sequence \P Policy CMP0010 is not set: Bad variable reference syntax is an error. Run "cmake --help-policy CMP0010" for policy details. Use the cmake_policy command to set the policy and suppress this warning. This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at CMakeLists.txt:4 (set): Syntax error in cmake code at D:/OpenSceneGraph-3.2.0/OpenSceneGraph/CMakeLists.txt:4 when parsing string \Windows Invalid escape sequence \W Policy CMP0010 is not set: Bad variable reference syntax is an error. Run "cmake --help-policy CMP0010" for policy details. Use the cmake_policy command to set the policy and suppress this warning. This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at CMakeLists.txt:4 (set): Syntax error in cmake code at D:/OpenSceneGraph-3.2.0/OpenSceneGraph/CMakeLists.txt:4 when parsing string Kits\8.0\Lib\win8\um\x64” Invalid escape sequence \8 Policy CMP0010 is not set: Bad variable reference syntax is an error. Run "cmake --help-policy CMP0010" for policy details. Use the cmake_policy command to set the policy and suppress this warning. This warning is for project developers. Use -Wno-dev to suppress it.
我不认为这些警告与大多数其他警告一样无害,并且显示CMake根本找不到正确的目录。
有没有人有一个想法如何解决这个问题,或者如果不是一个预编译osgQt版本的Qt 5.1 osg 3.2.0和MSVS2012在Windows7(x64)?
编辑1:
Qt5GuiConfigExtras.cmake的代码
macro(_qt5gui_find_extra_libs Name Libs LibDir IncDirs) set(Qt5Gui_${Name}_LIBRARIES) set(Qt5Gui_${Name}_INCLUDE_DIRS ${IncDirs}) foreach(_lib ${Libs}) string(REGEX REPLACE [^_A-Za-z0-9] _ _cmake_lib_name ${_lib}) if (NOT TARGET Qt5::Gui_${_cmake_lib_name}) find_library(Qt5Gui_${_cmake_lib_name}_LIBRARY ${_lib} ) if (NOT Qt5Gui_${_cmake_lib_name}_LIBRARY) if ("${ARGN}" STREQUAL "OPTIONAL") break() else() message(FATAL_ERROR "Failed to find \"${_lib}\" in \"${LibDir}\".") endif() endif() add_library(Qt5::Gui_${_cmake_lib_name} SHARED IMPORTED) set_property(TARGET Qt5::Gui_${_cmake_lib_name} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${IncDirs}) set_property(TARGET Qt5::Gui_${_cmake_lib_name} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) _qt5_Gui_check_file_exists("${Qt5Gui_${_cmake_lib_name}_LIBRARY}") set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_LOCATION_RELEASE "${Qt5Gui_${_cmake_lib_name}_LIBRARY}") set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_IMPLIB_RELEASE "${Qt5Gui_${_cmake_lib_name}_LIBRARY}") unset(Qt5Gui_${_cmake_lib_name}_LIBRARY CACHE) find_library(Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG ${_lib}d PATHS "${LibDir}" NO_DEFAULT_PATH) if (Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG) set_property(TARGET Qt5::Gui_${_cmake_lib_name} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) _qt5_Gui_check_file_exists("${Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG}") set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_LOCATION_DEBUG "${Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG}") set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_IMPLIB_DEBUG "${Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG}") endif() unset(Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG CACHE) endif() list(APPEND Qt5Gui_${Name}_LIBRARIES Qt5::Gui_${_cmake_lib_name}) endforeach() if (NOT CMAKE_CROSSCOMPILING) foreach(_dir ${IncDirs}) _qt5_Gui_check_file_exists(${_dir}) endforeach() endif() endmacro() _qt5gui_find_extra_libs(OPENGL "GlU32;opengl32;gdi32;user32" "" "") set(Qt5Gui_OPENGL_IMPLEMENTATION GL) get_target_property(_configs Qt5::Gui IMPORTED_CONFIGURATIONS) foreach(_config ${_configs}) set_property(TARGET Qt5::Gui APPEND PROPERTY IMPORTED_LINK_DEPENDENT_LIBRARIES_${_config} ${Qt5Gui_EGL_LIBRARIES} ${Qt5Gui_OPENGL_LIBRARIES} ) endforeach() unset(_configs)
提前致谢。
在CMake中, \
是转义字符。 要添加一个实际的\
到一个字符串,你需要转义它,即使它\\
。
所以你需要做的是:
set(CMAKE_PREFIX_PATH "D:\\Programme\\Microsoft SDKs\\Windows\\v7.0\\Lib\\x64")
或者,您可以将路径分隔符更改为/
,即使对于Windows:
set(CMAKE_PREFIX_PATH "D:/Programme/Microsoft SDKs/Windows/v7.0/Lib/x64")
同样的问题,CMAKE_PREFIX_PATH不纠正错误,但以下工作:
set(CMAKE_MODULE_PATH "C:/Program Files/Microsoft SDKs/Windows/v7.1/Lib")