Argument 'DARMSTM' not permitted for option 'devic

本文详细解释了在使用MDK企业版时遇到STM32F10x.s编译错误A3903U:Argument'DARMSTM'notpermittedforoption'device'的问题,并提供了从MDK3.21版本开始支持企业版对M3内核调试的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题类别: RealView MDK问题 >> realview编译与汇编    
环境说明:
MDK3.21之前版本
分析描述:
使用MDK企业版的时候,在编译STM32的工程的时候出项STM32F10x.s: error: A3903U: Argument 'DARMSTM' not permitted for option 'device'.
问题解答    

 

操作步骤:这个是企业版老版本的限制,从MDK3.21之后才支持企业版对M3内核的调试的,请到www.realview.com.cn/MDK 及时更新您的开发环境,并覆盖安装即刻

Microsoft Windows [版本 10.0.22631.5335] (c) Microsoft Corporation。保留所有权利。 C:\Users\dell>make --version GNU Make 4.1 Built for x86_64-pc-mingw32 Copyright (C) 1988-2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. C:\Users\dell>cmake --version cmake version 3.27.4 CMake suite maintained and supported by Kitware (kitware.com/cmake). C:\Users\dell>gcc --version gcc (Rev3, Built by MSYS2 project) 13.2.0 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. C:\Users\dell>arm-linux-gnueabihf-gcc --version arm-linux-gnueabihf-gcc (Linaro GCC 4.9-2017.01) 4.9.4 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. C:\Users\dell>cd /d D:\20241207\KPC_PEPTXDLRI_Windos\build D:\20241207\KPC_PEPTXDLRI_Windos\build>cmake .. -G "MinGW Makefiles" CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 3.5 will be removed from a future version of CMake. Update the VERSION argument <min> value or use a ...<max> suffix to tell CMake that the project does not need compatibility with older versions. -- The C compiler identification is GNU 13.2.0 -- The CXX compiler identification is GNU 13.2.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: D:/VS CODE anzhuangweizhi/ucrt64/bin/cc.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: D:/VS CODE anzhuangweizhi/ucrt64/bin/c++.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Git version is main: -- Configuring done (9.3s) -- Generating done (0.1s) -- Build files have been written to: D:/20241207/KPC_PEPTXDLRI_Windos/build D:\20241207\KPC_PEPTXDLRI_Windos\build>mingw32-make [ 2%] Building CXX object app_PEPTXDLRI/CMakeFiles/PEPTXDLRI_APP.dir/PEPTXDLRI_console.cpp.obj In file included from D:\20241207\KPC_PEPTXDLRI_Windos\app_PEPTXDLRI\PEPTXDLRI_console.cpp:11: D:/20241207/KPC_PEPTXDLRI_Windos/app_PEPTXDLRI/hvac_if/logic_ptu.h:14:10: fatal error: arpa/inet.h: No such file or directory 14 | #include <arpa/inet.h> | ^~~~~~~~~~~~~ compilation terminated. mingw32-make[2]: *** [app_PEPTXDLRI\CMakeFiles\PEPTXDLRI_APP.dir\build.make:76: app_PEPTXDLRI/CMakeFiles/PEPTXDLRI_APP.dir/PEPTXDLRI_console.cpp.obj] Error 1 mingw32-make[1]: *** [CMakeFiles\Makefile2:117: app_PEPTXDLRI/CMakeFiles/PEPTXDLRI_APP.dir/all] Error 2 mingw32-make: *** [Makefile:90: all] Error 2 D:\20241207\KPC_PEPTXDLRI_Windos\build>
最新发布
06-26
<think>我们正在解决Windows下使用MinGW编译时找不到'arpa/inet.h'头文件的问题。根据引用资料,我们知道:-在Linux中,'arpa/inet.h'是用于网络编程的头文件,包含如inet_ntoa等函数。-在Windows中,对应的头文件是'winsock.h'或'winsock2.h',并且需要链接ws2_32库。因此,在Windows环境下,我们不能直接使用Linux特有的头文件,而应该使用Windows的套接字库。解决方案:1.使用条件编译:在代码中根据操作系统选择包含不同的头文件。2.在Windows下,包含'winsock2.h'和'ws2tcpip.h'(如果需要使用一些高级的TCP/IP函数)而不是'arpa/inet.h'。3.初始化Winsock库:在Windows下使用套接字之前,需要调用WSAStartup进行初始化。4.在链接时添加-lws2_32(对于MinGW)来链接Winsock库。具体步骤:第一步:修改头文件包含部分我们可以使用预处理指令来区分操作系统,例如:```c#ifdef_WIN32#include<winsock2.h>#include<ws2tcpip.h>#else#include<sys/socket.h>#include<netinet/in.h>#include<arpa/inet.h>#endif```第二步:在Windows下初始化Winsock在Windows下,使用套接字函数之前需要初始化Winsock库。通常在程序开始时调用WSAStartup,程序结束时调用WSACleanup。例如:```c#ifdef_WIN32WSADATAwsaData;if(WSAStartup(MAKEWORD(2,2),&wsaData)!=0){fprintf(stderr,"WSAStartupfailed.\n");return1;}#endif```第三步:在程序结束时清理Winsock(仅Windows)```c#ifdef_WIN32WSACleanup();#endif```第四步:在编译时链接Winsock库(Windows)使用MinGW编译时,需要链接ws2_32库。在编译命令中加入-lws2_32参数,例如:```gcc-oprogramprogram.c-lws2_32```另外,注意:在Windows中,套接字相关的函数和类型可能有一些不同的命名,比如关闭套接字使用closesocket而不是close(在非Windows系统使用close)。因此,我们也需要条件编译来处理这种差异。例如,关闭套接字:```c#ifdef_WIN32closesocket(sockfd);#elseclose(sockfd);#endif```总结:通过条件编译区分操作系统,使用Windows下的Winsock库替代Linux下的网络相关头文件,并正确初始化和清理,以及链接相应的库。注意:由于'arpa/inet.h'是UNIX/Linux系统的头文件,在Windows下不可用,所以必须用上述方法进行替换。下面是一个简单的示例代码结构:```c#include<stdio.h>#ifdef_WIN32#include<winsock2.h>#include<ws2tcpip.h>#else#include<sys/socket.h>#include<netinet/in.h>#include<arpa/inet.h>#include<unistd.h>//对于close函数#endifintmain(){#ifdef_WIN32//初始化WinsockWSADATAwsaData;if(WSAStartup(MAKEWORD(2,2),&wsaData)!=0){fprintf(stderr,"WSAStartupfailed.\n");return1;}#endif//创建套接字等网络操作//注意:在Windows中使用closesocket,在Linux中使用close#ifdef_WIN32WSACleanup();#endifreturn0;}```这样修改后,代码就可以在Windows和Linux上编译运行了。相关问题:1.如何编写跨平台的网络编程代码?2.Windows下的Winsock编程有哪些注意事项?3.MinGW在编译Windows程序时如何链接系统库?</think>### Windows下使用MinGW编译时找不到'arpa/inet.h'的解决方法 `arpa/inet.h` 是UNIX/Linux系统中的网络编程头文件,在Windows环境下不可用。以下是完整的解决方案: #### 1. **修改头文件包含方式(关键步骤)** 使用条件编译区分操作系统环境: ```c #ifdef _WIN32 #include <winsock2.h> // Windows套接字核心功能 #include <ws2tcpip.h> // 包含inet_ntop等函数的扩展 #else #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> // Linux专用头文件 #endif ``` #### 2. **初始化Winsock库(仅Windows需要)** 在程序入口处添加初始化代码: ```c #ifdef _WIN32 WSADATA wsaData; if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) { fprintf(stderr, "WSAStartup failed: %d\n", WSAGetLastError()); exit(1); } #endif ``` 程序退出前需清理资源: ```c #ifdef _WIN32 WSACleanup(); #endif ``` #### 3. **链接Winsock库(编译命令)** 使用MinGW编译时添加链接参数: ```bash gcc your_program.c -o output -lws2_32 ``` `-lws2_32` 参数链接Windows Socket 2.2库[^1]。 #### 4. **API差异处理** 注意Windows/Linux的API差异: ```c // 关闭套接字 #ifdef _WIN32 closesocket(sockfd); #else close(sockfd); #endif // 错误处理 #ifdef _WIN32 int error = WSAGetLastError(); #else int error = errno; #endif ``` #### 5. **替代函数映射** Windows下使用以下替代函数: | Linux函数 | Windows等效 | 头文件 | |----------------|----------------------|--------------| | `inet_ntoa()` | `WSAAddressToString` | `<winsock2.h>` | | `inet_aton()` | `InetPton` | `<ws2tcpip.h>` | | `getaddrinfo()`| 同名函数 | `<ws2tcpip.h>` | ### 完整示例代码 ```c #include <stdio.h> #ifdef _WIN32 #include <winsock2.h> #include <ws2tcpip.h> #else #include <arpa/inet.h> #include <unistd.h> #endif int main() { #ifdef _WIN32 WSADATA wsa; if (WSAStartup(MAKEWORD(2,2), &wsa) != 0) { printf("WSAStartup failed: %d\n", WSAGetLastError()); return 1; } #endif struct in_addr addr; addr.s_addr = htonl(0x7F000001); // 127.0.0.1 #ifdef _WIN32 char str[INET_ADDRSTRLEN]; InetNtop(AF_INET, &addr, str, INET_ADDRSTRLEN); printf("IP: %s\n", str); #else printf("IP: %s\n", inet_ntoa(addr)); #endif #ifdef _WIN32 WSACleanup(); #endif return 0; } ``` **编译命令**: ```bash gcc -o net_example net_example.c -lws2_32 ``` ### 注意事项 1. **头文件顺序**:Windows中必须先包含`<winsock2.h>`再包含其他头文件 2. **字节序处理**:Windows同样需要`htonl()`/`ntohl()`等函数 3. **类型差异**:Windows的`socket`类型是`SOCKET`(无符号整数),Linux是`int` 通过以上修改,您的代码将能在Windows/Linux双平台编译运行[^3][^4]。 --- ### 相关问题 1. 如何在Windows和Linux之间编写可移植的网络套接字程序? 2. MinGW编译时出现"undefined reference to `inet_ntoa`"错误应如何解决? 3. Windows下的Winsock编程与Linux的BSD套接字编程主要有哪些差异? 4. 使用MinGW进行跨平台开发时如何处理操作系统特定的头文件包含问题? 5. 如何检测当前编译环境是Windows还是Linux以实现条件编译?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值