Solved

how to link library

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

734 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