Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.apps > #341

Linking problem (using CMake)

From Kevin Nathan <knathan@project54.com>
Newsgroups comp.os.linux.development.apps
Subject Linking problem (using CMake)
Date 2012-01-05 00:08 -0700
Message-ID <20120105000841.0ca8d27e@efreet.linux> (permalink)

Show all headers | View raw


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

Back to comp.os.linux.development.apps | Previous | NextNext in thread | Find similar


Thread

Linking problem (using CMake) Kevin Nathan <knathan@project54.com> - 2012-01-05 00:08 -0700
  Re: Linking problem (using CMake) Richard Kettlewell <rjk@greenend.org.uk> - 2012-01-05 10:37 +0000
    Re: Linking problem (using CMake) Kevin Nathan <knathan@project54.com> - 2012-01-05 11:32 -0700

csiph-web