[CMake] Why does a mylib.dll.a file be build automatically ?
Kermit Mei
kermit.mei at gmail.com
Thu Mar 12 10:33:41 EDT 2009
Hello, I use cmake with Qt4.5.0(for Win installer), and my program on
can be compiled well on Linux, but when I use in windows, I want a share
lib, but it always build a mylib.dll.a file with mylib.dll. And finally,
when I link the targets, it can't work, and tell me:
Linking CXX shared library ..\..\lib\libFreeReciteGui.dll
...(some undefined errors)...
I detected the lib directory, and libFreeReciteGui.dll haven't been
built, but a libFreeReciteGui.dll be built. Why?
The CMakeLists.txt for this library is:
###########################################
##$ cat ../src/gui/CMakeLists.txt
###########################################
# Include the core library.
INCLUDE_DIRECTORIES(${FREERECITE_SOURCE_DIR}/src/core)
# Make sure the compiler can find include files from our ui library.
INCLUDE_DIRECTORIES(${FREERECITE_BINARY_DIR}/src/gui)
# Make sure the linker can find the ui library once it is built.
LINK_DIRECTORIES(${FREERECITE_BINARY_DIR}/lib)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
# with SET() command you can change variables or define new ones
# here we define SAMPLE_SRCS variable that contains a list of all .cpp
files
# note that we don't need \ at the end of line
SET( FR_SRCS
Speaker.h
Speaker.cpp
)
SET( FRGUI_SRCS
AddDialog.cpp
MainWindow.cpp
MainWidget.cpp
ModifyDialog.cpp
TaskModel.cpp
ScannerWidget.cpp
ReciterWidget.cpp
ResultWidget.cpp
TesterWidget.cpp
)
# another list, this time it includes all header files that should be
treated with moc
SET( FRGUI_MOC_HDRS
AddDialog.h
MainWindow.h
MainWidget.h
ModifyDialog.h
TaskModel.h
ScannerWidget.h
ReciterWidget.h
ResultWidget.h
TesterWidget.h
)
# some .ui files
SET( FRGUI_UIS
AddDialog.ui
MainWindow.ui
MainWidget.ui
ModifyDialog.ui
ResultWidget.ui
ScannerWidget.ui
)
# and finally an resource file
#SET( FRGUI_RCS
# ./src/rc/sample.qrc
# )
# enable warnings
ADD_DEFINITIONS( -Wall )
# by default only QtCore and QtGui modules are enabled
# other modules must be enabled like this:
#SET( QT_USE_QT3SUPPORT TRUE )
#SET( QT_USE_QTXML TRUE )
# this command finds Qt4 libraries and sets all required variables
# note that it's Qt4, not QT4 or qt4
FIND_PACKAGE( Qt4 REQUIRED )
SET( QT_USE_QTWEBKIT TRUE )
# add some useful macros and variables
# (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that
contains a path to CMake script)
INCLUDE( ${QT_USE_FILE} )
# this command will generate rules that will run rcc on all files from
FRGUI_RCS
# in result FRGUI_RC_SRCS variable will contain paths to files produced
by rcc
#QT4_ADD_RESOURCES( FRGUI_RC_SRCS ${FRGUI_RCS} )
# this will run uic on .ui files:
QT4_WRAP_UI( FRGUI_UI_HDRS ${FRGUI_UIS} )
# and finally this will run moc:
QT4_WRAP_CPP( FRGUI_MOC_SRCS ${FRGUI_MOC_HDRS} )
ADD_LIBRARY(FreeReciteGui SHARED
${FRGUI_SRCS}
${FRGUI_MOC_SRCS}
${FRGUI_UI_HDRS}
${FR_SRCS}
)
TARGET_LINK_LIBRARIES(FreeReciteGui FreeReciteCore ${QT_LIBRARIES})
INSTALL(TARGETS LIBRARY DESTINATION lib)
###########################################
And by the way, it works well on Linux. Another share library is
FreeReciteCore.dll, and it also be built on Windows.
Help me, please;p
Thanks for any replay!
Kermit
More information about the CMake
mailing list