?
Solved

how to link library

Posted on 2004-10-08
5
Medium Priority
?
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 140 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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

719 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