我是一名Java开发人员,正在编译一些C ++代码以构建共享对象以在Java中对其进行访问。我可以成功构建“ so”文件,但是使用Java加载该文件时,出现undefined symbol: _ZTI18TransportFormatter
错误。我在代码中对此符号做了grep,发现该符号是TcpFormatter.o and UdpFormatter.o
的一部分。以下是我的make文件。请告诉我我是否在这里缺少任何东西。
附注:我正在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)-共享-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
清洁:
-rm * .o
最佳答案
只是有根据的猜测,但看起来您的代码使用RTTI(_ZTI18TransportFormatter = TransportFormatter的typeinfo),直接通过调用dynamic_cast
或typeid
进行,否则,如果您未通过以下方式明确禁用它,则编译器/链接器将包括它: -fno-rtti
选项,但通常在嵌入式平台上不可用。