I am trying to compile Matlab interface of NOMAD algorithm (https://www.gerad.ca/nomad/Project/Home.html) in Ubuntu 14.04 using gcc-4.7.3.
After executing compilation script provided by algorithm manufacturer I get the following error:
>> GERAD_NOMAD_build------------------------------------------------NOMAD MEX FILE BUILD --- GERAD VERSION Warning: Legacy MEX infrastructure is provided for compatibility; it will be removed in a futureversion of MATLAB. For more information, consult the MEX release noteshttp://www.mathworks.com/help/matlab/release-notes.html. > In GERAD_NOMAD_build (line 145) -> mexopts.sh sourced from directory (DIR = $PREF_DIR) FILE = /home/bkhusain/.matlab/R2015a/mexopts.sh-----------------------------------------------------------------> MATLAB = /usr/local/MATLAB/R2015a-> CC = gcc-> CC flags: CFLAGS = -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c99 CDEBUGFLAGS = -g COPTIMFLAGS = -O -DNDEBUG CLIBS = -Wl,-rpath-link,/usr/local/MATLAB/R2015a/bin/glnxa64 -L/usr/local/MATLAB/R2015a/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -> CXX = g++-> CXX flags: CXXFLAGS = -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread CXXDEBUGFLAGS = -g CXXOPTIMFLAGS = -O -DNDEBUG CXXLIBS = -Wl,-rpath-link,/usr/local/MATLAB/R2015a/bin/glnxa64 -L/usr/local/MATLAB/R2015a/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -> FC = gfortran-> FC flags: FFLAGS = -fexceptions -fbackslash -fPIC -fno-omit-frame-pointer FDEBUGFLAGS = -g FOPTIMFLAGS = -O FLIBS = -Wl,-rpath-link,/usr/local/MATLAB/R2015a/bin/glnxa64 -L/usr/local/MATLAB/R2015a/bin/glnxa64 -lmx -lmex -lmat -lm arguments = -> LD = g++-> Link flags: LDFLAGS = -Wl,-rpath,'/../lib/' LDDEBUGFLAGS = -g LDOPTIMFLAGS = -O LDEXTENSION = .mexa64 arguments = -lut -lnomad -L/home/bkhusain/nomad.3.7.3/lib/-> LDCXX = -> Link flags: LDCXXFLAGS = LDCXXDEBUGFLAGS = LDCXXOPTIMFLAGS = LDCXXEXTENSION = arguments = -lut -lnomad -L/home/bkhusain/nomad.3.7.3/lib/-----------------------------------------------------------------> g++ -c -I. -I/home/bkhusain/nomad.3.7.3/src/ -I/usr/local/MATLAB/R2015a/extern/include -I/usr/local/MATLAB/R2015a/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread -O -DNDEBUG "nomadmex.cpp"-> g++ -O -Wl,-rpath,'/../lib/' -o "/home/bkhusain/nomad.3.7.3/bin//nomad.mexa64" nomadmex.o -lut -lnomad -L/home/bkhusain/nomad.3.7.3/lib/ -Wl,-rpath-link,/usr/local/MATLAB/R2015a/bin/glnxa64 -L/usr/local/MATLAB/R2015a/bin/glnxa64 -lmx -lmex -lmat -lm/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 21/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o: In function `_start':(.text+0x20): undefined reference to `main'collect2: error: ld returned 1 exit status mex: link of ' "/home/bkhusain/nomad.3.7.3/bin//nomad.mexa64"' failed.Error using GERAD_NOMAD_build (line 166)Error Compiling NOMAD!Unable to complete successfully.
The error is thrown after executing:
mex -v -largeArrayDims nomadmex.cpp LDFLAGS='$LDFLAGS -Wl,-rpath,''$ORIGIN/../lib/'' ' -I. -I/home/bkhusain/nomad.3.7.3/src/ -lut -lnomad -L/home/bkhusain/nomad.3.7.3/lib/ -output /home/bkhusain/nomad.3.7.3/bin//nomad.mexa64
I don't understand why linker is complaining about missing reference to 'main', since main function is not required for mex compilation.
Best Answer