博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
windows上怎么用libnfc的库函数编程
阅读量:5094 次
发布时间:2019-06-13

本文共 2051 字,大约阅读时间需要 6 分钟。

根据libnfc的说明文档,我在win7上装了
libnfc-1.7.0-rc6.Zip

MinGW64
libusb-win32-bin-1.2.6.0
CMake -2.8.10-win32-x86

 

然后用mingw32-make命令编译成功,并产生了libnfc.dll文件,并且能够顺利运行nfc-list.exe等例子。

但是我想问一下,如果我想自己写一个.c文件,我该如何调用libnfc的头文件库和函数库编译它呢?

 

//test.cpp

#include <iostream>

#include "libnfc_read_only\include\nfc\nfc.h"

using namespace std;

 

int main() {

    cout << nfc_version() << "\n";

    return 0;

}

 

我用 gcc -o test test.cpp -lnfc 命令编译,会报错说找不到头文件。我将之前编译成功的libnfc.dll文件放在同一目录下,仍然报错。

求指导:-)

 

I got it!

Thanks a lot for yobibe's help. I finally compiled it successfully, the steps are as follow:

Before that, I'll describe my files and directories:
The operating system is windows 7-32bit.

E:.

├─libnfc-1.7.0-rc6
│  ├─cmake
│  ├─contrib
│  ├─examples
│  ├─include
│  ├─libnfc
│  ├─libusb
│  ├─m4
│  ├─test
│  └─utils
│      ├─nfc-list.c
│      ├─CmakeList.txt
│      └─test.c
└─nfc_built
     ├─utils
     │  ├─nfc-list.exe
     │  └─libnfc.dll
     ├─libnfc
     │  └─libnfc.dll
     │
     └─(and so on)

when the operation "Cmake-->mingw32-make" achieved, copy the E:\nfc_built\libnfc\libnfc.dll to E:\nfc_built\utils, and then open the cmd.exe window:

C:\Users\WangYong> cd :e\libnfc\nfc_built\utils

e\libnfc\nfc_built\utils> nfc-list.exe

nfc-list.exe will run and then print the result.

If you write a program by yourself, for example:

//test.c
#include <stdio.h>
#include <nfc\nfc.h>
int main()
{
    printf("%s",nfc_version());
    return 0;
}
Next you should put the test.c in the E:\libnfc\libnfc-1.7.0-rc5\utils, and modify the CmakeList.txt which is under the same directory(E:\libnfc\libnfc-1.7.0-rc5\utils) by adding the "test" to CmakeList.txt:
SET(UTILS-SOURCES 
  nfc-emulate-forum-tag4
  nfc-list
  nfc-mfclassic
  nfc-mfultralight
  nfc-read-forum-tag3
  nfc-relay-picc
  nfc-scan-device
  test
)

Finally, do the mingw32make again, and then you will see the test.exe under E:\libnfc\nfc_built\utils. Run it:

E:\libnfc\nfc_built\utils> test.exe

ok! The version of libnfc will be printed on the cmd screen. You can also compile and run the quick_start_example1.c by this way. Good luck!

转载于:https://www.cnblogs.com/duanguyuan/archive/2013/03/11/2953923.html

你可能感兴趣的文章
iOS archive(归档)的总结 (序列化和反序列化,持久化到文件)
查看>>
python第九天课程:遇到了金角大王
查看>>
字符串处理
查看>>
ECharts(Enterprise Charts 商业产品图表库)初识
查看>>
LeetCode Factorial Trailing Zeroes (阶乘后缀零)
查看>>
hdu 5402 Travelling Salesman Problem (技巧,未写完)
查看>>
[AIR] 获取U盘,打开U盘
查看>>
git 常用命令
查看>>
js之事件冒泡和事件捕获详细介绍
查看>>
C# 如何实现记住密码功能
查看>>
some blogs for xna 3d game for windows phone!
查看>>
灰度变换——反转,对数变换,伽马变换,灰度拉伸,灰度切割,位图切割
查看>>
Freemodbus 1.5
查看>>
Word字体与像素的对应关系(转)
查看>>
uip UDP 服务器广播模式(客户端可以任意端口,并且主动向客户端发送数据) (转)...
查看>>
一次SQLSERVER触发器编写感悟
查看>>
记一次线上Zabbix对Redis监控实录
查看>>
English trip -- VC(情景课)2 C Where's my pencli?
查看>>
HtmlUnitDriver 网页内容动态抓取
查看>>
django url 路由设置技巧
查看>>