"collect2.exe: error: Id returned 1 exit status" when building S-function

20 ビュー (過去 30 日間)
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
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 件)

カテゴリ

Help Center および File ExchangeBlock and Blockset Authoring についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by