2

在函数中findQt4.cmake

FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE
                   NAMES QtCore QtCore4
                   HINTS ${QT_LIBRARY_DIR_TMP}
          )

如果我打印:

MESSAGE("HINT PATH " ${QT_LIBRARY_DIR_TMP})

我会得到:

~/dev/Libraries/Qt4.8.0/lib

在这个目录中有:~/dev/Libraries/Qt4.8.0/lib$ ls -all libQtCore*

我有:

-rw-r--r-- 1 abc abc     950 Nov 30 13:08 libQtCore.la
-rw-r--r-- 1 abc abc     942 Nov 30 13:07 libQtCore.prl
lrwxrwxrwx 1 abc abc      18 Nov 30 13:07 libQtCore.so -> libQtCore.so.4.8.0
lrwxrwxrwx 1 abc abc      18 Nov 30 13:08 libQtCore.so.4 -> libQtCore.so.4.8.0
lrwxrwxrwx 1 abc abc      18 Nov 30 13:08 libQtCore.so.4.8 -> libQtCore.so.4.8.0
-rwxr-xr-x 1 abc abc 2697932 Nov 30 13:08 libQtCore.so.4.8.0

但是为什么FIND_LIBRARY函数返回:QT_QTCORE_LIBRARY_RELEASE = NOT FOUND?

甚至,如果我这样做,也没有结果:

FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE
                       NAMES libQtCore.so
                       HINTS ${QT_LIBRARY_DIR_TMP}
              )
4

1 回答 1

0

而不是find_library()你可以使用find_package(). 这是 Qt 与 CMake 的常用方法

# Find Qt package
find_package(Qt4 REQUIRED) 

include(${QT_USE_FILE}) # Add and run Qt CMake modules
add_definitions(${QT_DEFINITIONS}) # Add definitions (if required)

# And later put all together
add_executable( ... )
target_link_libraries( ... ${QT_LIBRARIES}) # Link Qt libraries
于 2014-05-02T14:09:33.317 回答