如何处理Makefile以合并两个单独的程序(How to handle Makefiles to merge two separate programs)

编程入门 行业动态 更新时间:2024-10-28 16:22:16
如何处理Makefile以合并两个单独的程序(How to handle Makefiles to merge two separate programs)

我正在尝试使用:

http://nfc-tools.org/index.php?title=Nfc-eventd和https://code.google.com/p/libfreefare/

创建一个使用这两个代码的新程序。

我已经开始复制并粘贴mifare-classic-read-ndef.c (从libfreefare)到nfc-eventd.c ,当我运行make我得到了预期的错误:

... make[3]: Entering directory `/home/kapcom01/temp/nfc-eventd/src' CCLD nfc-eventd nfc-eventd.o: In function `main': /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:380: undefined reference to `freefare_get_tags' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:387: undefined reference to `freefare_get_tag_type' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:395: undefined reference to `freefare_get_tag_uid' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:398: undefined reference to `freefare_get_tag_friendly_name' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:407: undefined reference to `mifare_classic_connect' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:470: undefined reference to `freefare_free_tags' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:414: undefined reference to `mad_read' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:418: undefined reference to `mad_nfcforum_aid' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:418: undefined reference to `mifare_classic_nfcforum_public_key_a' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:418: undefined reference to `mifare_application_read' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:422: undefined reference to `tlv_decode' collect2: error: ld returned 1 exit status make[3]: *** [nfc-eventd] Error 1 make[3]: Leaving directory `/home/kapcom01/temp/nfc-eventd/src' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/kapcom01/temp/nfc-eventd/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/kapcom01/temp/nfc-eventd' make: *** [all] Error 2

显然我必须以某种方式链接freefare.h和freefare.h所有其他源文件,但我无法弄清楚如何...

只需#include "freefare.h"并将文件复制粘贴到同一目录中就行不通了。

I am trying to use:

http://nfc-tools.org/index.php?title=Nfc-eventd and https://code.google.com/p/libfreefare/

to create a new program that make use of code from both of these.

I have started with copy and pasting code from mifare-classic-read-ndef.c (from libfreefare) to nfc-eventd.c and when I run make I get the expected errors:

... make[3]: Entering directory `/home/kapcom01/temp/nfc-eventd/src' CCLD nfc-eventd nfc-eventd.o: In function `main': /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:380: undefined reference to `freefare_get_tags' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:387: undefined reference to `freefare_get_tag_type' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:395: undefined reference to `freefare_get_tag_uid' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:398: undefined reference to `freefare_get_tag_friendly_name' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:407: undefined reference to `mifare_classic_connect' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:470: undefined reference to `freefare_free_tags' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:414: undefined reference to `mad_read' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:418: undefined reference to `mad_nfcforum_aid' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:418: undefined reference to `mifare_classic_nfcforum_public_key_a' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:418: undefined reference to `mifare_application_read' /home/kapcom01/temp/nfc-eventd/src/nfc-eventd.c:422: undefined reference to `tlv_decode' collect2: error: ld returned 1 exit status make[3]: *** [nfc-eventd] Error 1 make[3]: Leaving directory `/home/kapcom01/temp/nfc-eventd/src' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/kapcom01/temp/nfc-eventd/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/kapcom01/temp/nfc-eventd' make: *** [all] Error 2

Obviously I have to link somehow the freefare.h and all the other source files of libreefare but I cant figure out how..

Just #include "freefare.h" and copy-paste the files into the same directory didn't work.

最满意答案

您是否尝试通过将库代码的各个部分直接复制到程序中来使用NFC库? 我不明白这是怎么回事。 您需要做的是(a)为您的平台构建库或下载预编译版本,(b)阅读有关库提供的API的文档,并在代码中使用该API,以及(c)编译程序时,链接库,可能通过添加-lfreefare或类似于Makefile中的链接行。 (图书馆的文档可能也应该告诉你如何做到这一点。)

Are you trying to use an NFC library by copying pieces of the library code directly into your program? I don't see how that could work. What you need to do is (a) build the library or download a precompiled version for your platform, (b) read the documentation regarding the API the library offers, and use that API in your code, and (c) when compiling your program, link with the library, possibly by adding -lfreefare or something similar to the link line in your Makefile. (The library's documentation should probably tell you how to do this as well.)

更多推荐

本文发布于:2023-08-07 19:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465713.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何处理   两个   程序   Makefile   handle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!