"collect2.exe: error: Id returned 1 exit status" when building S-function
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 26 Jan. 2022
Beantwortet: MathWorks Support Team
am 17 Feb. 2022
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.
Akzeptierte Antwort
MathWorks Support Team
am 26 Jan. 2022
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Block and Blockset Authoring finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!