Solved

Problem with statically linking libmysql and libmysqlpp libraries

Posted on 2006-07-20
2
356 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now