【发布时间】:2016-11-15 14:38:00
【问题描述】:
我尝试从单独的项目中调用 pylon5 C++ 库,但没有成功。
我一直在寻找答案,但无法弄清楚我做错了什么。
我想我的问题可能在于设置环境变量和/或库路径? (我是基于 Linux 的初学者,在网上阅读教程时,我很容易对一些明显的东西感到困惑?我应该做的事情?知道但我不知道)
我已经测试过相机本身可以与我的 Raspberry 一起使用,并且我可以使用示例代码来抓取图像。
我什至可以修改相机设置(曝光时间等)并拍照并将它们保存到我的 SD 卡中。所以摄像头模块不是问题。我的问题更有可能以正确的方式使用共享库。
此外,我还制作了一些简单的共享库,希望随后可以使用这些库中的 Pylon 相机代码。当我的库中不包含任何 Pylon 代码时,它可以正常工作并返回我想要的值。我什至可以在那里添加 Pylon 标头,它仍然可以正常编译。然后我可以再次从另一个(在本例中为 C#)代码中调用我的库并按预期获取返回值,但是当尝试在那里(在我的库中)调用任何 Pylon 代码时,它将导致“dllNotFoundException”。
按照我从 baslerweb.com 获得的手册中的建议,我已将 pylon5 代码放入 /opt/pylon5
http://s.baslerweb.com/media/documents/How%20to%20build%20pylon%20applications%20on%20Raspberry%20Pi.pdf
这是我的项目文件(我正在使用 QtCreator)
#-------------------------------------------------
QT -= gui
QT += core
TARGET = baslercamera
TEMPLATE = lib
DEFINES += BASLERCAMERA_LIBRARY
SOURCES += baslercamera.cpp \
Grab.cpp \
Image.cpp \
main.cpp \
BaslerDLL.cpp
HEADERS += baslercamera.h\
baslercamera_global.h \
Image.h \
Grab.h
unix {
target.path = /usr/lib
INSTALLS += target
}
#INCLUDEPATH += $$PWD/../pylon5/include
#DEPENDPATH += $$PWD/../pylon5/include
INCLUDEPATH += /opt/pylon5/include
DEPENDPATH += /opt/pylon5/include
INCLUDEPATH += /home/pi/baslercamera/
DEPENDPATH += /home/pi/baslercamera/
LIBS += "/opt/pylon5/lib" \
-lpylonc
正如您所见,INCLUDEPATH 和 LIBS 变量是我的弱点。我不知道我应该在那里包含哪些库以及如何正确包含它们。除了将它们包含在我的项目文件中之外,我还应该设置一些环境变量吗?
我也尝试设置一些库路径,但我真的不知道我应该在那里做什么。用户手册上说
Set the pylon environment variables:
# source ./pylon4/bin/pylon-setup-env.sh pylon4
然后我将 pylon4 替换为 pylon5。我认为这可能会将环境变量设置为使用 pylon 库。但我不确定那里会发生什么。 pylon 5 指南说:
Environment Variables
=====================
From pylon 5.0 upwards, no additional environment variables are required to
run pylon-based applications.
For development, though, the compiler must know where pylon is installed.
The pylon samples use the environment variable PYLON_ROOT to find the relevant information.
For your convenience, we created the pylon-setup-env.sh script located in the
pylon5/bin directory which can carry out the complete setup.
To setup the environment for a pylon installation in <path> execute:
source <path>/bin/pylon-setup-env.sh <path>
If you want the environment for the standard installation to be persistent, you
can add
source /path/to/your/pylon5/bin/pylon-setup-env.sh /path/to/your/pylon5
to ~/.bashrc
For special use cases, you can do a manual environment setup as follows:
export PYLON_ROOT=/path/to/your/pylon5
Even though there is currently only one variable needed, using pylon-setup-env.sh
is still the preferred way to set up your environment, as we might add more variables
in the future.
我已经以多种方式尝试过它,我很乐意获得任何帮助或建议,以便继续在我自己的库中使用这些共享库。
【问题讨论】:
标签: c++ camera shared-libraries raspberry-pi2