Solved

how to link library

Posted on 2004-10-08
5
231 Views
Last Modified: 2010-04-22
hello, all,
 
  i have a library "LibFirst.a", saved in "./Lib", and a source file saved in "./Cpp", is it possible to link them into an exe, how the command look? By the way, i am going to use g++.

Thanx in advance

kim
0
Comment
Question by:kim_wei
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:stefan73
ID: 12257906
Hi kim_wei,
Yes, like

g++ -L./Lib ./Cpp/your_source.cpp -o your_binary -lFirst

Be careful that libararies start with "lib", not "Lib". Linux is case-sensitive with file names!

Cheers!

Stefan
0
 

Author Comment

by:kim_wei
ID: 12274375
hello, stefan,

  thanx a lot, however, i just forgot to mention that in the cpp file is there a header file included "Child.h", which is saved in "./Inc", i did try several commands like following, they did not seem to work, any help?

1.)
g++ -I./Inc -L./Lib ./Cpp/Main.cpp -o test -Imy

2.) g++ -L./Lib ./Inc ./Cpp/Main.cpp -o test -Imy

kim
0
 
LVL 4

Expert Comment

by:pankajtiwary
ID: 12283556
Hi kim_wei,

Just like you tried -L flag for library, just try -I for include files.

g++ -I./Inc -L./Lib ./Cpp/your_source.cpp -o your_binary -lFirst

Have fun!!!
0
 
LVL 4

Accepted Solution

by:
pankajtiwary earned 35 total points
ID: 12283561
Sorry, just a bit late...:-))
0
 
LVL 12

Expert Comment

by:stefan73
ID: 12285277
yes, with an exact copy & paste of my text :-/
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now