Error linking Matlab generated C-code: start.S:114: undefined reference to `main' collect2

1 Ansicht (letzte 30 Tage)
When using Matlab Code Generator to generate an executable, I get the following error (see below) at the linking stage. Is this due to having a too new glibc version 5.2.x (because I use Ubuntu 15.10 rather than 14.x) and is there any solution other than to reinstall my complete system with Ubuntu 14.10 and glibc 4.7.x ??
Please advice where this error comes from and if it can somehow be resolved.
Thanks, Mark.
---------- gcc error:
gcc -Wl,-rpath,"/usr/local/MATLAB/R2016a/bin/glnxa64",-L"/usr/local/MATLAB/R2016a/bin/glnxa64" -L/usr/local/MATLAB/R2016a/sys/os/glnxa64 -fopenmp -liomp5 -o /home/mscheffer/Desktop/kstar/rtda/matlab/mse_rtda mse_rtda_rtwutil.o mse_rtda_data.o mse_rtda_initialize.o mse_rtda_terminate.o mse_rtda.o cos.o sin.o besselj.o cbesj.o abs.o sqrt.o cbinu.o gammaln.o cuchk.o cmlri.o casyi.o cuoik.o cunhj.o cunik.o extract_cosine.o interp1.o mean.o bsxfun.o correctphase.o sum.o norm.o std.o permute.o any.o getstokes.o mse_rtda_emxutil.o rt_nonfinite.o rtGetNaN.o rtGetInf.o -lm
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start':
/build/glibc-qbmteM/glibc-2.21/csu/../sysdeps/x86_64/start.S:114: undefined reference to `main'
collect2: error: ld returned 1 exit status

Akzeptierte Antwort

Ryan Livingston
Ryan Livingston am 29 Jun. 2016
To build an executable you need to specify a main function via MATLAB Coder. You can also use the example main function generated by MATLAB Coder in the examples directory as a starting point for your own main.

Weitere Antworten (1)

Mark Scheffer
Mark Scheffer am 30 Jun. 2016
Silly. When you ask Matlab Code to generate an Executable along with the generated C-code, it does not by default switch on the option to employ a main file that calls the function that should be executed. This leads to this error.
You would expect that Matlab Coder generates a working executable when one selects an Executable to be generated.

Kategorien

Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by