Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Kevin Nathan Newsgroups: comp.os.linux.development.apps Subject: Linking problem (using CMake) Date: Thu, 5 Jan 2012 00:08:41 -0700 Lines: 223 Message-ID: <20120105000841.0ca8d27e@efreet.linux> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: individual.net w7m9PhNbqLPc0lJBLmudngbCRGmb8SJ7M3jPNRA7v2OjjwX3VT Cancel-Lock: sha1:QW31YvVH1brgx1ditUg0c52jeFE= X-Newsreader: Claws Mail 3.7.10 (GTK+ 2.22.1; i686-pc-linux-gnu) X-Face: %/gp4MCQT=`#JS##?-]V9ksid6OSR@(wbF"bK6wSLO$u,%(N@X~bVhAD+\A_[gRhx*T6=fq "N_5H8.v[&;q0iw!s_wuL05B0xg#OYUkbn#@&U_]fL%o==~2sphc?*L+bicO!POJLG#p'N.]J0/p_w Z^(.kOB%Ob914-V>?GI; Xref: x330-a1.tempe.blueboxinc.net comp.os.linux.development.apps:341 I have another linking problem, which I have been fighting for several days, but I am sure it's due to my limited knowledge of CMake. And I much prefer CMake to the autotools! :-) I have been through various tutorials and have read through the html docs that are built from the CMake source, but nothing has seemed to cover this. Any pointers, hints or page links that might apply will be very welcome! If you need any other info, please let me know. Here is the source tree for the code: . |-auction |---src |-----dao <-- lib src |-----reports <-- lib src |-----types <-- lib src |-devel |---auct <-- old code, now a lib for clerk/penner |-----src |---clerk <-- uses auct, dao, reports, and types libs |-----src |---penner <-- uses auct lib |-----src "auction", "auct", and "penner" compile and link; auction and penner both run just fine (auct is a lib only). The problem is with "clerk" which compiles without error but has errors during linking. Here's a typical form of the error: ~/auction/src/reports/libreports.a(transactionticket.o): In function `TransactionTicket::transactionTable()': transactionticket.cpp:(.text+0xb69): undefined reference to `Tag::getTag()' This is the only error from libreports.a, all of the others are from libdao.a. There are no errors from libtypes.a. The Tag object is declared/defined in auction/src/types/tag.[h,cpp]. transactionticket.h has an include for tag.h. It was originally '#include "../types/tag.h"' and I tried '#include "tag.h"' with no difference. I was thinking since clerk is outside of the auction tree, it was having problems with the relative dir. There are no other tag.h files anywhere in any of the trees. I remove the CMakeCache.txt file after every change and run ccmake to reconfigure the Makefile, in case there were items left over in the cache file that weren't being updated properly. I am on CMake 2.4 because that is the newest version that will run on openSUSE 10.1. I'm sure I am missing something obvious, but cannot see it... -------------------------------------------------- CMakeList.txt file for "auction" link_directories( ${KDE3_KDECORE_LIBRARY} ${KDE3_LIB_DIR} ${MYSQL_LIBS} ${NEWDAO_INCLUDE} <-- this is auction/src/dao ${NEWREPT_INCLUDE} <-- this is auction/src/reports ${NEWTYPE_INCLUDE} <-- this is auction/src/types ) include_directories( ${KDE3_INCLUDE_DIR} ${QT_INCLUDE_DIR} ${AUCTLIB_DIR} ${MYSQL_INCLUDE} ${NEWAUCT_INCLUDE} <-- this is auction/src ${NEWTYPE_INCLUDE} <-- this is auction/src/types ${NEWDAO_INCLUDE} <-- this is auction/src/dao ${NEWREPT_INCLUDE} <-- this is auction/src/reports ) add_subdirectory (src) -------------------------------------------------- CMakeList.txt file for "auction/src" set(AUCTION_SRCS auction.cpp ... ) set(MOC_SRCS auction.cpp ... ) kde3_automoc(${MOC_SRCS}) # Build the libraries add_subdirectory (types) add_subdirectory (reports) add_subdirectory (dao) # create the executable add_executable(auction ${AUCTION_SRCS}) # link the "auction" target against the Qt and kdecore libraries # and our local libs. target_link_libraries( auction ${KDE3_KDECORE_LIBRARY} ${QT_QT_LIBRARY} kdeui mysqlclient kdeprint types reports dao ) -------------------------------------------------- CMakeList.txt file for "auction/src/dao" set(AUCTION_DAO_SRCS setupdao.cpp ... ) add_library( dao ${AUCTION_DAO_SRCS} ) -------------------------------------------------- CMakeList.txt file for "auction/src/types" set(AUCTION_TYPES_SRCS tag.cpp ... ) add_library( types ${AUCTION_TYPES_SRCS} ) -------------------------------------------------- CMakeList.txt file for "auction/src/reports" set(AUCTION_REPORTS_SRCS transactionticket.cpp ... ) add_library( reports ${AUCTION_REPORTS_SRCS} ) -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- The above works fine for the auction program. But, when clerk references the libraries, there are numerous errors. Here are the clerk CMake files: -------------------------------------------------- CMakeList.txt file for "devel/clerk" link_directories( ${KDE3_KDECORE_LIBRARY} ${KDE3_LIB_DIR} ${AUCTLIB_DIR} <-- only used by clerk and penner ${MYSQL_LIBS} ${NEWAUCT_INCLUDE} <-- this is auction/src ${NEWTYPE_INCLUDE} <-- this is auction/src/types ${NEWREPT_INCLUDE} <-- this is auction/src/reports ${NEWDAO_INCLUDE} <-- this is auction/src/dao ) include_directories( ${KDE3_INCLUDE_DIR} ${QT_INCLUDE_DIR} ${AUCTLIB_DIR} <-- only used by clerk and penner ${MYSQL_INCLUDE} ${NEWAUCT_INCLUDE} ${NEWTYPE_INCLUDE} ${NEWREPT_INCLUDE} ${NEWDAO_INCLUDE} ) add_subdirectory (src) -------------------------------------------------- CMakeList.txt file for "devel/clerk/src" set(CLERK_SRCS main.cpp ... ) kde3_automoc(${CLERK_SRCS}) add_executable(clerk ${CLERK_SRCS}) target_link_libraries( clerk ${KDE3_KDECORE_LIBRARY} ${QT_QT_LIBRARY} kdeui mysqlclient kdeprint auct types reports dao ) -------------------------------------------------- -- Kevin Nathan (Arizona, USA) Linux Potpourri -- http://www.project54.com/linux/ Open standards. Open source. Open minds. The command line is the front line. Linux 2.6.37.6-0.9-desktop 00:01am up 8:11, 14 users, load average: 0.09, 0.21, 0.87