"collect2.exe: error: Id returned 1 exit status" when building S-function
조회 수: 18 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2022년 1월 26일
답변: MathWorks Support Team
2022년 2월 17일
I am trying to build an S-function for use in a Simulink model on my Windows machine. But when I try to build it, I get an error that looks like this:
C:\Users\xxx\AppData\Local\Temp\mex_6822034771356968_15704\SourceCode.obj:SourceCode.c:(.text+0x316): undefined reference to `__imp_closesocket'
C:\Users\xxx\AppData\Local\Temp\mex_6822034771356968_15704\SourceCode.obj:SourceCode.c:(.text+0x323): undefined reference to `__imp_WSACleanup'
C:\Users\xxx\AppData\Local\Temp\mex_6822034771356968_15704\SourceCode.obj:SourceCode.c:(.text+0x401): undefined reference to `__imp_recv'
C:\Users\xxx\AppData\Local\Temp\mex_6822034771356968_15704\SourceCode.obj:SourceCode.c:(.text+0x5a3): undefined reference to `__imp_WSAStartup'
C:\Users\xxx\AppData\Local\Temp\mex_6822034771356968_15704\SourceCode.obj:SourceCode.c:(.text+0x5c1): undefined reference to `__imp_gethostbyname'
C:\Users\xxx\AppData\Local\Temp\mex_6822034771356968_15704\SourceCode.obj:SourceCode.c:(.text+0x5e7): undefined reference to `__imp_htons'
C:\Users\xxx\AppData\Local\Temp\mex_6822034771356968_15704\SourceCode.obj:SourceCode.c:(.text+0x615): undefined reference to `__imp_socket'
C:\Users\xxx\AppData\Local\Temp\mex_6822034771356968_15704\SourceCode.obj:SourceCode.c:(.text+0x61c): undefined reference to `__imp_connect'
C:\Users\xxx\AppData\Local\Temp\mex_6822034771356968_15704\SourceCode.obj:SourceCode.c:(.text+0x742): undefined reference to `__imp_WSAGetLastError'
C:\Users\xxx\AppData\Local\Temp\mex_6822034771356968_15704\SourceCode.obj:SourceCode.c:(.text+0xfdd): undefined reference to `__imp_recv'
C:\Users\xxx\AppData\Local\Temp\mex_6822034771356968_15704\SourceCode.obj:SourceCode.c:(.text+0x3987): undefined reference to `__imp_closesocket'
C:\Users\xxx\AppData\Local\Temp\mex_6822034771356968_15704\SourceCode.obj:SourceCode.c:(.text+0x398d): undefined reference to `__imp_WSACleanup'
collect2.exe: error: ld returned 1 exit status
It does not seem to matter whether I use the command line or the S-function builder. My colleagues seem able to build the function, so it does not appear to be a bug.
채택된 답변
MathWorks Support Team
2022년 1월 26일
Usually, this indicates that the winsock library is missing.
Troubleshooting steps:
1. Are you able to build a simple MEX example such as "arrayProduct.c"?
2. Confirm that only the ws_2_32.lib is on the path and mex is configured to use the MinGW64 compiler. Then, try running:
>> mex -lws2_32 SourceCode.c
3. Try reinstalling Windows SDK.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Block and Blockset Authoring에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!