将共享库与g ++链接起来 [英] Link a shared library with g++

查看:147
本文介绍了将共享库与g ++链接起来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个cpp文件 a.cpp 和一个共享对象 libA.so 它会在下面使用但是,当我尝试使用g ++将它们链接在一起时,它声明它找不到该库(之后我检查了 ldd )。



这是我使用
g ++ a.cpp -I的命令。 -L。



可能的重复项:
建立和链接共享库

解决方案

使用
g ++ -oa a.cpp -I。 -L。 your-so-name.so


I've got a cpp file a.cpp and a shared object libA.so it's gonna use under the same folder, however, when I tried to use g++ to link them together, it declares that it cannot find the library (I checked with ldd afterwards).

This is the command I used g++ a.cpp -I . -L. -lA

Any idea how this might be solved?

Possible duplicates: building and linking a shared library

解决方案

use g++ -o a a.cpp -I . -L. your-so-name.so

这篇关于将共享库与g ++链接起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆