我正在尝试编译 Qt-Library osgQt,因为预编译包中没有提供它(至少对于 Windows 7(x64)和 MSVS 11 - x64 没有)。因此,我遵循以下说明:
注意:这个库是 OSG 源代码的一部分,但它不是预编译二进制文件的一部分。需要下载整个 OSG 项目来构建 osgQt 库。
一、下载osg 3.0.1源码。
二、使用 CMake 生成 Visual Studio 解决方案。
为此,您可以运行准备好的批处理文件。- 它创建没有任何 osg 依赖的 VS 解决方案。(希望足够) - 有必要在文件头中设置变量。- 运行后,应该有包含 OpenSceneGraph.sln 文件的 build 文件夹和 src/osgQt 目录。
我不能使用这个批处理文件,因为它不可用和其他软件条件(MSVS 2008,Qt 4.7.4),因此必须自己用 CMake 构建它。
三、在 Visual Studio 中打开 OpenSceneGraph.sln
四。选择调试win32(或你想要的其他配置)
五、选择osgQt项目
六、从菜单中选择构建,构建 osgQt
结果:osgQt lib 和 dll 文件...将它们复制到预构建的 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/)之前,许多其他人都遇到了这个问题:
所以它对我有用(至少 CMake 配置,还没有尝试在编译中实际使用它)。重现步骤:
- 我使用了 Qt 5.1 的预编译版本(用于 VS2012 的带有 OpenGL x64 的版本)。使用它对你来说应该没问题,因为 Qt 5.1 应该支持开箱即用的 OpenGL3.2+ 配置文件,我认为你不再需要使用 Glew,只需查看http://qt-project.org/doc/qt - >5.1/qtgui/qabstractopenglfunctions.html 层次结构
- 已安装 Win SDK 8.0。但我认为7.0可能会很好。
- 在我的 cmake 文件中添加了 set (CMAKE_PREFIX_PATH “C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64”) 行。这就是 glu32.lib 和类似文件所在的位置。
- 运行 cmake-gui configure&generate,使用 VS 11 win64 作为生成器。
它尝试了两者(不是在同一个构建过程中):
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 根本无法找到正确的目录。
有没有人知道如何解决这个问题,或者如果不是 Windows7(x64) 上带有 osg 3.2.0 和 MSVS2012 的 Qt 5.1 的 osgQt 预编译版本?
编辑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)
提前致谢。