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

时间:2014-12-21 17:27:06

标签: c++ makefile corba ace tao

尝试实现我的第一个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上使用来自this repo的ACE(6.2.8)和TAO(2.2.8)

1 个答案:

答案 0 :(得分:1)

库的顺序很重要,从右到左,您应该确保首先指定基础库,而不是使用基础库的基础库,例如-lTAO_PortableServer -lTAO_AnyTypeCode -lTAO -lACE -ldl -lrt。有关更多信息,请参阅Why does the order in which libraries are linked sometimes cause errors in GCC?

我建议你编译其中一个TAO发货单元测试并从那里复制,或使用MPC生成makefile。

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