有一个使用OpenCV的简单计算机视觉应用程序。我在主机系统上编译它而不是部署到NVidia Jetson TK1(这里没问题,我使用配置套件的Qt Creator)。我使用sshfs
将Jetson的文件系统root挂载到托管/mnt/sysroot_tegra_tk1
。
问题:我刚刚在Jetson上编译了OpenCV 3.2版(已安装到主板/usr/local/lib
中)。 /usr/local
中仍然存在系统OpenCV 2.4版。我不知道如何在主机系统上配置qmake以交叉编译和链接新版本而不是Jetson的系统默认值。
我的.pro文件:
QT += core
QT -= gui
CONFIG += c++11
TARGET = markerExtractionChromakey
CONFIG += console
CONFIG -= app_bundle
unix: INCLUDEPATH += /usr/local/include
unix: QMAKE_LIBDIR = /usr/local/lib
unix: LIBS += -lopencv_imgproc\
-lopencv_core.so\
-lopencv_video\
-lopencv_highgui\
-lopencv_gpu
TEMPLATE = app
HEADERS += cameraworker.h
SOURCES += main.cpp \
cameraworker.cpp
target.path = /home/ubuntu/alan/markerExtractionChromakey
target.files += markerExtractionChromakey
INSTALLS += target
项目链接输出:
/usr/bin/arm-linux-gnueabihf-g++ -Wl,-rpath-link,/mnt/sysroot_tegra_tk1/usr/lib
-Wl,-rpath-link,/mnt/sysroot_tegra_tk1/usr/lib/arm-linux-gnueabihf
-Wl,-rpath-link,/mnt/sysroot_tegra_tk1/lib/arm-linux-gnueabihf -mfloat-abi=hard
--sysroot=/mnt/sysroot_tegra_tk1 -Wl,-rpath,/usr/local/qt5/lib
-o markerExtractionChromakey main.o cameraworker.o -L/usr/local/lib
-lopencv_imgproc -lopencv_core -lopencv_video -lopencv_highgui
-lopencv_gpu -L/opt/qt5_for_tegra/qt-everywhere-opensource-src-5.5.1/qtbase/lib
-lQt5Core -L/mnt/sysroot_tegra_tk1/usr/lib
-L/mnt/sysroot_tegra_tk1/lib/arm-linux-gnueabihf
-L/mnt/sysroot_tegra_tk1/usr/lib/arm-linux-gnueabihf -lpthread
答案 0 :(得分:0)
问题解决了。关键时刻:
-rpath/-rpath-link
来告诉链接器在哪里寻找。 -rpath
中指定的Jetson的默认<path to Qt>/qt-everywhere-opensource-src-5.5.1/qtbase/mkspecs/devices/linux-jetson-tk1-g++/qmake.conf
位置。只需在默认目录之前添加您的目录:
QMAKE_INCDIR += \
$$[QT_SYSROOT]/usr/local/include \
$$[QT_SYSROOT]/usr/include \
$$[QT_SYSROOT]/usr/include/arm-linux-gnueabihf
QMAKE_LIBDIR += \
$$[QT_SYSROOT]/usr/local/lib \
$$[QT_SYSROOT]/usr/lib \
$$[QT_SYSROOT]/lib/arm-linux-gnueabihf \
$$[QT_SYSROOT]/usr/lib/arm-linux-gnueabihf
QMAKE_LFLAGS += \
-Wl,-rpath-link,$$[QT_SYSROOT]/usr/local/lib \
-Wl,-rpath-link,$$[QT_SYSROOT]/usr/lib \
-Wl,-rpath-link,$$[QT_SYSROOT]/usr/lib/arm-linux-gnueabihf \
-Wl,-rpath-link,$$[QT_SYSROOT]/lib/arm-linux-gnueabihf