Cypress USB3014 C++DLL 导入问题
VS2017编译cpp工程出现问题
- 硬件型号:芯片版本 Cypress FX3 USB3014(和芯片无关))
重现步骤:
1.解压 FX3_SDK_Windows_v1.3.3.exe
2.VS2017编译自带demo
cd ./Cypress/EZ-USB FX3 SDK/1.3/application/cpp
3.以上demo是vc2008的工程,转换为vs2017的工程后
- 添加【SetupAPI.Lib】
win10 SDK库,不需要指定地址,默认已经static link
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17134.0\um\x64 C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17134.0\um\x86
1>cyapi.lib(CyAPI.obj) : error LNK2019: 无法解析的外部符号 sprintf,该符号在函数 "public: void __cdecl CCyUSBDevice::UsbdStatusString(unsigned long,char *)" (?UsbdStatusString@CCyUSBDevice@@QEAAXKPEAD@Z) 中被引用 1>.\x64\Release/bulkloop.exe : fatal error LNK1120: 1 个无法解析的外部命令
5.依然提示错误,还需要静态链接【legacy_stdio_definitions.lib】
#include <stdio.h>
无效- 静态链接【legacy_stdio_definitions.lib】 没有此lib文件
<stdio.h> and <conio.h> The printf and scanf family of functions are now defined inline. The definitions of all of the printf and scanf functions have been moved inline into <stdio.h>, <conio.h>, and other CRT headers. This is a breaking change that leads to a linker error (LNK2019, unresolved external symbol) for any programs that declared these functions locally without including the appropriate CRT headers. If possible, you should update the code to include the CRT headers (that is, add #include <stdio.h>) and the inline functions, but if you do not want to modify your code to include these header files, an alternative solution is to add an additional library to your linker input, legacy_stdio_definitions.lib. To add this library to your linker input in the IDE, open the context menu for the project node, choose Properties, then in the Project Properties dialog box, choose Linker, and edit the Linker Input to add legacy_stdio_definitions.lib to the semi-colon-separated list. If your project links with static libraries that were compiled with a release of Visual C++ earlier than 2015, the linker might report an unresolved external symbol. These errors might reference internal stdio definitions for _iob, _iob_func, or related imports for certain stdio functions in the form of _imp_*. Microsoft recommends that you recompile all static libraries with the latest version of the Visual C++ compiler and libraries when you upgrade a project. If the library is a third-party library for which source is not available, you should either request an updated binary from the third party or encapsulate your usage of that library into a separate DLL that you compile with the older version of the Visual C++ compiler and libraries.
参考网站:
有讨论过此问题
Cypress社区论坛1
Cypress社区论坛2
https://blog.csdn.net/baidu_37503452/article/details/76235121
https://blog.csdn.net/wangzhichunnihao/article/details/78480493
==============
解决方案:
添加静态库(吐血写完C# 之后,才处理好这个问题,又要改成C++版本了)
添加【legacy_stdio_definitions.lib】VS2017运行库, C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\lib\x64\ C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\lib\x86\ 添加【SetupAPI.Lib】 win10 SDK库(需要额外 安装win10 SDK) C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17134.0\um\x64 C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17134.0\um\x86
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
2015-10-09 golang资料整理 (整理 中...)