2011-07-08 102 views
1

昨天我下載了Qt4 Opensource library for linux。運行編譯錯誤:「找不到-lQtCore4」

./configure 
./make 
./make install 

並插入到我的.bashrc文件之後:

PATH=/usr/local/TrollTech/Qt-4.7.3/bin:$PATH 
export PATH 

在此之後,我爲了產生一個Makefile,我跑出cmake的。的CMakeLists.txt:

project(VTKToVTFx) 

cmake_minimum_required(VERSION 2.6) 

find_package(VTK REQUIRED) 
find_package(Qt4 REQUIRED) 

include(${VTK_USE_FILE}) 
include(${QT_USE_FILE}) 

SET(VTK_TO_VTFX_FORMS main.ui) 
QT4_WRAP_UI(VTK_TO_VTFX_FORMS_UIC ${VTK_TO_VTFX_FORMS}) 

SET(MOC_HEADERS VTKToVTFx.h) 
qt4_wrap_cpp(MOC_OUTFILES ${MOC_HEADERS}) 

SET(CPP_SOURCES VTKToVTFx.cpp 
       VTKPatch.cpp 
       VTKFile.cpp 
       VTKData.cpp 
       VTKDataHolder.cpp 
       ) 

add_executable(VTKToVTFx ${CPP_SOURCES} ${VTK_TO_VTFX_FORMS_UIC} ${MOC_OUTFILES}) 

# Adds folders for Visual Studio solution explorer (and for Xcode explorer) 
source_group("Generated"   FILES ${MOC_FILES_CPP} ${VTK_TO_VTFX_FORMS_UIC} ${QRC_FILES_CPP} ${MOC_OUTFILES}) 

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) 

target_link_libraries(VTKToVTFx vtkHybrid) 
target_link_libraries(VTKToVTFx QtCore4) 
target_link_libraries(VTKToVTFx QtGUI4) 

此的CMakeLists.txt完美的作品以及在Windows,但是當我嘗試編譯我的Ubuntu安裝的輸出,出現此錯誤:

/usr/bin/ld: cannot find -lQtCore4 
/usr/bin/ld: cannot find -lQtGUI4 

任何誰可以點我到我的問題在這裏?

+0

斜線?反斜槓? Linux呢?視窗? –

+0

對不起,我確實使用了正確的斜線,但是在這裏寫錯了。我上面更新了我的帖子。我使用的是Ubuntu 11.04。 –

+0

你爲什麼不使用[現有軟件包](http://packages.ubuntu.com/natty/libqt4-dev)的任何原因? – sehe

回答

3

在unix [like]世界中,斜線是路徑分隔符,而不是反斜線。

\usr\local\TrollTech\Qt-4.7.3\bin評估爲usrlocalTrollTechQt-4.7.3bin

編輯:此外,您的CMakeLists.txt似乎有點犯規。看看http://qtnode.net/wiki/Qt4_with_cmake。取而代之的

target_link_libraries(VTKToVTFx QtCore4) 

使用類似(源鏈接網站):


  • To add support for Qt4 libraries like network or qttest, you need to add both the include files and corresponding libraries. For example, to add support for the network and qttest libraries, you can use:
INCLUDE_DIRECTORIES(
    ${QT_INCLUDE_DIR} 
    ${QT_QTNETWORK_INCLUDE_DIR} 
    ${QT_QTTEST_INCLUDE_DIR} 
) 

TARGET_LINK_LIBRARIES(
    ${QT_LIBRARIES} 
    ${QT_QTNETWORK_LIBRARIES} 
    ${QT_QTTEST_LIBRARIES} 
) 

即使在發佈的4.x的線,圖書館已經改名並將重新命名。幸運的是,不需要硬編碼:)

+0

對不起,我確實使用了正確的斜線,但在這裏只是寫錯了。我上面更新了我的帖子。 –

+0

@Steinar Lima:我編輯了我的答案。 –

+0

謝謝,這個伎倆!真棒! :) –