FreeBSD static link Problem (2) libpqxx & libpq

Source: Internet
Author: User

In the previous article "FreeBSD static link problem", another legacy problem is to determine which library is called by a static library? Google's results are disappointing. The only result is the libtool script, which has never been used and cannot be understood. Without Google's method of use, you have to use a stupid method.

The problem is due to a post http://community.csdn.net/Expert/TopicView.asp csdn? Id = 5630522
To put it simply, you need to statically link libpqxx and libpq. The post owner finds the problem: the Library generated using libtool usually includes one. la file description file, indicating the library name, required library, version, and installation path, libpqxx. the content of La is as follows:

# Libpqxx. La-A libtool Library File
# Generated by ltmain. Sh-GNU libtool 1.5.22 Debian 1.5.22-4 (1.123162.365 2005/12/18 22:14:06)
#
# Please do NOT delete this file!
# It is necessary for linking the library.

# The name that we can dlopen (3 ).
Dlname = 'libpqxx-2.6.9.so'

# Names of this library.
Library_names = 'libpqxx-2.6.9.so libpqxx-2.6.9.so libpqxx. so'

# The Name Of The static archive.
Old_library = 'libpqxx.'

# Libraries that this one depends.
Dependency_libs = '-L/usr/local/lib-lpq'

# Version information for libpqxx.
Current = 0
Age = 0
Revision = 0

# Is this an already installed library?
Installed = Yes

# Shoshould we warn about portability when linking against-modules?
Shouldnotlink = No

# Files to dlopen/dlpreopen
Dlopen =''
Dlpreopen =''

# Directory that this library needs to be installed in:
Libdir = '/usr/local/lib'

Libpqxx requires libpq, but cannot find a libpq. La file. Static links always fail. Use objdump-T libpq. so check libpq. the so symbol shows no symbols, strip, and view libpq. A will display libpq one by one. in. o file symbols, it is difficult to determine those are real external symbols, there is no way to solve libpq. a, and then relink. so file, you can use objdump-t to see which external symbols are available, and finally determine the function library called by libpq. libpqxx can finally be statically linked to the application. The following is a makefile for compiling the test program in libpqxx.

#
# Makefile-static linked to libpqxx
#

Cflags + =-static-I/usr/local/include
Ldflags + =-L/usr/local/lib
Ldlibs + =-lpqxx-lstdc ++-lpq-lcrypt-lssl-lcrypto-lintl-liconv

Prog = test094
Objs = test094.o

Rm = Rm-RF

ALL: $ (Prog)

Test094: $ (objs)
$ (CC) $ (cflags) $ (ldflags) $ (objs) $ (ldlibs)-o $ @

Clean:
$ (RM) $ (Prog) $ (objs)

System Information:
FreeBSD 5.4-release
GCC version 3.4.2 [FreeBSD] 20040728
Postgresql-client-7.4.17
Postgresql-libpqxx-2.6.9

This method is very troublesome. In the case of a large number of databases, the workload is huge, and even cannot be completed. We look forward to a good method!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.