Thread: GNU Auto build tools

  1. #1
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532

    GNU Auto build tools

    This is less a question about C++ coding, as it is using the GNU Auto build tools with it.
    I have my project all set up using these tools, but when I compile I realize that the libraries I need to link with are linking with EVERY source file in my project. Now most of them need to be linked with these libraries, but some source files have no code that needs it, so wouldn't this just be making the file larger than it needs to be?
    How can I specify which specific source files need to be linked with the libraries?
    I assume this needs to be done in my src/Makefile.am file, but I don't know how exactly. I have all the libraries stored in a Makefile variable, so if I just know the macro or variable I need to use I can easily set it up. Thanks.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > but when I compile I realize that the libraries I need to link with are linking with EVERY source file in my project
    Huh?

    The compilation should be at it's most basic
    gcc -c file.c

    > I have all the libraries stored in a Makefile variable,
    Did you add them to say CPP_FLAGS, and not say LD_FLAGS ?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Ok, here's my Makefile.am in my src directory:
    Code:
    bin_PROGRAMS = merc
    merc_SOURCES = merc.cc info.cc controls.cc listbox.cc window.cc main.cc
    AM_CXXFLAGS = $(Xmms2Client_CFLAGS) $(Gtkmm_CFLAGS) -Wall -g
    merc_LDADD = $(Xmms2Client_LIBS) $(Gtkmm_LIBS)
    Now only merc.cc and main.cc use the Xmms2Client_LIBS, and the rest only need the Gtkmm_LIBS. Yet when I compile, both libraries are linked for every source file. Is this normal and supposed to happen, or is this just making my object files for each source file larger than it needs to be? I'm not sure if this is even an actual "problem" or not, but it just seems to me if every source file is being linked to libraries it doesn't need, it'd make object code larger than it should be.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. PlaySound
    By cangel in forum C++ Programming
    Replies: 16
    Last Post: 10-08-2009, 05:29 PM
  2. build GNU GCC 4.3.1
    By MarkZWEERS in forum Tech Board
    Replies: 8
    Last Post: 08-10-2008, 10:43 AM
  3. Code auto generation tools?
    By xuftugulus in forum C Programming
    Replies: 3
    Last Post: 02-18-2008, 04:00 PM
  4. GNU Build System and referring to Libraries
    By orwb in forum Linux Programming
    Replies: 7
    Last Post: 12-06-2007, 03:41 AM
  5. Boom, Headoshot!!
    By mrafcho001 in forum A Brief History of Cprogramming.com
    Replies: 50
    Last Post: 07-21-2005, 08:28 PM