g++的编译选项:-Wl,-rpath=
来源:互联网 发布:域账号取消挂载网络盘 编辑:程序博客网 时间:2024/05/22 01:49
假设main.cpp,hello.h,hello.cpp,其中main.cpp调用了hello类中的方法
1 生成hello.so
g++ -shared hello.cpp -olibhello.so
2 编译main.cpp,并链接,并指定运行时libhello.so的位置
g++ main.cpp -lhello -L./ -Wl,-rpath=./ -o main
值得一提的是,如果采用带版本号的库,例如libhello.so.2
链接命令可使用g++ main.cpp libhello.so.2 -L./ -Wl,-rpath=./ -o main
2)加入第二个so库
g++ main.cpp -L./second/ -Wl,-rpath=./second/ -lsecond -L./hello/ -Wl,-rpath=./hello/ -lhello -o main
ps,遇到过一个奇怪的问题,就是假设libhello.so还用到了libother.so,由于在/etc/ld.so.conf里配置错误了libother.so的目录路径,导致一直产生undefined reference to错误,但是在工程里对libother目录路径配置是正确的,有可能于查找路径顺序有关
http://www.cnblogs.com/maximusfz/archive/2010/12/01/1893384.html
- g++的编译选项:-Wl,-rpath=
- gcc中的-Wl,rpath=<your_lib_dir>选项
- gcc中的-Wl,rpath=<your_lib_dir>选项
- gcc中的-Wl,rpath=<your_lib_dir>选项
- gcc中的-Wl,rpath=<your_lib_dir>选项
- gcc中的-Wl,rpath=<your_lib_dir>选项
- GCC的-wl,-rpath=<link_path>参数
- 链接选项-I,-l,-L,-Wl:rpath
- 运行时记住动态库的路径 -Wl,-rpath=
- 动态库编译 -Wl, -rpath 用法
- gcc编译选项-Wl
- 使用 -Wl,rpath设置动态库的搜索路径
- gcc的两个选项 -Xlinger -rpath
- Makefile 中 -wl ,rpath 以及 O0 O1 O2 O3 Os 的用法
- g++编译命令选项
- gcc g++编译选项
- g++编译选项
- g++编译选项
- Linux音频编程
- 网页内容延迟加载实现方式
- 升级到Visual C++ 2010的三纪律八注意
- 在eclipse中搜索中文字符
- IE和FF下document.body对象的clientHeight,offsetHeight,scrollHeight的差别
- g++的编译选项:-Wl,-rpath=
- C++ 冒号运算符
- OpenGL在Android上绘制Bitmap
- MFC 浏览文件夹,浏览保存文件, 获取当前路径
- 数据从MySQL迁移到 Oracle的注意事项
- Android中OpenGL ES贴图无法显示问题的可能原因
- Linux 恢复已经删除的文件/文件夹
- ELF文件格式
- android.opengl.GLSurfaceView