我有一些使用一些共享库的代码(gcc上的c代码).编译时我必须使用-I和-L显式定义include和library目录,因为它们不在标准位置.当我尝试运行代码时,出现以下错误:
./sync_test
./sync_test: error while loading shared libraries: libsync.so: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
但是,执行以下操作,一切正常:
export LD_LIBRARY_PATH="/path/to/library/"
./sync_test
Run Code Online (Sandbox Code Playgroud)
现在,奇怪的是,这只能工作一次.如果我再次尝试运行sync_test,除非我先运行export命令,否则会得到相同的错误.我尝试将以下内容添加到我的.bashrc中,但它没有区别:
LD_LIBRARY_PATH="/path/to/library/"
Run Code Online (Sandbox Code Playgroud) 我读了这些主题:
使用 gcc 在 Linux 上运行线程构建模块 (Intel TBB)
无法将英特尔 TBB 库与 /usr/lib 中的 libtbb 链接
但仍然收到此错误:
piCalc.cpp:8:17: fatal error: ttb.h: No such file or directory
#include "ttb.h"
Run Code Online (Sandbox Code Playgroud)
我计算 pi 的代码始于
#include <iostream>
#include "ttb.h"
#include "parallel_for.h"
Run Code Online (Sandbox Code Playgroud)
运行安装了 nvidia 和 cuda 的 Ubuntu 14.04。为了安装 TBB,我从以下开始:
sudo apt-get install libtbb-dev
Run Code Online (Sandbox Code Playgroud)
它说
Reading package lists... Done
Building dependency tree
Reading state information... Done
libtbb-dev is already the newest version.
The following package was automatically installed and is no …Run Code Online (Sandbox Code Playgroud)