我一直試圖在過去的16個小時內將libusb庫附加到Qt項目中,但沒有取得太大的成功。我很感激任何關於此事的意見,這讓人感到沮喪。將libusb庫添加到osx中的Qt項目
的pro文件是這樣的:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
INCLUDEPATH +=/usr/local/include/libusb-1.0
LIBS += -L/usr/local/lib -libusb-1.0.a
LIBS += -L<libusb.h>
源代碼:
#include <iostream>
#include <libusb.h>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
編譯器輸出:
13:01:50: Running steps for project lallala...
13:01:50: Configuration unchanged, skipping qmake step.
13:01:50: Starting: "/usr/bin/make" -w
make: Entering directory `/Users/MAXIMUS/Documents/workspace/lallala-build-Desktop_Qt_5_0_0_clang_64bit_SDK-Debug'
/Users/MAXIMUS/Qt5.0.0/5.0.0/clang_64/bin/qmake -spec macx-g++42 CONFIG+=debug CONFIG+=x86_64 CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile ../lallala/lallala.pro
make: Leaving directory `/Users/MAXIMUS/Documents/workspace/lallala-build-Desktop_Qt_5_0_0_clang_64bit_SDK-Debug'
make: Entering directory `/Users/MAXIMUS/Documents/workspace/lallala-build-Desktop_Qt_5_0_0_clang_64bit_SDK-Debug'
g++-4.2 -headerpad_max_install_names -mmacosx-version-min=10.6 -o lallala main.o -L/usr/local/lib -libusb-1.0.a -L<libusb.h>
/bin/sh: -c: line 0: syntax error near unexpected token `newline'
/bin/sh: -c: line 0: `g++-4.2 -headerpad_max_install_names -mmacosx-version-min=10.6 -o lallala main.o -L/usr/local/lib -libusb-1.0.a -L<libusb.h> '
make: *** [lallala] Error 2
make: Leaving directory `/Users/MAXIMUS/Documents/workspace/lallala-build-Desktop_Qt_5_0_0_clang_64bit_SDK-Debug'
13:01:50: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project lallala (kit: Desktop Qt 5.0.0 clang 64bit (SDK))
When executing step 'Make'
嗨,約翰。你不能只使用[pkg-config](https://qt.gitorious.org/qt/qtserialport/source/6e75610dff5fb96ebd72cfb40ba7cbfea4bd21b7:src/serialport/serialport-lib.pri#L11)嗎?這就是我們在QtSerialPort中所做的,儘管確保它不是「本地」安裝。如果沒有,你是否檢查了[這個鏈接](http://www.yoctopuce.com/EN/article/how-to-use-us-b-devices-from-qt-framework)? – lpapp
拉斯洛你好,感謝您的意見和鏈接。我只是找到了一種通過GUI添加庫的方法,我會看看這是否適合我。 –
嘿!選擇了答案,對此感到抱歉;) –