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

조회 수: 6 (최근 30일)
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

채택된 답변

Ryan Livingston
Ryan Livingston 2016년 6월 29일
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.

추가 답변 (1개)

Mark Scheffer
Mark Scheffer 2016년 6월 30일
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.

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by