Computer Scientist

Friday, 18 February 2011

Experiment Q&A............

When I compiled the lookup program using MySQL connector C++ statically:

Q: what if I am confronted with "ld: can not found lm "?
A: The reason is that 'ld' can not find the static version of 'libm.a' within the default position.
     So I need to install it in Fedora using yum: "sudo yum install glibc-static". This should solve the 'lm' problem.

Q: what if I am confronted with message: "undefined reference to 'pthread_self' and so on...."?
A: The problem is that the pthread library can not be found. Just direct the g++ the location of it by append "-lpthread" at the end.

Q: What is the command that I used to compile the program and link against the static library?
A: Like this: "g++ -static -o <dst> <src> /usr/local/lib/libmysqlcppconn-static.a /usr/local/mysql/lib/libmysqlclient.a -lpthread".

Q: When using the static library, sometimes there is a strange message pop out: can not found lc ?
A: Because the static version of glibc is not installed by default, we need to install by ourself:
        sudo yum install glibc-static


No comments:

Post a Comment