0

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

4

1 回答 1

1

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

我建议您编译 TAO 提供的单元测试之一并从那里复制,或使用 MPC 生成 makefile。

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

于 2014-12-21T19:06:18.700 回答