链接到Windows机器上的libnfc

时间:2012-06-23 18:06:36

标签: c# dll nfc

我成功地将libnfc与GNU / Linux和C / C ++一起使用。现在我需要在Windows下编写一个 bridge 库,这样我就可以轻松地使用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 \ n ncc_access&gt; 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 \ n \ n \ nfc_access&gt;文件bar_dll.dll lib_bar_dll.a bar_dll.dll;用于MS Windows(DLL)(控制台)Mono / .Net程序集的PE32 +可执行文件 lib_bar_dll.a;当前的档案

我无法链接此dll!但是“Mono / .Net”在这种背景下意味着什么呢?这是本机代码!

1 个答案:

答案 0 :(得分:0)

解决!

C:\Users\peter\nfc_access>g++ -o touchatag_bridge.dll touchatag_bridge.cpp -Wl,--out-implib,touchata
g_bridge.a -Llibnfc_build\libnfc -llibnfc -m32 -shared
Creating library file: touchatag_bridge.a

选项 -m32 解决了它 - horray!