【Ubuntu Balser TOF】在一台新的电脑上,想要测试一下Basler 的TOF相机,安装好TOF的SDK之后(在这台电脑上我还装了pylon5),编译自己的程序发现出现下面的报错:
Failed to load the producer file ProducerTOF.cti: /opt/pylon5/lib64/gentlproducer/gtl/ProducerTOF.cti: cannot open shared object file: No such file or directory
BaslerToF的包含目录和库目录设置都没问题,这个错是加载这个.cti文件路径不对导致的。
我看了一下SDK里加载这个文件的代码位置(/opt/BaslerToF/include/ConsumerImplHelper/ProducerProxy.h 244行):
template
void CProducerProxy::Init(const char* dllname)
{
bool loaded = false;
std::string strDllName(dllname);
const bool isGenICamTLPathSet = ! GetGenicamGenTLPath().empty();
const bool nameContainsSeparator = strDllName.find('/') != std::string::npos || strDllName.find('\\') != std::string::npos;
// If there is a path separator in dllname we are going to ignore the GENICAM_GENTL_PATH. We directly try to load the module.
// Also directly load the module if there is no GENICAM_GENTL_PATH is set.
if ( nameContainsSeparator || ! isGenICamTLPathSet)
{
#ifdef CIH_WIN_BUILD
if ( ! nameContainsSeparator )
{
// Assume that the producer is located in the directory indicated by the BASLER_TOF_BIN/BASLER_TOF_BIN64 environment variable
#pragma warning(push, 1)
#pragma warning(disable: 4996)
#if CIH_WORDSIZE == 64
const char* szBaslerTofBinDir = getenv("BASLER_TOF_BIN64");
#else
const char* szBaslerTofBinDir = getenv("BASLER_TOF_BIN");
#endif#if CIH_WORDSIZE == 64
#endif // endif#pragma warning(pop)
if ( NULL != szBaslerTofBinDir)
{
std::string strBinDir( szBaslerTofBinDir );
if ( *strBinDir.rbegin() != '\\' && *strBinDir.rbegin() != '/' )
{
strBinDir += "\\";
}
#if CIH_WORDSIZE == 64
strBinDir += "x64\\";
#else
strBinDir += "win32\\";
#endif
strDllName = strBinDir + strDllName;
}
}
#endif
m_pProducerLib = new Internal::CDynamicLib();
loaded = m_pProducerLib->Load( strDllName.c_str() );
}
else
{
// Iterate over all entries in GENICAM_GENTL_PATH and try to load the desired module from there
#if defined CIH_WIN_BUILD
const char* delimiter = ";
";
#else
const char* delimiter = ":";
#endif
std::list lstPathEntries = Tokenize( GetGenicamGenTLPath(), delimiter );
for (std::list::const_iterator it = lstPathEntries.begin();
it != lstPathEntries.end() && ! loaded;
++it )
{
std::string strFullPath = *it;
if ( *strFullPath.rbegin() != '\\' && *strFullPath.rbegin() != '/' )
strFullPath += CIH_PATH_SEPARATOR;
strFullPath += strDllName;
m_pProducerLib = new Internal::CDynamicLib();
loaded = m_pProducerLib->Load( strFullPath.c_str() );
}
}if (!loaded)
{
std::ostringstream s;
throw RUNTIME_EXCEPTION( static_cast(s << "Failed to load the producer file " << dllname << ": " << m_pProducerLib->GetLastErrorMsg() ).str());
}
应该是:GetGenicamGenTLPath()将gentl位置定位到pylon5文件下了。
解决方案:设置正确的GENICAM_GENTL_PATH (/opt/BaslerToF/lib64/gentlproducer/gtl)
或者向我一样偷懒(不推荐),修改代码:
strFullPath = "/opt/BaslerToF/lib64/gentlproducer/gtl/";
strFullPath += strDllName;
m_pProducerLib = new Internal::CDynamicLib();
loaded = m_pProducerLib->Load( strFullPath.c_str() );
推荐阅读
- 个人日记|K8s中Pod生命周期和重启策略
- 学习分享|【C语言函数基础】
- C++|C++浇水装置问题
- 数据结构|C++技巧(用class类实现链表)
- C++|从零开始学C++之基本知识
- 步履拾级杂记|VS2019的各种使用问题及解决方法
- leetcode题解|leetcode#106. 从中序与后序遍历序列构造二叉树
- 动态规划|暴力递归经典问题
- 麦克算法|4指针与队列
- 遇见蓝桥遇见你|小唐开始刷蓝桥(一)2020年第十一届C/C++ B组第二场蓝桥杯省赛真题