我成功地将 libnfc 与 GNU/Linux 和 C/C++ 一起使用。现在我需要在Windows下编写一个桥接库,这样我就可以很容易地用C#访问libnfc。简而言之:
我无法链接libnfc.dll。
#include <iostream>
#include "libnfc_read_only\include\nfc\nfc.h"
using namespace std;
int main() {
cout << nfc_version() << "\n";
return 0;
}
C:\Users\peter\nfc_access>x86_64-w64-mingw32-g++ -o test test.cpp -Llibnfc_build\libnfc -llibnfc
C:\Users\peter\nfc_access>x86_64-w64-mingw32-g++ -o test test.cpp -Llibnfc_build\libnfc -llibnfc
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.6.1/../../../../x86_64-w64-mingw32/bin/ld.exe: skippi
ng incompatible libnfc_build\libnfc/libnfc.dll.a when searching for -llibnfc
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.6.1/../../../../x86_64-w64-mingw32/bin/ld.exe: skippi
ng incompatible libnfc_build\libnfc/libnfc.dll when searching for -llibnfc
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.6.1/../../../../x86_64-w64-mingw32/bin/ld.exe: skippi
ng incompatible libnfc_build\libnfc/libnfc.dll.a when searching for -llibnfc
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.6.1/../../../../x86_64-w64-mingw32/bin/ld.exe: skippi
ng incompatible libnfc_build\libnfc/libnfc.dll when searching for -llibnfc
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.6.1/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot
find -llibnfc
collect2: ld returned 1 exit status
当我尝试将我的 dll 与此链接时,也会发生同样的情况。
C:\Users\peter\nfc_access>file libnfc_build/libnfc/libnfc.*
libnfc_build/libnfc/libnfc.dll; PE32 executable for MS Windows (DLL) (console) Intel 80386 32-bit
libnfc_build/libnfc/libnfc.dll.a; current ar archive
我做错了什么?
// 编辑 C:\Users\peter\nfc_access>file bar_dll.dll lib_bar_dll.a bar_dll.dll; 适用于 MS Windows (DLL) 的 PE32+ 可执行文件(控制台)Mono/.Net 程序集 lib_bar_dll.a;当前的 ar 档案
我无法链接到这个 dll!但是在这种情况下,“Mono/.Net”是什么意思?这是本机代码!