Solved

Problem with statically linking libmysql and libmysqlpp libraries

Posted on 2006-07-20
2
367 Views
Last Modified: 2012-06-21
For some reason I'd like to statically link some mysql libraries. I am using the following compiler options:
g++ <<blah blah>> -static -lmysqlclient -lmysqlpp

I am not sure I am using the right compiler options. Anyhow I get the following errors:

/usr/lib/mysql/libmysqlclient.a(mf_pack.o)(.text+0x623): In function `unpack_dirname':
: warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/mysql/libmysqlclient.a(libmysql.o)(.text+0x3113): In function `.L481':
: warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/mysql/libmysqlclient.a(mf_pack.o)(.text+0x637): In function `unpack_dirname':
: warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
miscfunc.o(.text+0x1e48): In function `GetIPAddress()':
: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/mysql/libmysqlclient.a(my_gethostbyname.o)(.text+0x3c): In function `my_gethostbyname_r':
: warning: Using 'gethostbyname_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/mysql/libmysqlclient.a(libmysql.o)(.text+0x11f2): In function `mysql_once_init':
: warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/mysql/libmysqlclient.a(my_compress.o)(.text+0x66): In function `my_uncompress':
: undefined reference to `uncompress'
/usr/lib/mysql/libmysqlclient.a(my_compress.o)(.text+0x11c): In function `my_compress_alloc':
: undefined reference to `compress'
collect2: ld returned 1 exit status


0
Comment
Question by:sandeep_th
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 17148349
Regarding 'compress()' and 'uncompress()': It seems that you're missing 'zlib' - try to add '-lz' to your linker options.
0
 
LVL 17

Assisted Solution

by:rstaveley
rstaveley earned 50 total points
ID: 17148883
The other warnings are just warnings. If your program is going to run on the same system you built on you'll be fine, but presumably you are linking statically because you want to be able to distribute your binary. The problem is that the glibc runtime invokes shared libraries. You'll need to find an alternative C runtime, if that's no good for you.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question