Hi, I am struggling with c++ linking problem in Linux...
The C++ code has MATLAB engine inside, and it has no problem when compiling under Windows(same MATLAB version, MATLAB 6.5R13), but it can not be compiled with Linux, I always get the following error:
/usr/bin/ld: warning: libstdc++-libc6.1-2.so.3, needed by /s2bin/matlabR13/bin/glnx86/libmx.so, not found (try using -rpath or -rpath-link)
/s2bin/matlabR13/bin/glnx86/libmx.so: undefined reference to `__throw'
collect2: ld returned 1 exit status
make: *** [rz_dpsk] Error 1
make: Target `all' not remade because of errors.
I have included the directory $(MATLAB)/sys/os/glnx86 in the Makefile, which has the file of libstdc++-libc6.1-2.so.3 that libmx.so is needed, but I still get the warning. The Makefile I am using is shown below:
MATLAB = /s2bin/matlabR13
CC = g++
FLAGS = -I$(MATLAB)/extern/include -I$(MATLAB)/extern/include/cpp
LIBS = -L$(MATLAB)/bin/glnx86 -L$(MATLAB)/extern/lib/glnx86 -L$(MATLAB)/sys/os/glnx86 -lut -lmx -leng -lmex -lmat
CFLAGS = -Wall -g
LINK = $(CC)
LFLAGS =
INCPATH =
LIBPATH =
SOURCES = Mat_ex.cpp
OBJECTS = Mat_ex.o
TARGETS = Mat_ex
LINKOBJECTS =
#######Implicit rules
.SUFFIXES:.cpp
#.cpp.o:
#$(CC) -c $(FLAGS) $(INCPATH) -o $@ $<
.cpp.o:
$(CC) -c $(FLAGS) -o $@ $<
####### Build rules
all: $(TARGETS)
Mat_ex:Mat_ex.o $(LINKOBJECTS)
$(LINK) $(LIBPATH) $(LFLAGS) -o $@ $@.o $(LINKOBJECTS) $(LIBS)
depend:
@makedepend $(SOURCES) 2> /dev/null
showfiles:
@echo $(HEADERS) $(SOURCES) Makefile
clean:
rm *.o
rm $(TARGETS)
<< moderator edit: added [code][/code] tags >>
The compiler version is:
gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
Can anyone help? Thanks a lot!