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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:00:50+00:00 2026-05-15T20:00:50+00:00

I have a large makefile which builds several libraries, installs them, and then keeps

  • 0

I have a large makefile which builds several libraries, installs them, and then keeps on building objects which link against those installed libraries. My trouble is that I want to use “-lfoo -lbar” as g++ flags to link against the two installed libraries, but the dependencies get messed up. If I change a header “42.h” which the library foo depends on, then of course make will rebuild and install it, but it does not appear to notice that my object “marvin” used “-lfoo” and marvin is left linked against the old version… 🙁

Thus far, I’ve been doing:

$(myObject): $(localSrc) /explicit/path/to/lib/libfoo.a
            $(CXX) $(CPPFLAGS) $(INCFLAGS) -o $@ $^ $(LINKFLAGS) $(LINKLIBS)

But I’m at a point where this is no longer a viable option. I need to simply add libraries “-lfoo -lbar” to the LINKFLAGS variable and have the linker figure things out?

In the mean time, I’ve aliased a few commands to explicitly blow away the object file(s) in question and then call make, but this is getting silly. I’m pressed for time, but if necessary I could post a small example perhaps Friday evening or Saturday morning.

Hence, I feel like I’m back in some bad version of windows dll hell. Is there something I can do to make the linker take notice of the version of the libraries that an object was built against and relink it if those libraries change??

Updated: So I hadn’t had a chance to crash the suggestions until now. The drawback of what I’m doing is using static libraries. So I can’t use ldd. So I rewrote my Makefile and found a way around this problem. If I get time, I’ll post what I did.

  • 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-15T20:00:51+00:00Added an answer on May 15, 2026 at 8:00 pm

    As far as I know, make in general isn’t very good at automatically detecting dependencies like this. (It’s not really make’s job; make is a higher-level tool that’s not aware of the specifics of the commands that it’s spawning or what those commands do.)

    Two options come to mind.

    First, you could run ldd on $(myObject), save its list of libraries to a text file, then feed that back into your makefile as a list of dependencies. (This is similar to using -MD to save a list of header files to a text file then feeding that back into the makefile as additional rules for source file compilation, as Sam Miller suggested.)

    Second, you could use a LINKLIBS variable as you’ve been using, and use GNU Make’s functions to let the same variable work for both dependencies and command-line options. For example:

    LINKLIBS := /explicit/path/to/lib/libfoo.so
    $(myObject): $(localSrc) $(LINKLIBS)
            $(CXX) $(CPPFLAGS) $(INCFLAGS) -o $@ $^ $(LINKFLAGS) $(patsubst %,-l:%,$(LINKLIBS))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.