为什么我在尝试编译我的第一个 CORBA 服务器(使用 ACE/TAO ORB 实现)时遇到链接器错误

Why do I get linker errors trying to compile my first CORBA server (using ACE/TAO ORB implementation)?

本文关键字:实现 ORB TAO 错误 链接 遇到 ACE 使用 编译 我的 服务器      更新时间:2023-10-16

尝试实现我的第一个 CORBA 服务器(使用 ACE/TAO ORB 实现(,我使用以下 makefile:

#compiler                                                                                                                                                      
CC=g++
#compiler options
CPPFLAGS=-Wall -I. -I/usr/include/ -I/usr/include/orbsvcs/
LFLAGS=-L/usr/lib64/ -lACE -lTAO -lTAO_PortableServer -lTAO_DynamicAny -lTAO_CosNotification -lTAO_CosNaming
#source files
SOURCES=$(wildcard *.cpp)
#object files
OBJECTS=$(SOURCES:.cpp=.o)
#executable filename
EXECUTABLE=main
#Special symbols used:
#$^ - is all the dependencies (in this case =$(OBJECTS) )
#$@ - is the result name (in this case =$(EXECUTABLE) )
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
  #$(LINK.o) $^ -o $@
  $(CC) $(LFLAGS) $^ -o $@
%.o: %.c 
  $(CC) $(CPPFLAGS) -c $<
clean:
  - rm -rf $(EXECUTABLE) $(OBJECTS)

我在编译时收到以下错误:

g++  -Wall -I. -I/usr/include/ -I/usr/include/orbsvcs/  -c -o cryptC.o cryptC.cpp
g++  -Wall -I. -I/usr/include/ -I/usr/include/orbsvcs/  -c -o cryptS.o cryptS.cpp
g++  -Wall -I. -I/usr/include/ -I/usr/include/orbsvcs/  -c -o main.o main.cpp
In file included from main.cpp:5:
CryptographicImpl.h: In member function ‘virtual char* CryptographicImpl::decrypt(const CaesarAlgorithm::charsequence&, CORBA::ULong, CORBA::ULong)’:
CryptographicImpl.h:49: warning: comparison between signed and unsigned integer expressions
#g++   cryptC.o cryptS.o main.o -o main
g++ -L/usr/lib64/ -lTAO_PortableServer -lTAO_DynamicAny -lACE -lTAO -lTAO_CosNotification -lTAO_CosNaming cryptC.o cryptS.o main.o -o main
cryptC.o: In function `TAO::Objref_Traits<CaesarAlgorithm>::marshal(CaesarAlgorithm*, TAO_OutputCDR&)':
cryptC.cpp:(.text+0x7f): undefined reference to `CORBA::Object::marshal(CORBA::Object*, TAO_OutputCDR&)'

整个编译日志:http://pastebin.com/0KpLXixw

我在 CentOS 6.6 上使用这个存储库中的 ACE (6.2.8( 和 TAO(2.2.8(

库的顺序很重要,从右到左,您应该确保首先指定基本库,而不是使用基本库的库,例如 -lTAO_PortableServer -lTAO_AnyTypeCode -lTAO -lACE -ldl -lrt .有关更多信息,另请参阅为什么库的链接顺序有时会导致 GCC 中的错误?。

我建议您编译 TAO 附带的单元测试之一并从那里复制,或者使用 MPC 生成生成文件。

还要检查 TAOX11,新的 IDL 到 C++11 语言映射更易于使用,我们提供免费的评估许可证,您可以将其用于课堂使用。