views:

574

answers:

1

Hi there,

For my bachelors thesis, I am implementing a distributed version of an algorithm for factoring large integers (finding the prime factorisation). This has applications in e.g. security of the RSA cryptosystem.

My vision is, that clients (linux or windows) will download an application and compute some numbers (these are independant, thus suited for parallelization). The numbers (not found very often), will be sent to a master server, to collect these numbers. Once enough numbers have been collected by the master server, it will do the rest of the computation, which cannot be easily parallelized.

Anyhow, to the technicalities. I was thinking to use Boost::Asio to do a socket client/server implementation, for the clients communication with the master server. Since I want to compile for both linux and windows, I thought windows would be as good a place to start as any. So I downloaded the Boost library and compiled it, as it said on the Boost Getting Started page:

bootstrap

.\bjam

It all compiled just fine. Then I try to compile one of the tutorial examples, client.cpp, from Asio, found (here.. edit: cant post link because of restrictions). I am using the Visual C++ compiler from Microsoft Visual Studio 2008, like this:

cl /EHsc /I D:\Downloads\boost_1_42_0 client.cpp

But I get this error:

/out:client.exe

client.obj

LINK : fatal error LNK1104: cannot open file 'libboost_system-vc90-mt-s-1_42.lib'

Anyone have any idea what could be wrong, or how I could move forward? I have been trying pretty much all week, to get a simple client/server socket program for c++ working, but with no luck. Serious frustration kicking in.

Thank you in advance.

+2  A: 

The reason the build is failing is because it cannot find the library file containing boost system. Boost includes a "handy" autolinking feature, such that when you include a header file for a binary libaray (as opposed to a header only library), boost automatically tells the compiler that it should link in the library. The downside to this is that boost doesn't tell the compiler where to find the library.

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.

mch
Hi mch, thanks for your answer.After doing a fresh compilation of Boost, I find some .lib files that have names very similar to the one I need, eg:libboost_system-vc90-mt.liblibboost_system-vc90-mt-1_42.liblibboost_system-vc90-mt-gd.liblibboost_system-vc90-mt-gd-1_42.libBut none with the exact name that it is complaining about, which islibboost_system-vc90-mt-s-1_42.lib. So I am not sure where to go from here? Does the -s mean that it is a static library, and if so, how do I tell Boost that I want to compile like that?I am compiling everything from a command prompt.
Martin Lauridsen
The -s means that it is looking for a library that is statically linked to the C++ standard library and runtime. To build this library, try `bjam link=static link=shared runtime-link=static runtime-link=shared`, which should build all of the possible combinations.
mch
Thanks mch,I got it working by doing a fresh unzip of boost, and doing booststrap, followed by bjam link=static runtime-link=static. Then I added the library path (/stage/lib/) as a flag to cl.Thanks!
Martin Lauridsen
Hello again.Today I needed to make my program work, both with the Boost::Asio library, but also another library (NTL). For this NTL library, I can only make my program compile through Visual Studio (and not via the command prompt).So I thouhgt I would use Visual Studio and set my project to use both libraries, and hope for the best...Fat chance! Now it complains about the file 'libboost_system-vc90-mt-gd-1_42.lib' missing, while yesterday it was 'libboost_system-vc90-mt-s-1_42.lib'. Do I need to set my Visual Studio to use the static library or something, or should I compile Boost again?
Martin Lauridsen
`-gd-` means that it is looking for the debug versions of the standard and runtime libraries, and for a debug version of the boost libraries. You need to build boost like this: `bjam variant=debug variant=release link=static link=shared runtime-link=static runtime-link=shared` to get the debug builds.
mch
hi mch. If I do that, it sayserror: link=shared together with runtime-link=static is not allowederror: such property combination is either impossibleerror: or too dangerious to be of any useWhich one should I choose? Also I cant use link=shared together with runtime-link=static
Martin Lauridsen