Linking statically

Discussion in 'C Programming' started by T, Jan 10, 2006.

  1. T

    T Guest

    Hi,

    I haven't involved in C programming for quite a while. I want to confirm
    this question but couldn't find in comp.lang.c FAQ, and GCC Frequently
    Asked Questions. Anyway, here is the question:

    How can I link a lib statically?

    Although the question is simple, please answer comprehensively. I.e., what
    is the command line format, what is required for the linking.
    Specifically, I want to link avcodeccvs & avformat statically while lz is
    linked dynamically. how can I do that? This is what I tried:

    $ g++ -g -Wall -o lnk-test lnk-test.C -lz -static -lavcodeccvs -lavformat
    /usr/bin/ld: cannot find -lavcodec
    collect2: ld returned 1 exit status

    Please note, this is ok:

    $ g++ -g -Wall -o lnk-test lnk-test.C -lavcodec -lavformat -lz

    Further, in the libavcodeccvs-dev package, only .so type of libs are provided:

    /usr/lib/libavcodec.so
    /usr/lib/libavformat.so

    please elaborate. Thanks

    tong
     
    T, Jan 10, 2006
    #1
    1. Advertising

  2. T

    Michael Mair Guest

    T wrote:
    > Hi,
    >
    > I haven't involved in C programming for quite a while. I want to confirm
    > this question but couldn't find in comp.lang.c FAQ, and GCC Frequently
    > Asked Questions. Anyway, here is the question:
    >
    > How can I link a lib statically?


    This seems to be a gcc question -> news:gnu.gcc.help
    Look into the newsgroup's archives

    > Although the question is simple, please answer comprehensively. I.e., what
    > is the command line format, what is required for the linking.
    > Specifically, I want to link avcodeccvs & avformat statically while lz is
    > linked dynamically. how can I do that? This is what I tried:
    >
    > $ g++ -g -Wall -o lnk-test lnk-test.C -lz -static -lavcodeccvs -lavformat
    > /usr/bin/ld: cannot find -lavcodec


    Note that g++ is used for compilation of C++.
    In this case, ask in news:gnu.g++.help


    Cheers
    Michael
    --
    E-Mail: Mine is an /at/ gmx /dot/ de address.
     
    Michael Mair, Jan 10, 2006
    #2
    1. Advertising

  3. T

    T Guest

    On Tue, 10 Jan 2006 23:52:40 +0100, Michael Mair wrote:

    > T wrote:
    >> How can I link a lib statically?

    >
    > Note that g++ is used for compilation of C++. In this case, ask in
    > news:gnu.g++.help


    Hi, sorry to have posted OT question here. I re-posted it again in
    gnu.g++.help.

    However, by taking a look at the recent posts, I get a feeling that the NG
    is abandoned, and is full of spams. Check the subject list (and count)
    below.

    > This seems to be a gcc question -> news:gnu.gcc.help Look into the
    > newsgroup's archives


    As I said, I searched and looked before raised the question.

    thank
    tong

    PS.

    Latest headers in gnu.g++.help (count subject)
    1
    3 (no subject)
    1 A LETTER FROM EURO MILLIONS
    1 ADAMS SMITH(NEW YEAR AWARD)
    1 AWARD CLAIM !!!
    1 AWARD NOTICE FROM MRS. MARY VAN ANDER.
    2 AWARD WINNING NOTIFICATION / YOU HAVE WON AN E-MAIL LOTTERY.
    1 Account Suspended
    1 Alert - S.H. Information
    1 Banco Central
    1 Be the "biggest" out of all your friends
    1 Buy OEM Software
    2 CHRIST: THE ARRIVAL
    1 CONTACT YOUR AGENT.
    1 CONTACT YOUR CLAIM AGENT.
    1 CONTACT YOUR CLAIMS AGENTS TO VERIFY YOUR LOTTERY WINNING
    1 CONTACT YOUR FIDUCIARY AGENT.
    1 CONTACT!!!
    1 Cialis Soft Tabs bestseller
    1 Compile error with concept_check.h
    1 Confirm Mail
    1 Congratulatio your mail have won!.
    2 Corel Draw
    1 EMAIL NOTICE!! CONTACT FUDICIAL AGENT ASAP
    1 Error message of pointer of type `void *' used in arithmetic in g++
    1 Euromillion Loteria Español AWARD 2005.
    1 FINAL NOTICE
    1 FROM THE PROMOTIONAL MANAGER
    1 Finally, you can afford software by Symantec Microsoft & Photoshop
    1 Formatted output with std::basic_ostream
    1 From The Desk of Mrs.F.Demellor
    1 GNU gcc/g++ cross-compiler for PowerPC
    1 Geschäft Antrag
    1 Grokking C++ errors
    3 INTERNET NETHERLANDS EMAIL PROMOTION AWARD
    1 INVESTMENT BANKING IN HONGKONG.
    1 Important
    2 International Promotions
    1 Is a gnu object file like an other compiler object file
    1 LET'S GO INTO THIS TOGETHER
    1 LOTTO.NL.
    1 Linker problem
    2 Mesage from ebay member
    1 Message from eBay Member
    1 Mrs. Mercy Steve/Lottery Coordinator
    2 Mrs.Pareson Molburg.Prize Claim
    4 My.
    1 NETHERLANDS EMAIL PROMOTION AWARD
    1 NETHERLANDS EMAIL PROMOTION AWARDS
    1 NEW YEAR WINNERS.
    2 NOTICE OF CONSULATION PRIZE WINNING
    1 NOTIFICATION
    2 Need S0ftware?
    1 New AutoSurf (PAYING)
    1 Notification of Limited Account Access
    1 Notification of e-gold account update
    1 OEM Adobe, Windows software @ wholesale price$
    1 Off topic - To be ignored
    1 PayPal Account Suspension Notice - PayPal Account Limited
    1 Photoshop, Windows, Office
    1 Please Protect Your Identity And Update
    3 Please Update Your Account Access
    1 Please Update Your PayPal Account!
    1 Printed information
    1 Question from eBay member
    2 Question from ebay member
    1 READ THIS MAIL YOU JUST WON !!!
    2 REFERENCE AND BATCH NUMBER TO FIDUCIARY
    2 REQUESTING A BUSINESS RELATIONSHIP
    1 RESULTS OF WINNINGS CONTACT YOUR AGENT.
    1 ReferenceNumber: 7334NFJF/UDDFMF/NDDD
    1 Resolution Center Your account is limited
    1 Security Tip: Prevent unautorized access to your account!
    1 Security Update Notification
    1 Security update
    4 Software At Low Pr1ce
    1 Sonorisation et effets lumiÉres à prix discount
    1 Spyware a problem?
    1 THE NETHERLANDS EMAIL PROMOTION
    1 THE NETHERLANDS EMAIL PROMOTION,
    1 Test post please ignore.
    1 Three Steps to the Software You Need at the Prices You Want
    1 US$500,000.00 (Five Hundred Thousand US DOLLARS ) AWARD
    2 Update your information
    1 WARNING: Your paypal account has been frozen. for Security reasons please Log-in & update your info.
    2 WINNING NOTIFICATION/FINAL AWARD.
    1 We cure any desease!
    1 What IS 0EM Software And Why D0 You Care?
    1 YOUR PERUSAL.
    2 Your Account Will Be Suspended
    1 Your eBay Billing Information is out of date
    1 ambiguity and 0
    3 eBay Security Center
    1 gcc vs g++
    1 hiii
    1 melhore a sua auto estima 2006
    1 operators << and >> for 'std::streampos'
    1 please,be my partner
    1 std::streampos and INT_MAX - incompatible?
    1 www.mundonumismatico.com Monedas del Mundo
    1 you really should read this
     
    T, Jan 10, 2006
    #3
  4. T <> writes:
    > On Tue, 10 Jan 2006 23:52:40 +0100, Michael Mair wrote:
    >> T wrote:
    >>> How can I link a lib statically?

    >>
    >> Note that g++ is used for compilation of C++. In this case, ask in
    >> news:gnu.g++.help

    >
    > Hi, sorry to have posted OT question here. I re-posted it again in
    > gnu.g++.help.
    >
    > However, by taking a look at the recent posts, I get a feeling that the NG
    > is abandoned, and is full of spams. Check the subject list (and count)
    > below.
    >
    >> This seems to be a gcc question -> news:gnu.gcc.help Look into the
    >> newsgroup's archives

    >
    > As I said, I searched and looked before raised the question.
    >
    > thank
    > tong
    >
    > PS.
    >
    > Latest headers in gnu.g++.help (count subject)
    > 1
    > 3 (no subject)
    > 1 A LETTER FROM EURO MILLIONS
    > 1 ADAMS SMITH(NEW YEAR AWARD)

    [94 lines deleted]
    > 1 std::streampos and INT_MAX - incompatible?
    > 1 www.mundonumismatico.com Monedas del Mundo
    > 1 you really should read this


    Yeah, well, thanks so much for reposting their spam here.

    Your question clearly wasn't about C, and probably wasn't about C++
    either. I'm sorry if you're having trouble getting help elsewhere,
    but that doesn't mean it's topical here.

    There were *some* topical posts there. You might try posting and
    seeing if anyone answers. If that doesn't work, there are a number of
    gcc-related mailing lists; you can find them with a quick Google
    search.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Jan 10, 2006
    #4
  5. T

    * Tong * Guest

    On Tue, 10 Jan 2006 23:48:48 +0000, Keith Thompson wrote:

    > Your question clearly wasn't about C, and probably wasn't about C++
    > either. I'm sorry if you're having trouble getting help elsewhere, but
    > that doesn't mean it's topical here.


    ok, thanks for clear it up. I'll try elsewhere.

    --
    Tong
     
    * Tong *, Jan 11, 2006
    #5
  6. T

    Grumble Guest

    Tong wrote:

    > Keith Thompson wrote:
    >
    >> Your question clearly wasn't about C, and probably wasn't about
    >> C++ either. I'm sorry if you're having trouble getting help
    >> elsewhere, but that doesn't mean it's topical here.

    >
    > ok, thanks for clear it up. I'll try elsewhere.


    Try the gcc-help mailing list.
    http://gcc.gnu.org/ml/gcc-help/
     
    Grumble, Jan 13, 2006
    #6
    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. Replies:
    17
    Views:
    1,715
    Chris Riesbeck
    Nov 3, 2003
  2. LinuxN00b

    Statically Linking Libraries

    LinuxN00b, Aug 6, 2003, in forum: C++
    Replies:
    1
    Views:
    359
    Thomas Matthews
    Aug 6, 2003
  3. Replies:
    2
    Views:
    418
    Tom St Denis
    May 30, 2004
  4. Phil Tomson
    Replies:
    0
    Views:
    121
    Phil Tomson
    May 10, 2004
  5. Indigo Casson

    "Statically linking" native extensions.

    Indigo Casson, May 26, 2010, in forum: Ruby
    Replies:
    0
    Views:
    90
    Indigo Casson
    May 26, 2010
Loading...

Share This Page