Eclipse CDT Auto Include Shared Libraries

帅比萌擦擦* 提交于 2019-11-30 20:06:18

问题


I am working in Eclipse: Helios Service Release 1 using Eclipse CDT compiling using g++

I have just started to have a go at using Shared Libraries in my projects but have run into a little problem. I have three projects A, B and C. A and B are both Shared Libraries and C is an executable.

Under eclipse I have managed to reference A and B from C and C compiles and runs correctly but when I try and run the generated C program manually outside of Eclipse I get the following error:

"error while loading shared libraries: libA.so: cannot open shared object file: No such file or directory"

I have tried moving A.so B.so and C into the same folder and run C but I get the same error.

Can I get Eclipse to build my project with all the files in the same place and them still run when I move them to a new location?


回答1:


Run ldconfig as root to update the cache - if that still doesn't help, you need to add the path to the file ld.so.conf (just type it in on its own line) or better yet, add the entry to a new file (easier to delete) in directory ld.so.conf.d.




回答2:


You just need to set LD_LIBRARY_PATH to include the folder in which the shared libraries are. Something like this: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/user/lib/



来源:https://stackoverflow.com/questions/5327744/eclipse-cdt-auto-include-shared-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!