复杂项目:cmake fdoes在远程子目录中找不到静态库

时间:2013-12-17 00:02:14

标签: cmake

我正在开展一个特别复杂的项目。

在其中,我有一个库libcdlib.a,它位于“image”的子目录中,将被移动到另一个设备。在那个位置,我所拥有的只是.a文件。附近的目录中附有.h。相对于svn“trunk”

躯干/碱/ SYS /主机/ PKGS /访问/ LIB / libcdlib.a    躯干/碱/ SYS /主机/ PKGS /访问/包含/ CDK / cdlib.h

源代码存在于tarball中,如果最近构建了lib,则可以使用源代码。

trunk / sys / cdk / CDK.tar.gz扩展为    躯干/ SYS / CDK / CDK / CDLIB /

有这个Makefile

##################################################################                              
# Compiler / Cross-Compiler Declarations:                         #
###################################################################
include ../CompilerDeclaration

###################################################################
# Other Declarations:                                             #
###################################################################
LIBPATH  = ../bin
INCLUDE  = ../include

CCFLAGS = -Wall $(CROSS_CCFLAGS) -I inc -I $(INCLUDE)
TARGET = $(LIBPATH)/cdlib.a

SRC = src/sys.c src/mcast.c src/misc.c src/cmgr.c src/cert.c ext/fw.c src/devio.c src/eth.c src/mgmt
OBJ = $(addsuffix .o, $(basename $(SRC)))

.c.o: 
   $(CC) -c $(CFLAGS) $(CCFLAGS) $(DEBUG) -o $@ $<

all: $(OBJ)
   $(AR) $(ARFLAGS) $(TARGET) $(OBJ)

clean:
   rm -f $(OBJ)
   rm -f $(TARGET)

../ CompilerDeclaration定义了对目标处理器进行交叉编译的路径和参数。

运行此Makefile后,生成的cdlib.a将复制到其“image”位置并重命名为libcdlib.a。

现在,我们使用此CMakeList.txt在trunk/platform中构建平台代码(应用程序等)稍微混淆以安抚我的IP安全类型。

cmake_minimum_required(VERSION 2.8.10.2)
set(CMAKE_BUILD_TYPE Release)

add_definitions( -DFPGA_IMAGE_DIR="/pkgs/access/firmware/fpga" )                #for FPGA image file
add_definitions( -DTEMP_DATA_FILE_PATH="/tmp" )                                 #for temporary data 
add_definitions( -DCAPPER_CFG_PATH="/cust/private/lastconfigs/access/capper" )  #for persistent copp

include(../base/platform/CMakeSharedDefs.txt)

include_directories( ../base/sys/host/pkgs/access/include ${CMAKE_CURRENT_LIST_DIR}/modules)
include_directories( ${CMAKE_CURRENT_LIST_DIR}/modules/capper )
link_directories( ../base/sys/host/pkgs/access/lib ../base/sys/host/base/lib )

find_library(CDLIB   cdlib)
find_library(COMMON  common)
find_library(PCAP pcap)
find_library(OSIP osip2)
find_library(OSIP_PARSER osipparser2)
find_library(VQMON vqmon)

trunk/platform' are additional directories with CMakeList.txt 's. One layer down, each CMakeLists.txt is a bunch of add_subdirectory() statements. Two layers down are the final CMakeList.txt files. The item that needs libcdlib.a`下是trunk / platform / modules / wxyzModule / wxyzModule.cpp和Trunk / platform / modules / wxyzModule / Wxyz.cpp。

该目录的CMakeLists.txt是:

set( wxyz_SOURCE                                                                                    
   wxyzModule.cpp
        wxyz.cpp
   )

qt5_wrap_cpp(wxyz_MOCS
   wxyzModule.h
   )

add_library( wxyzModule STATIC ${wxyz_SOURCE} ${wxyz_MOCS})
Qt5_use_modules(wxyzModule Core)   

很抱歉长篇介绍......

当这个编译时,我得到:

../../modules/wxyzModule/libwxyzModule.a(wxyzModule.cpp.o): In function `wxyzModule::exitStatTest()':
wxyzModule.cpp:(.text+0x54): undefined reference to `CM_disconnect'
../../modules/wxyzModule/libwxyzModule.a(wxyzModule.cpp.o): In function `wxyzModule::stationCert()':
wxyzModule.cpp:(.text+0x5908): undefined reference to `MISC_pe_to_rate'
wxyzModule.cpp:(.text+0x5dec): undefined reference to `MISC_pe_to_rate'
../../modules/wxyzModule/libwxyzModule.a(wxyzModule.cpp.o): In function `wxyzModule::enterStatTest()':
wxyzModule.cpp:(.text+0x6e00): undefined reference to `NIC_get_mac_by_InterfaceName'
wxyzModule.cpp:(.text+0x6e84): undefined reference to `str_to_mac'
wxyzModule.cpp:(.text+0x6f88): undefined reference to `CM_connect_by_InterfaceName'
../../modules/wxyzModule/libwxyzModule.a(wxyzModule.cpp.o): In function `wxyzModule::stationVersion()':
wxyzModule.cpp:(.text+0x7318): undefined reference to `NIC_get_mac_by_InterfaceName'
wxyzModule.cpp:(.text+0x7394): undefined reference to `MGMT_get_version_info'
wxyzModule.cpp:(.text+0x74d0): undefined reference to `CM_disconnect'
wxyzModule.cpp:(.text+0x74fc): undefined reference to `str_to_mac'
wxyzModule.cpp:(.text+0x7558): undefined reference to `CM_connect_by_InterfaceName'
wxyzModule.cpp:(.text+0x7824): undefined reference to `CM_disconnect'
../../modules/wxyzModule/libwxyzModule.a(wxyz.cpp.o): In function `flush_rx_buffers(void*)':
wxyz.cpp:(.text+0x2c): undefined reference to `ETH_rx'

and a bunch more of the same....

所有未引用的内容都在libcdlib中。

最后,这是一个问题。我需要在哪里添加waht以获取此构建以查找libcdlib.a并使用其内容?

0 个答案:

没有答案