2011-02-01 160 views
0

我是一名java開發人員並編譯一些C++代碼來構建一個共享對象以便在Java中訪問它。我可以成功地構建我的'so'文件,但是當我使用Java加載它時,我得到了undefined symbol: _ZTI18TransportFormatter錯誤。我在代碼中爲這個符號做了一個grep,我發現符號是TcpFormatter.o and UdpFormatter.o的一部分。以下是我的make文件。請告訴我,如果我在這裏丟失任何東西。未定義符號錯誤

P.S:我在ARM處理器上構建它。當我在常規的Linux x86上構建並運行時,我沒有任何問題。

在此先感謝。

 

LD_LIBRARY_PATH=/usr/lib/gcc/arm-linux-gnueabi/4.3.3/ 
JDK_HOME=/home/skolli/native/java/include 
CC=gcc 
CCFLAGS=-c -O2 
INCLUDE_DIRS=-I$(JDK_HOME) -I$(JDK_HOME)/linux 
LIBS=/usr/lib/libstdc++.so.6 
OBJ= Clock.o Constants.o IpFullAddress.o IcmpFormatter.o IpHeaderFormatter.o TcpFormatter.o UdpFormatter.o IcmpEchoFormatter.o IcmpErrorFormatter.o NetworkHandler.o IcmpTransfer.o jni_util.o JniConnector.o 

icmpTransfer: $(OBJ) 
    $(CC) $(INCLUDE_DIRS) $(LIBS) -shared -o libicmpTransfer.so $(OBJ) 
Clock.o:  Clock.cpp Clock.h JniConnector.h 
    $(CC) $(INCLUDE_DIRS) $(CCFLAGS) $*.cpp 
Constants.o:  Constants.cpp Constants.h 
    $(CC) $(INCLUDE_DIRS) $(CCFLAGS) $(FLAGS) $*.cpp 
IcmpFormatter.o:  IcmpFormatter.cpp IcmpFormatter.h Constants.h 
    $(CC) $(INCLUDE_DIRS) $(CCFLAGS) $*.cpp 
IpHeaderFormatter.o: IpHeaderFormatter.cpp IpHeaderFormatter.h Exception.h JniConnector.h 
    $(CC) $(INCLUDE_DIRS) $(CCFLAGS) $*.cpp 
TcpFormatter.o:   TcpFormatter.cpp TcpFormatter.h IpFullAddress.h IcmpFormatter.h 
    $(CC) $(INCLUDE_DIRS) $(CCFLAGS) $*.cpp 
UdpFormatter.o:  UdpFormatter.cpp UdpFormatter.h IpFullAddress.h TcpFormatter.h IcmpFormatter.h 
    $(CC) $(INCLUDE_DIRS) $(CCFLAGS) $*.cpp 
IcmpEchoFormatter.o: IcmpEchoFormatter.cpp IpHeaderFormatter.h IcmpFormatter.h IpHeaderFormatter.h 
    $(CC) $(INCLUDE_DIRS) $(CCFLAGS) $*.cpp 
IcmpErrorFormatter.o: IcmpErrorFormatter.cpp IcmpErrorFormatter.h IcmpEchoFormatter.h Exception.h IpHeaderFormatter.h IpFullAddress.h Exception.h JniConnector.h 
    $(CC) $(INCLUDE_DIRS) $(CCFLAGS) $*.cpp 
IpFullAddress.o:  IpFullAddress.cpp IpFullAddress.h Exception.h JniConnector.h 
    $(CC) $(INCLUDE_DIRS) $(CCFLAGS) $*.cpp 
NetworkHandler.o:  NetworkHandler.cpp NetworkHandler.h Clock.h IpFullAddress.h JniConnector.h 
    $(CC) $(INCLUDE_DIRS) $(CCFLAGS) $*.cpp 
IcmpTransfer.o:   IcmpTransfer.cpp IcmpTransfer.h IcmpFormatter.h IcmpEchoFormatter.h IcmpErrorFormatter.h IpHeaderFormatter.h NetworkHandler.h Clock.h TcpFormatter.h JniConnector.h UdpFormatter.h 
    $(CC) $(INCLUDE_DIRS) $(CCFLAGS) $*.cpp 
jni_util.o:   /home/skolli/native/share/TaCoreLib/jni_util.c /home/skolli/native/share/TaCoreLib/jni_util.h 
    $(CC) $(INCLUDE_DIRS) $(CCFLAGS) $*.c 
JniConnector.o:   JniConnector.cpp JniConnector.h ../TaCoreLib/jni_util.h com_attune_netally_ta_corelib_IcmpPacketTransfer.h Clock.h IcmpTransfer.h 
    $(CC) $(INCLUDE_DIRS) $(CCFLAGS) $*.cpp 


clean: 
    -rm *.o 

回答

1

只是一個受過教育的猜測,但它看起來像你的代碼使用RTTI(_ZTI18TransportFormatter =所屬類別爲TransportFormatter),或直接致電dynamic_casttypeid或編譯器/連接器將包括它無論如何,如果你不明確禁用它通過-fno-rtti選項,但通常在嵌入式平臺上不可用。

+0

當我做了ldd -d我有以下。 undefined symbol:_ZTV18TransportFormatter(./libicmpTransfer.so) undefined symbol:_ZTI18TransportFormatter(./libicmpTransfer.so) libstdC++。so.6 => /usr/lib/libstdc++.so.6(0x4001e000) libgcc_s.so.1 => /lib/libgcc_s.so.1(0x400f6000) libc.so.6 => /lib/libc.so.6(0x4010c000) libm.so.6 => /lib/libm.so.6(0x4023b000 ) /lib/ld-linux.so.3(0x2a000000) – M99 2011-02-01 21:22:02