[CMake] Why the ui_header.h can not be found in Qt project when I add a share lib?

Kermit Mei kermit.mei at gmail.com
Tue Jan 20 13:12:28 EST 2009


Clinton Stimpson wrote:
>
> How about using ${GUI_UIS} instead of ${SAMPLE_UIS}, which is undefined.
>
> Clint
Hmm, thank you. I had repired some erros, and the GUI.so can be created.

But the new troubles come:


$ make
[ 20%] Generating ui_gotocelldialog.h
[ 40%] Generating moc_gotocelldialog.cxx
Scanning dependencies of target GUI
[ 60%] Building CXX object gui/CMakeFiles/GUI.dir/gotocelldialog.cpp.o
[ 80%] Building CXX object gui/CMakeFiles/GUI.dir/moc_gotocelldialog.cxx.o
Linking CXX shared library libGUI.so
[ 80%] Built target GUI
Scanning dependencies of target gtc
[100%] Building CXX object CMakeFiles/gtc.dir/main.cpp.o
Linking CXX executable gtc
CMakeFiles/gtc.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x138): undefined reference to 
`QApplication::QApplication(int&, char**, int)'
main.cpp:(.text+0x188): undefined reference to `QApplication::exec()'
main.cpp:(.text+0x195): undefined reference to 
`QApplication::~QApplication()'
main.cpp:(.text+0x1ab): undefined reference to 
`QApplication::~QApplication()'
gui/libGUI.so: undefined reference to `QLabel::setBuddy(QWidget*)'
gui/libGUI.so: undefined reference to `QString::free(QString::Data*)'
gui/libGUI.so: undefined reference to `QWidget::devType() const'
gui/libGUI.so: undefined reference to `QHBoxLayout::QHBoxLayout()'
gui/libGUI.so: undefined reference to `QDialog::sizeHint() const'
gui/libGUI.so: undefined reference to `QWidget::dropEvent(QDropEvent*)'
gui/libGUI.so: undefined reference to `QWidget::languageChange()'
gui/libGUI.so: undefined reference to `QWidget::leaveEvent(QEvent*)'
gui/libGUI.so: undefined reference to `QDialog::showEvent(QShowEvent*)'
gui/libGUI.so: undefined reference to `QWidget::hideEvent(QHideEvent*)'
gui/libGUI.so: undefined reference to `QDialog::setVisible(bool)'
gui/libGUI.so: undefined reference to `vtable for QLayoutItem'
 ……  <snip>  ……
gui/libGUI.so: undefined reference to `QDialog::reject()'
collect2: ld returned 1 exit status
make[2]: *** [gtc] Error 1
make[1]: *** [CMakeFiles/gtc.dir/all] Error 2
make: *** [all] Error 2



And the new CMakeLists of the main.cpp's directory is like this:

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT( GTC )

FIND_PACKAGE( Qt4 REQUIRED )

INCLUDE( ${QT_USE_FILE} )

ADD_SUBDIRECTORY( gui )

INCLUDE_DIRECTORIES(${GTC_SOURCE_DIR}/gui)
LINK_DIRECTORIES(${GTC_BINARY_DIR}/gui)

ADD_DEFINITIONS( -Wall )

SET( GTC_SRCS main.cpp )

INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/gui )
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR}/gui )



ADD_EXECUTABLE( gtc ${GTC_SRCS} )

SET(EXECUTABLE_OUT_PATH ${CMAKE_BINARY_DIR})

TARGET_LINK_LIBRARIES( gtc GUI )

What's the matter?
Thanks again;p



More information about the CMake mailing list