我想在eclipse中导入库,但我不能这样做。我知道有很多线索已经讨论过这个问题,但我无法解决这些问题。所以我很感激你能否提供帮助。 我有文本代码:添加库到eclipse C++项目(根)
#include <iostream>
#include <TRandom1.h>
int main(void) {
TRandom1* myrand = new TRandom1();
for(int i=0;i<10;++i) {
std::cout << myrand->Gaus(5,1) << std::endl;
}
return 0;
}
和我建立并运行它像:
g++ -c `root-config --cflags` test.cpp
g++ -o randoms `root-config --libs` test.o
./randoms
工作正常。 如果root-config --cflags
结果是:
-pthread -m64 -I/usr/local/include/root
和root-config --libs
-L/usr/local/lib/root -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic
现在的结果时ecplise我改变C/C++ Build-> C++ compiler -> miscellanoeus
到:
-c `root-config --cflags` -fmessage-length=0
,并添加root-config --libs
进行接头miscellanoeus。现在我可以构建代码。但是当我试图运行它时,我得到:
/home/jd/C-workespace/CERN/Debug/CERN: error while loading shared libraries: libCore.so: cannot open shared object file: No such file or directory
我在这里错过了什么?
仍然没有工作 – Moj
那么你需要确保根的配置是路径。并且LD_LIBRARY_PATH环境变量具有包含libCore.so的目录 –