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 7685813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:20:08+00:00 2026-05-31T19:20:08+00:00

I am trying to link a static library [1] into another static library [2]

  • 0

I am trying to link a static library [1] into another static library [2] with scons.

Unfortunately the emitted call to “ar” never contains any path to library [1].

According to this post How to merge two "ar" static libraries into one it should be possible to merge to archives into one.

Is the usual call to CheckLibWithHeader not sufficient here?

Best regards

  • 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-31T19:20:10+00:00Added an answer on May 31, 2026 at 7:20 pm

    Have you tried specifying the complete path to library [1] when referring to it with the SCons ar command?

    Brady

    Adding more info to my original answer:
    Since you havent posted your SCons scripts, I’ll assume its something like the one I present below:

    Normally, the LIBPATH construction variable is used to specify paths to libraries, but that appears to only work with the Program() builder and is not used with the ar command. What needs to be done then is to specify the complete path for the library in question. Assuming I have the following directory structure:

    # tree .
    .
    |-- SConstruct
    |-- fileA.cc
    |-- fileA.o
    |-- libB
    |   `-- libmoduleB.a
    |-- libmoduleA.a
    `-- libmoduleC.a
    

    Here is the SConscript that shows how to do so:

    env = Environment()
    env.Library(target = 'moduleA', source = 'fileA.cc')
    env.Library(target = 'moduleC', source = ['libmoduleA.a', '#libB/libmoduleB.a'])
    

    Or Instead of the relative dir ‘#libB’, you could specify an absolute path. (the ‘#’ in a path means its relative to the SConscript)

    And, to make it portable, you should specify the moduleB library (and moduleA) like this:

    libBname = "%smoduleB%s" % (env['LIBPREFIX'], env['LIBSUFFIX'])
    libB = os.path.join(pathToLibB, libBname)
    

    Here is the result:

    # scons
    scons: Reading SConscript files ...
    scons: done reading SConscript files.
    scons: Building targets ...
    g++ -o fileA.o -c fileA.cc
    ar rc libmoduleA.a fileA.o
    ranlib libmoduleA.a
    ar rc libmoduleC.a libmoduleA.a libB/libmoduleB.a
    ranlib libmoduleC.a
    scons: done building targets.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to link to a static library and I keep getting linker errors.
I'm trying to create a simple static C++ library that I can link it
Using MINGW, I'm trying to link my C code with a static C++ library
I'm trying to link a static library (.a) file with a .o file which
I'm trying to link to a static library, libcovis.a. Everything looks fine but I
I'm trying to link with the static libc.a and a dynamic lib .so unsuccessfully.
Im trying to grab the destination (dynamic) of a link (static) with php Im
I'm trying to link an RPATH containing the special string $ORIGIN into an executable
I'm trying to link the LizardTech GeoExpress DSDK into my own application. I use
I'm trying to link my mac application to the wonderful libancillary library. However, I

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.