Code generated from RTW doesn't Compile with gcc in Linux Environment

Hello,
I have problems during compilation of the c code generated by RTW/Windows environment in Linux. I had error of missing header files, so copied all of the required headers from the matlab/rtw & matlab/simulink/ & matlab/extern/ directory but after that i have new issues like this one
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/crt1.o: In function `_start': (.text+0x18): undefined reference to `main' /tmp/cc6Qgk1k.o: In function `Test_initialize': Test.c:(.text+0x25a): undefined reference to `rt_InitInfAndNaN' collect2: ld returned 1 exit status
The command used to compile is " gcc -DRT filename.c"
Don't know why is it shouting in this function since we never modified anything in the code given by the RTW.
The whole program with other files could also be sent if required.
Any help would be welcomed.. as we have the same problem in all the codes from RTW.
Thanks and Best Regards,
Kareem.

回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2012 年 6 月 27 日

1 投票

Looks like you are still missing some files. Please try using the packNGo utility so that all required files are automatically packaged for relocation.

5 件のコメント

ak ms
ak ms 2012 年 6 月 29 日
Hello Govind,
I tried even the packNGO, but there is no use in it.. it still shouts out the same error.. any other way ?
Kaustubha Govind
Kaustubha Govind 2012 年 6 月 29 日
What target (tlc file) did you select during code-generation Is there a rt_nonfinite.c file generated in the code-generation folder?
ak ms
ak ms 2012 年 7 月 2 日
Hello, I selected grt.tlc target file and i also have a rt_nonfinite.c & rt_nonfinite.h files too... But i don't what & where is the problem !! Do help with some other solution ?
Kaustubha Govind
Kaustubha Govind 2012 年 7 月 2 日
Oops, I just noticed that the compile command you are using is "gcc -DRT filename.c" - this is not sufficient. You clearly need to link against the other .c files in the folder. Your command should include the list of all the C files generated into that folder. In some cases, there may also be other library files to link against. I would recommend using the Makefile generated by Simulink to ensure that the right compiler/linker flags are present.
asma
asma 2017 年 6 月 14 日
編集済み: asma 2017 年 6 月 14 日
Hello,
if we use rsim.tlc target, does this work?
Thanks

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSimulink Coder についてさらに検索

質問済み:

2012 年 6 月 27 日

編集済み:

2017 年 6 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by