我使用Kubuntu 14.04,Eclipse CDT等包含产生此错误的CSFML:
/home/u123/Prog/Test/Debug/Test: error while loading shared libraries: libcsfml-audio.so.2.2: cannot open shared object file: No such file or directory
我的编译器设置:
-DCSFML_STATIC -I/home/u123/Prog/CSFML-2.2/include -O0 -g3 -Wall -c -fmessage-length=0
我的链接器设置
-L/home/u123/Prog/CSFML-2.2/lib -L/usr/local/lib -Xlinker -rpath /home/u123/Prog/SFML-2.2/lib
ldconfig -v
的一些输出 /home/u123/Prog/CSFML-2.2/lib:
libcsfml-system.so.2.2 -> libcsfml-system.so.2.2.0
libcsfml-graphics.so.2.2 -> libcsfml-graphics.so.2.2.0
libcsfml-window.so.2.2 -> libcsfml-window.so.2.2.0
libcsfml-audio.so.2.2 -> libcsfml-audio.so.2.2.0
directorys:
u123@PC-Ubuntu:~$ ls /home/u123/Prog/CSFML-2.2/lib
libcsfml-audio.so libcsfml-graphics.so libcsfml-network.so libcsfml-system.so libcsfml-window.so
libcsfml-audio.so.2.2 libcsfml-graphics.so.2.2 libcsfml-network.so.2.2 libcsfml-system.so.2.2 libcsfml-window.so.2.2
libcsfml-audio.so.2.2.0 libcsfml-graphics.so.2.2.0 libcsfml-network.so.2.2.0 libcsfml-system.so.2.2.0 libcsfml-window.so.2.2.0
u123@PC-Ubuntu:~$ ls /home/u123/Prog/SFML-2.2/lib
libsfml-audio.so libsfml-graphics.so.2.2.0 libsfml-system.so libsfml-window.so.2.2.0
libsfml-audio.so.2.2.0 libsfml-network.so libsfml-system.so.2.2.0 pkgconfig
libsfml-graphics.so libsfml-network.so.2.2.0 libsfml-window.so
LDD:
u123@PC-Ubuntu:~$ ldd /home/u123/Prog/Test/Debug/Test
linux-vdso.so.1 => (0x00007ffec7bfe000)
libcsfml-graphics.so.2.2 => /home/u123/Prog/CSFML-2.2/lib/libcsfml-graphics.so.2.2 (0x00007f226358b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f22631c6000)
libsfml-graphics.so.2.2.0 => not found
libsfml-window.so.2.2.0 => not found
libsfml-system.so.2.2.0 => not found
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f2262ec0000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f2262caa000)
/lib64/ld-linux-x86-64.so.2 (0x000055fd8c8fb000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f22629a3000)
在我看来(但我在SFML方面不是很有经验)CSFML是c中的代码,就像一个外观,它引用了SFML c ++代码。
问题出在哪里?感谢。
答案 0 :(得分:0)
-rpath /home/u123/Prog/SFML-2.2/lib
选项中存在拼写错误
-rpath /home/u123/Prog/CSFML-2.2/lib
应该是
-lcsfml-audio
?
另外,请尝试将- (IBAction)btn_Map:(id)sender
{
MapViewController *map=[[ViewController alloc]init];
sample = [self.storyboard instantiateViewControllerWithIdentifier:@"MapVC"];
sample.view.frame = CGRectMake(0, 0, self.view_map.bounds.size.width, self.view_map.bounds.size.height);
[self.mapView addSubview:map.view];
}
添加到链接器。
答案 1 :(得分:0)
设置Enviroment变量LD_LIBRARY_PATH解决了问题。 转到
Project-> Properties-> C / C ++ Build-> Enviroment,并添加一个名为LD_LIBRARY_PATH的新变量,value = / path / to / lib
在这种情况下/home/u123/Progs/SFML-2.2/lib