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的工程后

  1. 添加【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

解决方案指向
msdn(英文版)
msdn(中文版)

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

posted @ 2018-10-09 11:21  scott_h  阅读(735)  评论(0编辑  收藏  举报