c++ - 在 Linux 上设置链接库

标签 c++ ubuntu libraries

在 Linux 上进行开发对我来说是新事物,而且我在设置环境时遇到了麻烦。我有一个相对较小的程序,它依赖于以下库:

-lboost_date_time -lboost_regex -lmysqlclient -lmysqlcppconn -lexpat

我在 Ubuntu 12.04 LTS 上使用 eclipse。我需要对包管理器和 eclipse 做什么才能成功编译?我被告知使用 sudo apt-get libboost* ,但这会打印出一大堆冲突,然后得出令人悲伤的结论:

E: Unable to correct problems, you have held broken packages.

我相信我正确安装了libmysqlcppconn-devlibexpat1-dev。 我在 Eclipse 中所做的唯一一件事就是将 -l 内容添加到链接器库设置中。

总之,操作系统和 IDE 对我来说都是新的,我将不胜感激详细的帮助。

从下面的终端转储:

libboost-dev is already the newest version.
libboost-iostreams1.46.1 is already the newest version.
libboost-iostreams1.46.1 set to manually installed.
libboost-serialization1.46.1 is already the newest version.
libboost-serialization1.46.1 set to manually installed.
libboost1.46-dev is already the newest version.
libboost1.46-dev set to manually installed.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libboost-date-time1.48-dev : Conflicts: libboost-date-time1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-filesystem1.48-dev : Conflicts: libboost-filesystem1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-graph-parallel1.48-dev : Conflicts: libboost-graph-parallel1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-graph1.48-dev : Conflicts: libboost-graph1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-iostreams1.48-dev : Conflicts: libboost-iostreams1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-math1.48-dev : Conflicts: libboost-math1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-mpi-python1.48-dev : Conflicts: libboost-mpi-python1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-mpi-python1.48.0 : Conflicts: libboost-mpi-python1.46.1 but 1.46.1-7ubuntu3 is to be installed
 libboost-mpi1.48-dev : Conflicts: libboost-mpi1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-program-options1.48-dev : Conflicts: libboost-program-options1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-python1.46-dev : Depends: python-dev but it is not going to be installed
 libboost-python1.48-dev : Depends: python-dev but it is not going to be installed
                           Conflicts: libboost-python1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-regex1.48-dev : Conflicts: libboost-regex1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-serialization1.48-dev : Conflicts: libboost-serialization1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-signals1.48-dev : Conflicts: libboost-signals1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-system1.48-dev : Conflicts: libboost-system1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-test1.48-dev : Conflicts: libboost-test1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-thread1.48-dev : Conflicts: libboost-thread1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost-wave1.48-dev : Conflicts: libboost-wave1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost1.48-dbg : Conflicts: libboost1.46-dbg but 1.46.1-7ubuntu3 is to be installed
 libboost1.48-dev : Conflicts: libboost1.46-dev but 1.46.1-7ubuntu3 is to be installed
 libboost1.48-doc : Conflicts: libboost1.46-doc but 1.46.1-7ubuntu3 is to be installed
E: Unable to correct problems, you have held broken packages.

最佳答案

libboost-dev是一个虚拟包,指向存储库中部署的最新boost开发包集。目前,对于您的 ubuntu 版本,似乎 1.48.02 是最新的(请参阅 package description )。存储库中可能还有其他可用版本,例如 1.46,它似乎是 12.04 发布时可用的版本。

启动时:

apt-get install liboost*

包管理器将尝试安装名称以 libboost 开头的每个包。 ,不仅仅是最新版本。您真正想要的是仅安装一组开发包(以及您的应用程序可能需要的所有运行时包,但这将由 apt 的依赖项跟踪器处理)。

以下命令:

apt-get update
apt-get install libboost-dev

aptitude install libboost-dev

应该将您的系统升级到 boost 开发包的最新版本。

关于c++ - 在 Linux 上设置链接库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15874220/

相关文章:

android - 获取 AIMAGE_FORMAT_JPEG 图像失败

c++ - C++ 标准是否要求对 wchar_t 进行编码?

c++ - 使用第三方库部署 Linux c++ 可分发应用程序

c# - 将 C# 方法转换为 C++ 方法

c++ - 在 AVR 的程序内存中构建编译时任意长度数组

linux - 从终端启动 Sublime 3,默认为 Sublime Text 2

php - 正确签名的 phpmailer 电子邮件不断被标记为垃圾邮件或被拒绝

postgresql - 顶部 PostgreSQL 命令中括号中的数字

ios - 在 Xcode 中使用静态库

javascript - 如何找出特定变量从哪里来?