Trying to implement my very first CORBA server (with ACE/TAO ORB implementation) I use the following 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)
and I get the following error on compilation:
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&)'
whole compilation log: http://pastebin.com/0KpLXixw
I use ACE (6.2.8) and TAO(2.2.8) from this repo on my CentOS 6.6
The order of the libraries is important, from right to left you should make sure you first specify the base libraries, than the ones that use the base, for example
-lTAO_PortableServer -lTAO_AnyTypeCode -lTAO -lACE -ldl -lrt
. For more information see also Why does the order in which libraries are linked sometimes cause errors in GCC?.I would recommend you to compile one of the TAO shipped unit tests and copy from there, or use MPC to generate the makefiles.
Also check TAOX11, the new IDL to C++11 language mapping is way easier to use and we provide free of charge evaluation licenses that you can use for classroom usage.