在使用动态库的时候,已经生成了可执行文件(exam5-5)了,但是输入./exam5-5运行时报错:
./exam5-5: error while loading shared libraries: libdemo.so: cannot open shared object file: No such file or directory
这是因为运行时系统无法找到你的动态库,这时候要配置一下:
进入/etc/ld.so.conf.d/目录下
新建一个文件:demo.conf(libdemo,so)
然后再demo.conf中写入libdemo.so的路径
我这里是 /home/lan/桌面/GNU C/动态库
最后一root身份输入:/sbin/ldconfig-v
让改成的配置文件生效即可
然后就可以运行啦:
参考:运行错误:error while loading shared libraries: xxx.so.0:cannot open shared object file: No such file or