提供的FTDI库

时间:2015-10-29 11:49:02

标签: c++ static-libraries linker-errors unresolved-external

我使用VS2015使用FTDI MPSSE电缆制作简单的SPI接口。它们提供以下文件以用作其硬件的接口。

libMPSSE.a
libMPSSE.lib
libMPSSE.dll
libMPSSE.h
libMPSSE_spi.h

我正在使用一个简单的项目来尝试和初始化库并测试电缆。我已尝试链接.a和.lib,但它们都抛出以下错误

1>------ Build started: Project: SPI_interface, Configuration: Release Win32 ------
1>MSVCRT.lib(_secchk_.obj) : warning LNK4078: multiple '.drectve' sections found with different attributes (00100A00)
1>libMPSSE.a(ftdi_infra.o) : error LNK2001: unresolved external symbol _printf
1>C:\Users\Sammys\Documents\Visual Studio 2015\Projects\SPI_interface\Release\SPI_interface.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我也尝试从dll创建自己的.DEF和.lib,这会编译但会立即退出代码0x1。

这是链接器的详细输出。

1>------ Build started: Project: SPI_interface, Configuration: Release Win32 ------
1>
1>  Searching libraries
1>      Searching libMPSSE.a:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\kernel32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\user32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\gdi32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\winspool.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\comdlg32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\advapi32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\shell32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\ole32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\oleaut32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\uuid.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\odbc32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\odbccp32.lib:
1>      Searching C:\Program Files\Microsoft Visual Studio 14.0\VC\lib\msvcprt.lib:
1>      Searching C:\Program Files\Microsoft Visual Studio 14.0\VC\lib\MSVCRT.lib:
1>MSVCRT.lib(_secchk_.obj) : warning LNK4078: multiple '.drectve' sections found with different attributes (00100A00)
1>      Searching C:\Program Files\Microsoft Visual Studio 14.0\VC\lib\OLDNAMES.lib:
1>      Searching C:\Program Files\Microsoft Visual Studio 14.0\VC\lib\vcruntime.lib:
1>      Searching C:\Program Files\Windows Kits\10\lib\10.0.10150.0\ucrt\x86\ucrt.lib:
1>      Searching libMPSSE.a:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\kernel32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\user32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\gdi32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\winspool.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\comdlg32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\advapi32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\shell32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\ole32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\oleaut32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\uuid.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\odbc32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\odbccp32.lib:
1>      Searching C:\Program Files\Microsoft Visual Studio 14.0\VC\lib\msvcprt.lib:
1>      Searching C:\Program Files\Microsoft Visual Studio 14.0\VC\lib\MSVCRT.lib:
1>      Searching C:\Program Files\Microsoft Visual Studio 14.0\VC\lib\OLDNAMES.lib:
1>      Searching C:\Program Files\Microsoft Visual Studio 14.0\VC\lib\vcruntime.lib:
1>      Searching C:\Program Files\Windows Kits\10\lib\10.0.10150.0\ucrt\x86\ucrt.lib:
1>      Searching libMPSSE.a:
1>
1>  Finished searching libraries
1>
1>  Searching libraries
1>      Searching libMPSSE.a:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\kernel32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\user32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\gdi32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\winspool.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\comdlg32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\advapi32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\shell32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\ole32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\oleaut32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\uuid.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\odbc32.lib:
1>      Searching C:\Program Files\Windows Kits\8.1\lib\winv6.3\um\x86\odbccp32.lib:
1>      Searching C:\Program Files\Microsoft Visual Studio 14.0\VC\lib\msvcprt.lib:
1>      Searching C:\Program Files\Microsoft Visual Studio 14.0\VC\lib\MSVCRT.lib:
1>      Searching C:\Program Files\Microsoft Visual Studio 14.0\VC\lib\OLDNAMES.lib:
1>      Searching C:\Program Files\Microsoft Visual Studio 14.0\VC\lib\vcruntime.lib:
1>      Searching C:\Program Files\Windows Kits\10\lib\10.0.10150.0\ucrt\x86\ucrt.lib:
1>
1>  Finished searching libraries
1>libMPSSE.a(ftdi_spi.o) : error LNK2001: unresolved external symbol _printf
1>libMPSSE.a(ftdi_infra.o) : error LNK2001: unresolved external symbol _printf
1>C:\Users\Sammys\Documents\Visual Studio 2015\Projects\SPI_interface\Release\SPI_interface.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

令人沮丧的是,几年前我在2010年开始工作,但我不记得我做了什么。

为什么它没有找到printf函数?

编辑:更新。当我加载它时,库初始化函数似乎抛出了一个错误,因此它似乎只是退出。

../../Infra/src/ftdi_infra.c:261:Init_libMPSSE(): NULL expression encountered

我假设这与显然缺少的_printf函数有关?这是对的吗?

1 个答案:

答案 0 :(得分:0)

Visual Studio 2015编译遇到同样的问题,运行exe时出现以下错误:

../../Infra/src/ftdi_infra.c:261:Init_libMPSSE(): NULL expression encountered.

在使用Visual Studio 2013的其他计算机上运行正常,所以我刚刚在新的开发计算机上安装了2013版本。 之后,在运行Visual Studio 2015时,我将工具集从vs140(2015)更改为vs120(2013),一切都按预期工作。

最有可能是一种更简单的方法,但这对我有用。