为什么qmake不包含库文件?

时间:2018-04-05 02:25:47

标签: qt qmake

我正在尝试将第三方库链接到我的Qt项目。这是我的.pro文件:

TEMPLATE = app
TARGET = camera_ui

QMAKE_LFLAGS += -Wl --enable-new-dtags -Wl -rpath /opt/pylon5/lib64
INCLUDEPATH += -I/opt/pylon5/include

LIBS += -L/opt/pylon5/lib64 -Wl -E \
       -lpylonbase \
       -lpylonutility \
       -lGenApi_gcc_v3_0_Basler_pylon_v5_0 \
       -lGCBase_gcc_v3_0_Basler_pylon_v5_0 \
       -lopencv_core \
       -lopencv_highgui

# Input
HEADERS += basler_opencv_utils.h camera_interface.h mainwindow.h
FORMS += mainwindow.ui
SOURCES += basler_opencv_utils.cc main.cpp mainwindow.cpp

但是这是运行qmake然后make后的输出。

g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I-I/opt/pylon5/include -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o basler_opencv_utils.o basler_opencv_utils.cc
basler_opencv_utils.cc:5:33: fatal error: pylon/PylonIncludes.h: No such file or directory
compilation terminated.
Makefile:373: recipe for target 'basler_opencv_utils.o' failed
make: *** [basler_opencv_utils.o] Error 1

请注意,INCLUDE_PATH可以正常工作,但LIBS和QMAKE_LFLAGS不包含在构建命令中。我查看了thisthis但这些并没有解决我的问题。我也尝试按此question添加TARGETDEPS += libpylonbase.so,但没有任何更改。

我也尝试使用Qt Creator为我制作.pro文件,但我无法弄清楚我应该在“库文件”字段中输入向导。

更新:我能够从以下部分获得一些帮助。如果其他人试图使用带有QT5的Basler Pylon SDK,那么这是一个有效的make文件(包括OpenCV)。

QT += core gui widgets

TEMPLATE = app
TARGET = camera_ui
PYLON_ROOT = /opt/pylon5
# Input
HEADERS += basler_opencv_utils.h camera_interface.h mainwindow.h
FORMS += mainwindow.ui
SOURCES += basler_opencv_utils.cc main.cpp mainwindow.cpp

QMAKE_CPPFLAGS += /opt/pylon5/include
QMAKE_CXXFLAGS += -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable
QMAKE_LFLAGS_RPATH += -Wl,--enable-new-dtags -Wl,-rpath,/opt/pylon5/lib64

INCLUDEPATH += /opt/pylon5/include
INCLUDEPATH += /opt/pylon5/lib64

LIBS += /opt/pylon5/lib64 -Wl,-E -lpylonbase -lpylonutility -lGenApi_gcc_v3_0_Basler_pylon_v5_0 -lGCBase_gcc_v3_0_Basler_pylon_v5_0
LIBS += -lopencv_core -lopencv_highgui 

1 个答案:

答案 0 :(得分:2)

  1. 不,您的var oldURL = document.referrer; alert(oldURL);无效。您的包含INCLUDEPATH已解析为INCLUDEPATH += -I/opt/pylon5/include正确(-I-I/opt/pylon5/include)且该目录无效。必须从-I/opt/pylon5/include移除-I。标题文件INCLUDEPATH应位于PylonIncludes.h

  2. 包含库的正确路径是

    /opt/pylon5/include/pylon/PylonIncludes.h - 如果找不到库,编译器会抛出错误。

    LIBS += -L"/home/directory" -lmylibrary -mylibrary2无效,可能会在LIBS += -L/opt/pylon5/lib64 -Wl -E \

  3. 之后截断库
  4. 您的链接器标志:-WL -E \是正确的。 QMAKE_LDFLAGS等等。为什么你不在g ++命令行中看到它?它是编译器而不是链接器,你之前就错了。