SOT: make/build question

Discussion in 'C++' started by woodbrian77@gmail.com, Mar 31, 2013.

  1. Guest

    Up till now I've just been building a static library.
    Now I want to also create a shared library.
    I'm trying to figure out how to compile the files
    without the fpic option for the static library and
    then add fpic and recompile the files for the shared
    library. I'd like to do this from one makefile.
    I've been duckduckgoing --
    https://duckduckgo.com -- for a couple of hours,
    but haven't figured it out. (Currently I have it
    building both a static and shared library, but the
    files that go into the static library were compiled
    with fpic. http://webEbenezer.net/misc/makefile )


    I was reading this thread about libraries:

    https://groups.google.com/forum/?fromgroups=#!searchin/comp.lang.c$2B$2B/merits$20static$20dynamic/comp.lang.c++/WdiIeG8yftQ/zx1KYYJ6j_oJ

    Is there a shared lib revival in the data center?
    It seems some of the difficulties regarding shared
    libs mentioned in that thread vanish in a data center.
    Thanks in advance.


    Brian
    Ebenezer Enterprises - in G-d we trust.
    http://webEbenezer.net
     
    , Mar 31, 2013
    #1
    1. Advertising

  2. Jorgen Grahn Guest

    On Sun, 2013-03-31, wrote:
    > Up till now I've just been building a static library.
    > Now I want to also create a shared library.
    > I'm trying to figure out how to compile the files
    > without the fpic option for the static library and
    > then add fpic and recompile the files for the shared
    > library. I'd like to do this from one makefile.


    What have you tried? I'd start with building to separate
    directories:

    libfoo.a: static/bar.o
    libfoo.so: shared/bar.o
    static/%.o: %.c
    shared/%.o: %.c

    And so on.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Mar 31, 2013
    #2
    1. Advertising

  3. Guest

    On Sunday, March 31, 2013 7:35:37 PM UTC, Jorgen Grahn wrote:
    >
    > What have you tried? I'd start with building to separate
    >
    > directories:
    >
    >
    >
    > libfoo.a: static/bar.o
    >
    > libfoo.so: shared/bar.o
    >
    > static/%.o: %.c
    >
    > shared/%.o: %.c
    >
    >
    >
    > And so on.
    >
    >


    I saw something like CXXFLAGS+=-fpic, but I couldn't
    get that to work.
     
    , Mar 31, 2013
    #3
  4. Jorgen Grahn Guest

    On Sun, 2013-03-31, wrote:
    > On Sunday, March 31, 2013 7:35:37 PM UTC, Jorgen Grahn wrote:
    >>
    >> What have you tried? I'd start with building to separate
    >> directories:
    >>
    >> libfoo.a: static/bar.o
    >> libfoo.so: shared/bar.o
    >> static/%.o: %.c
    >> shared/%.o: %.c
    >>
    >> And so on.
    >>

    > I saw something like CXXFLAGS+=-fpic, but I couldn't
    > get that to work.


    It does work (assuming you use Gnu Make and have read the manual). The
    'target: VAR+=stuff' syntax is intended for just that: to tweak the
    way certain targets are built.

    I use it that way. You can also customize those rules completely when
    needed. After you have created a clear way of pointing out certain
    build steps which have something in common ('static/%.o: %.c' above),
    Make is on your side.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Apr 2, 2013
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chaz

    SOT: Finding orphaned files

    chaz, May 15, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    463
  2. Just Another Joe

    SOT: Turbo C 2 Question

    Just Another Joe, Dec 12, 2003, in forum: C Programming
    Replies:
    5
    Views:
    396
    Mark A. Odell
    Dec 15, 2003
  3. Tux
    Replies:
    2
    Views:
    284
  4. Thomas Weholt

    SOT: License issues ....

    Thomas Weholt, Oct 12, 2003, in forum: Python
    Replies:
    1
    Views:
    998
    Paolo Alexis Falcone
    Oct 14, 2003
  5. Lyndon Samson

    SOT gmail invites

    Lyndon Samson, Dec 1, 2004, in forum: Ruby
    Replies:
    104
    Views:
    754
Loading...

Share This Page