이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
fatal error C1083: Cannot open source file: '..\..\..\..\Program Files\MATLAB\R2017a\rtw\c\src\common\rt_main.c': No such file or directory [Using Code Generation in Simulink]
조회 수: 5 (최근 30일)
이전 댓글 표시
I am trying to build my Simulink model using Visual Studio 2012 c++ compiler which is building just fine. However, included in the project are two .c files, namely:
rt_main.c
rt_logging.c
And when I try to build the model in Visual Studio 2012, it gives me the error that is in the title. In the directory '..\..\..\..\Program Files\MATLAB\R2017a\rtw\c\src\common\rt_main.c': I cannot find a file named rt_main.c, but I can find one named rt_main.cpp. Same for the rt_logging.c file. I've tried changing names either places without luck.
1) Why are .c files included in the project, when I have specificed in the Code Generation Options that the system target file is grt.tlc [Create Visual C/C++ Solution File for Simulink Coder] with c++ language?
2) How can I make Simulink build using the rt_main.cpp file?
If I uncheck the box "Generate Code Only" in Configuration Parameters -> Code Generation -> Build Process, it gives me the errors:
1>------ Build started: Project: SimulinkModelDLL, Configuration: Debug x64 ------
1>Build started 15-03-2021 12:01:44.
1>InitializeBuildStatus:
1> Creating "x64\Debug\SimulinkModelDLL.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1> rt_main.c
1>c1 : fatal error C1083: Cannot open source file: '..\..\..\..\Program Files\MATLAB\R2017a\rtw\c\src\common\rt_main.c': No such file or directory
1> rt_logging.c
1>c1 : fatal error C1083: Cannot open source file: 'rt_logging.c': No such file or directory
1> Generating Code...
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.12
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
댓글 수: 10
Rasmus Visgaard
2021년 3월 15일
Correct. It builds just fine in Simulink, but if I attempt to build it in VS2012, it gives me the said error.
Fangjun Jiang
2021년 3월 15일
Okay, I think you can "generate code" fine in Simulink but not "build", because you had those "build" errors in MATLAB Command window.
It surprised me that I found only rt_main.c in R17b and R18b folders but not rt_main.cpp file.
Where did you find the file and can you open it to look at the "abstract" at the begining of the file?
Rasmus Visgaard
2021년 3월 15일
Funny, because it's the other way around here. I can find the rt_main.cpp but not the rt_main.c. The folder I found it in is the same folder that VS is looking for the rt_main.c :
C:\Program Files\MATLAB\R2017a\rtw\c\src\common
Abstract:
/*
* Copyright 2012-2015 The MathWorks, Inc.
*
* File: rt_main.c
*
* Abstract:
*
* A real-time main that runs generated Simulink Coder code under most
* operating systems. Based on the definition of MULTITASKING, a single-task
* or multitask step function is employed.
*
* This file is a useful starting point for creating a custom main when
* targeting a custom floating point processor or integer micro-controller.
*
* Alternatively for ERT targets, you can generate a sample ert_main.c file
* with the generated code by selecting the "Generate an example main program"
* option. In this case, ert_main.c is precisely customized to the
* model requirements.
*
* Required Defines:
*
* MODEL - Model name
* NUMST - Number of sample times
*
*/
Fangjun Jiang
2021년 3월 15일
Noted "* File: rt_main.c"?? not rt_main.cpp. Check the date for the file to see if it matches the date of other original files.
Fangjun Jiang
2021년 3월 16일
restore the original files (or try just rename the .cpp files to .c) and try again. CPP application can with with C files.
Rasmus Visgaard
2021년 3월 16일
I tried to rename .cpp files to .c and tried again. I got the following error:
I have renamed some directories for proprietary reasons to XXXXX.
Build started 16-03-2021 13:29:46.
1>Project "C:\XXXXXX\Bladed\SimulinkModelDLL_grt_rtw\msvc\SimulinkModelDLL.vcxproj" on node 2 (Build target(s)).
1>InitializeBuildStatus:
Creating "x64\Debug\SimulinkModelDLL.unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64\CL.exe /c /IC:\XXXXXX\Bladed /I"C:\Program Files\MATLAB\R2017a\simulink\include\sf_runtime" /IC:\XXXXXX\Bladed\SimulinkModelDLL_grt_rtw /I"C:\Program Files\MATLAB\R2017a\extern\include" /I"C:\Program Files\MATLAB\R2017a\simulink\include" /I"C:\Program Files\MATLAB\R2017a\rtw\c\src" /I"C:\Program Files\MATLAB\R2017a\rtw\c\src\ext_mode\common" /Zi /nologo /W2 /WX- /Od /D WIN32 /D _DEBUG /D _CONSOLE /D MODEL=SimulinkModelDLL /D NUMST=1 /D NCSTATES=0 /D HAVESTDIO= /D RT= /D USE_RTMODEL= /D MAT_FILE=1 /D INTEGER_CODE=0 /D MT=0 /D CLASSIC_INTERFACE=0 /D ALLOCATIONFCN=0 /D ONESTEPFCN=1 /D TERMFCN=1 /D MULTI_INSTANCE_CODE=0 /D TID01EQ=0 /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"x64\Debug\\" /Fd"x64\Debug\vc110.pdb" /Gd /TC /errorReport:prompt "..\..\..\..\Program Files\MATLAB\R2017a\rtw\c\src\common\rt_main.c" "..\..\..\..\Program Files\MATLAB\R2017a\rtw\c\src\rt_logging.c"
rt_main.c
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xtgmath.h(111): warning C4602: #pragma pop_macro : 'new' no previous #pragma push_macro for this identifier
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(28): error C2061: syntax error : identifier 'acosf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(28): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(28): error C2061: syntax error : identifier 'asinf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(29): error C2061: syntax error : identifier 'atanf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(29): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(29): error C2061: syntax error : identifier 'atan2f'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(29): error C2061: syntax error : identifier 'ceilf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(30): error C2061: syntax error : identifier 'cosf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(30): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(30): error C2061: syntax error : identifier 'coshf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(30): error C2061: syntax error : identifier 'expf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(31): error C2061: syntax error : identifier 'fabsf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(31): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(31): error C2061: syntax error : identifier 'floorf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(31): error C2061: syntax error : identifier 'fmodf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(32): error C2061: syntax error : identifier 'frexpf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(32): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(32): error C2061: syntax error : identifier 'ldexpf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(32): error C2061: syntax error : identifier 'logf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(33): error C2061: syntax error : identifier 'log10f'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(33): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(33): error C2061: syntax error : identifier 'modff'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(33): error C2061: syntax error : identifier 'powf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(34): error C2061: syntax error : identifier 'sinf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(34): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(34): error C2061: syntax error : identifier 'sinhf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(34): error C2061: syntax error : identifier 'sqrtf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(35): error C2061: syntax error : identifier 'tanf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(35): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(35): error C2061: syntax error : identifier 'tanhf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(37): error C2061: syntax error : identifier 'acosl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(37): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(37): error C2061: syntax error : identifier 'asinl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(38): error C2061: syntax error : identifier 'atanl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(38): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(38): error C2061: syntax error : identifier 'atan2l'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(38): error C2061: syntax error : identifier 'ceill'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(39): error C2061: syntax error : identifier 'cosl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(39): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(39): error C2061: syntax error : identifier 'coshl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(39): error C2061: syntax error : identifier 'expl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(40): error C2061: syntax error : identifier 'fabsl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(40): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(40): error C2061: syntax error : identifier 'floorl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(40): error C2061: syntax error : identifier 'fmodl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(41): error C2061: syntax error : identifier 'frexpl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(41): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(41): error C2061: syntax error : identifier 'ldexpl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(41): error C2061: syntax error : identifier 'logl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(42): error C2061: syntax error : identifier 'log10l'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(42): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(42): error C2061: syntax error : identifier 'modfl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(42): error C2061: syntax error : identifier 'powl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(43): error C2061: syntax error : identifier 'sinl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(43): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(43): error C2061: syntax error : identifier 'sinhl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(43): error C2061: syntax error : identifier 'sqrtl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(44): error C2061: syntax error : identifier 'tanl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(44): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(44): error C2061: syntax error : identifier 'tanhl'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(46): error C2061: syntax error : identifier 'abs'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(46): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(48): error C2061: syntax error : identifier 'acos'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(48): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(48): error C2061: syntax error : identifier 'asin'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(49): error C2061: syntax error : identifier 'atan'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(49): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(49): error C2061: syntax error : identifier 'atan2'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(49): error C2061: syntax error : identifier 'ceil'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(50): error C2061: syntax error : identifier 'cos'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(50): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(50): error C2061: syntax error : identifier 'cosh'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(50): error C2061: syntax error : identifier 'exp'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(51): error C2061: syntax error : identifier 'fabs'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(51): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(51): error C2061: syntax error : identifier 'floor'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(51): error C2061: syntax error : identifier 'fmod'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(52): error C2061: syntax error : identifier 'frexp'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(52): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(52): error C2061: syntax error : identifier 'ldexp'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(52): error C2061: syntax error : identifier 'log'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(53): error C2061: syntax error : identifier 'log10'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(53): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(53): error C2061: syntax error : identifier 'modf'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(53): error C2061: syntax error : identifier 'pow'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(54): error C2061: syntax error : identifier 'sin'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(54): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(54): error C2061: syntax error : identifier 'sinh'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(54): error C2061: syntax error : identifier 'sqrt'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(55): error C2061: syntax error : identifier 'tan'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(55): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(55): error C2061: syntax error : identifier 'tanh'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(57): error C2061: syntax error : identifier 'hypot'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(57): error C2059: syntax error : ';'
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(57): error C2061: syntax error : identifier 'hypotf'
rt_logging.c
Generating Code...
1>Done Building Project "C:\XXXXX\Bladed\SimulinkModelDLL_grt_rtw\msvc\SimulinkModelDLL.vcxproj" (Build target(s)) -- FAILED.
Build FAILED.
Time Elapsed 00:00:00.58
Rasmus Visgaard
2021년 3월 19일
Some further insight:
I tried changing the Simulink option to generate c-code, and I can both generate the code and build it using visual studio 2012 without problems. The issue seems to be, that if I want Simulink to generate c++ code, it's trying to locate rt_main.c and compile it as c++ for some reason. Changing the name of rt_main.c to rt_main.cpp does not help either, as it is, for another reason unknown, trying to locate the rt_main.c file which no longer exists.
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)