tags:

views:

40

answers:

2

Hi SO,

I wrote a client program and a server program, that uses the NTL library and Boost::Asio, to do client/server communication for an integer factorization application, in C++.

Both sides consist of several headers and cpp files. Both project compile fine individually on Windows in Visual Studio. All I did, was add the include path of NTL and Boost to both projects:

Additional include paths: "D:\Downloads\WinNTL-5_5_2\include";D:\boost_1_42_0

Furthermore, for both projects, I added the two library paths to both projects in VS:

Additional library directories: D:\boost_1_42_0\stage\lib;"D:\Documents\Visual Studio 2008\Projects\ntl\Debug"

And added under Additional dependencies:

ntl.lib

As said, it compiles fine on Windows. But when I put the code on a Linux machine provided by university, I try to compile with the following statement

c++ -I/appl/htopopt/Linux_x86_64/NTL-5.4.2/include -I/appl/htopopt/Linux_x86_64/boost_1_43_0/include client_protocol.cpp mpqs_client.cpp mpqs_sieve.cpp mpqs_helper.cpp -o mpqs_helper -L/appl/htopopt/Linux_x86_64/NTL-5.4.2/lib -lntl -L/appl/htopopt/Linux_x86_64/gmp-4.2.1/lib -lgmp -lm -L/appl/htopopt/Linux_x86_64/boost_1_43_0/lib -lboost_system -static

Upon doing this, I get a huuuge error, which I posted here. Any idea how to fix this, please??

A: 

I'm not sure, but I suspect you can't do multi-threading in a staticly linked binary.

Douglas Leeder
+1  A: 

You are getting lots of errors to do with missing pthread symbols. Try adding

-lpthread

to your link line.

Troubadour
Hi, I tried adding -lpthread. It fixed a lot of problems. Then I added -lboost_thread as well, and now I just get this error here: http://pastebin.com/bVBKfcKhAny help on this?
Martin Lauridsen
@Martin: I think the remaining error means that although you are linking boost statically with your app. you didn't link boost itself statically to glibc i.e. your boost library still depends on other shared libraries like glibc.
Troubadour
How may I fix this? Would it involve compiling Boost again? This was handled by a university system admin, and not myself.
Martin Lauridsen
@Martin: Hmm, I think I'm wrong about that last part. Persumably the boost libraries you have are .a files and not .so?
Troubadour
@Troubadour: I have both .a files and .so files, for each library, it seems.
Martin Lauridsen
@Martin: You could try moving the .so files out the way completely to make sure it is not picking those up and let me know if you get the same error.
Troubadour
@Troubadour: I dont think I have access to move the files away. I will request the system admin to do, and return to you asap. Thanks!
Martin Lauridsen
@Martin: Alternatively you can copy the required .a files out to one of your own directories and alter the link path to point to that directory. That way you don't need to hassle your sysadmin!
Troubadour
@Troubadour: I tried copying all the .a files out to a different directory and linking to that instead. I still get the same error :(
Martin Lauridsen