Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3358560
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:46:03+00:00 2026-05-18T02:46:03+00:00

I have the following problem, which seems not to have a nice solution. For

  • 0

I have the following problem, which seems not to have a nice solution.

For example, I have an CLI utility which uses libtiff and libX11. I want to produce two versions of this utility: dynamically linked and statically linked (with as many dependences compiled-in as possible).

For dynamic linking everything works as a charm: one need to specify -ltiff -lX11 and linker will produce a nice executable referring libtiff.so and libX11.so.

The situation becomes worse for static linking. When I use the following command:

g++ -static-libgcc -Wl,-static -o my.out *.o -lc -ltiff -lX11

it ends with missed symbols in libtiff.a and libX11.a. OK, I can put all libraries they depend on into row:

g++ -static-libgcc -Wl,-static -o my.out *.o -lc -ltiff -ljpeg -lz -lX11 -lXau -lxcb -lXdmcp

but is there any tool that makes this discovery for me? Can libtool help here (I see /usr/lib/libtiff.la but no /usr/lib/libX11.la)? Can somebody provide a basic example for libtool please? The situation is critical, if on some platform libtiff provides a narrower functionality and does not link to libjpeg which will not be available on that platform at all, so the above command for linking will fail due to unsatisfied library dependency.

The second problem is due to that warning (I believe):

/usr/lib/libX11.a(xim_trans.o): In function `_XimXTransSocketUNIXConnect':
(.text+0xcda): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

the utility is not linked statically against libc, which is still displayed in ldd output. How to correctly link statically with libX11 and libc in this case?

This question is relevant, but I think re-packing system .a files is not good idea.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:46:03+00:00Added an answer on May 18, 2026 at 2:46 am

    For libraries that provide .pc files for pkg-config like the X11R7 libraries do:

    % pkg-config --static --libs x11
    -lX11 -lpthread -lxcb -lXau  
    

    Unfortunately, pkg-config --list-all doesn’t seem to show libtiff as one of the
    libraries delivering those, but you can at least turn your link command into:

    g++ -static-libgcc -Wl,-static -o my.out *.o -lc -ltiff -ljpeg -lz `pkg-config --static --libs x11`
    

    and then not have to worry about keeping track of what libraries that version of libX11 needs (since libxcb was optional until recently, so older Linux distros may not have it).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem. I have a class named A in which I
I have the following problem: I opened the activity A, from which I opened
I am having a strange problem which I don't understand. I have the following
Greetings, I have to following problem. I have a WCF Service which runs under
I have the following tricky problem: I have implemented a (rather complicated) class which
Ive got the following problem. I have a model called user which has a
I have a problem with following script. It generates a list of places which
I have problems with following code: http://lisper.ru/apps/format/96 The problem is in normalize function, which
I have the following code which seems to work OK except for a minor
I have the following problem, on which I can't seem to find an answer...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.