Linking statically

T

T

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
 
M

Michael Mair

T said:
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 -> 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

Cheers
Michael
 
T

T

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 -> 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
 
K

Keith Thompson

T said:
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 -> 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.
 
T

* Tong *

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top