我正在处理具有多个共享库的基于QT-CMake的项目。不幸的是,当我尝试编译需要QtNetwork的类时,出现了无法找到QNetworkReply的错误。我的CMake文件如下所示

project(Geo CXX)
cmake_minimum_required(VERSION 2.8)
find_package(Qt4 4.7.3 REQUIRED QtCore QtNetwork)
message(STATUS "Geo module build")

SET(QT_USE_QTNETWORK true)

INCLUDE(${QT_USE_FILE})
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${QT_INCLUDE_DIR} ${QT_QTNETWORK_INCLUDE_DIR})

ADD_DEFINITIONS(${QT_DEFINITIONS})

set(geo_lib_src google.cpp Tracker.cpp Coordinates.h)
set(geo_lib_headers google.h)

qt4_wrap_cpp(geo_lib_moc ${geo_lib_headers})

add_library(Geo SHARED ${geo_lib_src} ${geo_lib_moc} )
target_link_libraries(Geo ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARY})

另外,当尝试在其他库中使用该库时,我收到无法解析函数名称的消息,但我在那里
add_dependencies(Core Model Geo)

有什么事吗

最佳答案

您的find_package调用看起来与我在此处的某些项目中看到的不同:

FIND_PACKAGE( Qt4 4.6.0 COMPONENTS QtMain QtCore QtGui QtSql QtXml QtNetwork REQUIRED )

所以我会尝试
FIND_PACKAGE( Qt4 4.7.3 COMPONENTS QtCore QtNetwork REQUIRED )

10-06 12:06