Solved

how to link library

Posted on 2004-10-08
5
232 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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 demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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