문제

I'm trying to compile the Qt-Library osgQt, because it's not provided in the precompiled packages (at least not for Windows 7(x64) and MSVS 11 - x64). Therefore I'm following these instructions:

Note: This library is part of OSG sources, but it is not part of prebuilt binaries. It is necessary to download whole OSG project to build osgQt library.

I. Download osg 3.0.1 sources.

II. Generate Visual Studio solution with CMake.

To do this you can run prepared batch file. - It creates VS solution without any osg dependencies. (hopefully sufficient) - It is necessary to set variables in the file header. - After running it, there should be build folder with OpenSceneGraph.sln file and src/osgQt directory.

I couldn't use this batch file, because of its unavailability and other software-conditions (MSVS 2008, Qt 4.7.4) and therefore have to build it with CMake on my own.

III. Open OpenSceneGraph.sln in Visual studio

IV. Choose debug win32 (or other configuration you want)

V. Select osgQt project

VI. From menu select Build, Build osgQt

Result: osgQt lib and dll files ...copy them beside prebuilt osg libraries.

But I'm getting into trouble at the second step:

When using CMake 2.8.11.2 I'm receiving the following error:

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)

Because many others had this problem before I followed this instruction (http://qt-project.org/forums/viewthread/30006/):

So it worked for me(at least the CMake coniguration, didnt try to actually use it in compilation yet). Steps to reproduce:

  1. I used precompiled version of Qt 5.1(the one with OpenGL x64 for VS2012). To use it should be fine for you, as Qt 5.1 should support OpenGL3.2+ profiles out of the box, i dont think you need to use Glew anymore, just look at http://qt-project.org/doc/qt->5.1/qtgui/qabstractopenglfunctions.html hierarchy
  2. Installed Win SDK 8.0. But i think 7.0 could be fine.
  3. added set (CMAKE_PREFIX_PATH “C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64”) line to my cmake file. That’s where glu32.lib and similar files are located.
  4. Run cmake-gui configure&generate, using VS 11 win64 as generator.

It tried both (not during the same building process):

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”)

I get the error posted above and the following warnings:

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.

I don't think that these warnings are as harmless as most other warnings and show that CMake isn't able to find the right directory at all.

Does anybody has an idea how to fix this or if not a precompiled Version of osgQt for Qt 5.1 with osg 3.2.0 and MSVS2012 on Windows7(x64)?

Edit 1:

Code of 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)

Thanks in advance.

도움이 되었습니까?

해결책

In CMake, \ is the escape character. To add an actual \ to a string, you need to escape it, i.e. make it \\.

So you need to do:

set(CMAKE_PREFIX_PATH "D:\\Programme\\Microsoft SDKs\\Windows\\v7.0\\Lib\\x64")

Alternatively, you can change the path separators to /, even for Windows:

set(CMAKE_PREFIX_PATH "D:/Programme/Microsoft SDKs/Windows/v7.0/Lib/x64")

다른 팁

Same issue, CMAKE_PREFIX_PATH does't correct the error, but the following worked:

set(CMAKE_MODULE_PATH "C:/Program Files/Microsoft SDKs/Windows/v7.1/Lib")
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top