0

对于我的学士论文,我正在实现一个分布式版本的算法,用于分解大整数(寻找素数分解)。这在例如 RSA 密码系统的安全性中具有应用。

我的愿景是,客户端(linux 或 windows)将下载应用程序并计算一些数字(这些是独立的,因此适合并行化)。这些号码(不经常找到)将被发送到主服务器,以收集这些号码。一旦主服务器收集到足够的数字,它将完成其余的计算,这些计算不容易并行化。

无论如何,到技术细节。我正在考虑使用 Boost::Asio 来实现套接字客户端/服务器,以便客户端与主服务器进行通信。因为我想同时为 linux 和 windows 编译,所以我认为 windows 是一个很好的起点。因此,我下载了 Boost 库并对其进行了编译,正如Boost Getting Started 页面上所说:

引导程序

.\bjam

这一切都编译得很好。然后我尝试编译来自 Asio 的教程示例 client.cpp 之一,发现(这里.. 编辑:由于限制无法发布链接)。我正在使用 Microsoft Visual Studio 2008 中的 Visual C++ 编译器,如下所示:

cl /EHsc /ID:\Downloads\boost_1_42_0 client.cpp

但我得到这个错误:

/out:client.exe

客户端.obj

链接:致命错误 LNK1104:无法打开文件“libboost_system-vc90-mt-s-1_42.lib”

任何人都知道可能出了什么问题,或者我该如何前进?我几乎整个星期都在尝试获得一个简单的 C++ 客户端/服务器套接字程序,但没有运气。严重的挫败感袭来。

先感谢您。

4

1 回答 1

2

构建失败的原因是它找不到包含 boost 系统的库文件。Boost 包含一个“方便的”自动链接功能,这样当您包含二进制 libaray 的头文件(与仅头文件库相反)时,boost 会自动告诉编译器它应该链接到库中。这样做的缺点是 boost 不会告诉编译器在哪里可以找到库。

The short answer is to read a little further in the boost getting started guide. This page shows you how to add the necessary flags to the compiler command line: Getting started on windows: linking from the command line.

The first thing you have to do is find the .lib file. Boost hides them in a deep directory structure, so search for it starting in the directory you ran bjam from. Make note of the directory where the file is. You may also wish to use bootstrap --prefix=/some/install/location and bjam install to install boost somewhere other than the source directory in which you built it.

Are you building your project using a Visual Studio solution, or on the command line?

If you are using a solution file, find the link page in the solution properties. There should be a box where you can enter additional library paths. Add the directory in which you boost .lib files reside to this box.

If you are using cl on the command link, familiarize yourself with the command line options for cl and link. You can pass commands to the linker using the cl option /link, and the linker command you are looking for is /libpath.

于 2010-04-10T14:53:57.633 回答