gpt4 book ai didi

bash - Qt没有找到bash中设置的环境变量

转载 作者:行者123 更新时间:2023-12-04 18:47:39 33 4
gpt4 key购买 nike

我有一台相机,我正在连接它,认为它有自己的 API。为了获得工作代码,相机手册建议将这些环境变量添加到系统中。

我在/etc/bash.bashrc 中设置了以下内容

    export PYLON_ROOT=/opt/pylon3
export GENICAM_ROOT_V2_3=${PYLON_ROOT}/genicam

mkdir -p $HOME/genicam_xml_cache
export GENICAM_CACHE_V2_3=$HOME/genicam_xml_cache

export LD_LIBRARY_PATH=${PYLON_ROOT}/lib64:${GENICAM_ROOT_V2_3}/bin/Linux64_x64:${GENICAM_ROOT_V2_3}/bin/Linux64_x64/GenApi/Generic:$LD_LIBRARY_PATH

当我从终端运行我的 qt 代码时,代码运行没有任何错误。但是当我从 Qtcreator 运行它时,它会给我以下错误并终止程序!

Environment Variable 'GENICAM_ROOT_V2_3' not found

我也将环境变量代码添加到/etc/profile 但结果是一样的。为什么 Qtcreator 找不到我的变量?

.pro
QT       += core

QT += gui

INCLUDEPATH += /opt/pylon3/include \
/opt/pylon3/genicam/library/CPP/include
LIBS += -L/opt/pylon3/lib64 \
-L/opt/GenICam_v2_3/bin/Linux64_x64 \
-L/opt/GenICam_v2_3/bin/Linux64_x64/GenApi/Generic \
-lgxapi \
-lpylonbase \
-lpylonbase-3.2.0 \
-lpylongigesupp \
-lpylonutility \
-lGCBase_gcc40_v2_3 \
-lGenApi_gcc40_v2_3 \
-llog4cpp_gcc40_v2_3 \
-lLog_gcc40_v2_3 \
-lMathParser_gcc40_v2_3 \
-lXerces-C_gcc40_v2_7 \
-lXMLLoader_gcc40_v2_3


TARGET = VLPR
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app


CONFIG += link_pkgconfig
PKGCONFIG += opencv

主窗口.cpp
 MainWindow::MainWindow(QObject *parent) :QObject(parent)
{
Initialize_Cam();
}
void MainWindow::Initialize_Cam()
{
MonoCamThr = new MonoCamThread(this);
MonoCamThr->Stop_Disp = true;
MonoCamThr->start();
MonoCamThr->Stop_Disp = false;
}

Monocam.cpp
MonoCamThread::MonoCamThread(QObject *parent) :
QThread(parent)
{
try
{
// List of cameras
DeviceInfoList_t m_Devices; // Still empty

// Create the unique transport layer factory object
// ... create the transport layer object
// ... create and initialise Cameras
CTlFactory& TlFactory = CTlFactory::GetInstance();
ITransportLayer *pTl = TlFactory.CreateTl( Camera_t::DeviceClass() );
if ( ! pTl )
{
throw GenericException(
"Failed to create transport layer!", __FILE__, __LINE__);
}

// Get all attached cameras and exit if no camera is found
m_Devices.clear();
if ( 0 == pTl->EnumerateDevices( m_Devices ) )
{
throw GenericException(
"No camera present!", __FILE__, __LINE__);
}
if(m_Devices.size()<2)
{
while(1)
{
qDebug() << "Number of Cameras are less than 2 .... \n" ;
}
}

qDebug() << "Number of Cameras are: "<<m_Devices.size()<<" \n" ;
// Restrict number of used camera
size_t nCameras = 2;

// Create all camera devices and set up the grab threads

if(pTl->CreateDevice( m_Devices[0])->GetDeviceInfo().GetModelName())
MonoCamera = new Camera_t( pTl->CreateDevice( m_Devices[1]) );


MonoCamera->Open();

MonoCamera->PixelFormat.SetValue( PixelFormat_Mono8 );
MonoCamera->OffsetX.SetValue( 0 );
MonoCamera->OffsetY.SetValue( 0 );
MonoCamera->Width.SetValue( MonoCamera->Width.GetMax() );
MonoCamera->Height.SetValue( MonoCamera->Height.GetMax() );
}
catch( GenericException &e )
{
qDebug() << "**** An exception occurred! Desription is: " << "\n"<< " " << e.GetDescription() << "\n";
}

}

void MonoCamThread::run()
{
while(!Stop_Disp)
{
//since this part of code never runs I didn' put the code for it ....
}
}

还有其他 cpp 文件,但它们在相机初始化后运行。六个月前,我通过将 GENICAM_ROOT_V2_3 PATH 位置添加到 ubuntu 中的系统文件(如 .bashrc 或 .profile)来修复此错误,但我现在不记得文件名了! :((

附言
不要忘记这段代码在终端中运行并且工作正常......唯一的问题是Qt没有找到指定的变量位置!

谢谢

最佳答案

我正在使用带有类似凸轮的 Qt。我已经设置了“运行设置”,就像你在这张图片中看到的那样。

enter image description here

关于bash - Qt没有找到bash中设置的环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23052991/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com