如何在 macOS 上的 Qt qamke 项目中使用 libnfc

问题描述 投票:0回答:1

我有一个 Qt 项目 (QMAKE),可以在我的 Raspberry Pi 操作系统上完美运行。

我希望能够在 MacBook 上运行相同的项目。该项目有效,但当我包含 libnfc 时,我收到链接器错误:

:-1: error: Undefined symbols:

我已经从 GitHub 安装了 libnfc,并且可以成功编译并运行示例(例如 npc-poll.c)。虽然他们是纯C,而我的代码是C++。

main.cpp:

#include "mainwindow.h"
#include <QApplication>

#include <nfc/nfc.h>

int main(int argc, char *argv[])
{

    printf("TEST");
    const char *acLibnfcVersion = nfc_version();
    printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
    return 1;


    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

我更新了我的 .pro 文件以包含以下内容:

INCLUDEPATH += /usr/local/include
LIBS += -L/usr/local/lib -lnfc

lib文件夹下有一个libnfc.dylib和一个libnfc.a,所以我实在搞不懂这里出了什么问题。

我也尝试过用brew安装libnfc。

我还在.pro文件中尝试了不同的设置,例如

QMAKE_CXXFLAGS += -std=c++11
QMAKE_LFLAGS += -L/usr/local/lib -lnfc

我也收到此警告:

:-1: warning: ignoring file '/usr/local/lib/libnfc.6.dylib': found architecture 'arm64', required architecture 'x86_64'
c++ macos qt qmake lib-nfc
1个回答
0
投票

好吧,我找到了一个解决方法。我使用的是 Qt5,当我切换到 Qt6 时,它开箱即用。 所以现在已经解决了

© www.soinside.com 2019 - 2024. All rights reserved.