473,385 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

[g++] library inclusion problem

Hello,

I wrote quite a few c++ programs a some years ago which I compiled
successfully with g++ at the time, but now I forgot how to make them
work, so your help would be greatly appreciated (I had a look at FAQs
but to no avail).

Here's my setup:
1. I have a directory called /home/pindare/mycode/
2. in it there's my file prog.cc
3. there's another directory called /home/pindare/othercode/
4. that one contains mycode.h mycode.cc mycode.o libmycode.a
5. now I want to compile prog.cc using libmycode.a
6. so in a shell I go to /home/pindare/mycode
7. then I type
g++ -I../home/pindare/othercode/ -L../home/pindare/othercode/ -o xprog
prog.cc -lmycode -lm

8. and I get the following message

/usr/bin/ld: cannot find -lmycode
collect2: ld returned 1 exit statuse

I haven't recompiled the mycode library for years and it did work at
the time, so I'm guessing it's a compiler issue, but what exactly?

Regards,
---
PP

Jul 5 '06 #1
2 1413
Pindare wrote:
Hello,

I wrote quite a few c++ programs a some years ago which I compiled
successfully with g++ at the time, but now I forgot how to make them
work, so your help would be greatly appreciated (I had a look at FAQs
but to no avail).
There is something in the FAQ relevant to your question. See:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9
Here's my setup:
1. I have a directory called /home/pindare/mycode/
2. in it there's my file prog.cc
3. there's another directory called /home/pindare/othercode/
4. that one contains mycode.h mycode.cc mycode.o libmycode.a
5. now I want to compile prog.cc using libmycode.a
6. so in a shell I go to /home/pindare/mycode
7. then I type
g++ -I../home/pindare/othercode/ -L../home/pindare/othercode/ -o xprog
prog.cc -lmycode -lm
Why do you give /home/pindare/home/pindare/othercode as library and include
paths? Note that .. is just the parent directory of the current one.
Jul 5 '06 #2

Rolf Magnus wrote:
There is something in the FAQ relevant to your question. See:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9
Oups, sorry, I'm useless! I couldn't find a group that suited gcc in
comp.compilers.* and looked no further. So it's gnu.g++.help then,
thank you.

Regards,
---
PP

Jul 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
by: Reinhold Birkenfeld | last post by:
Hello, at the moment python-dev is discussing including Jason Orendorff's path module into the standard library. Do you have any other good and valued Python modules that you would think are...
16
by: Nathan Funk | last post by:
I used to work as a web designer a couple of years ago, but I haven't been closely in touch in the past years. Has anything changed recently for managing content that is common among many pages...
14
by: Fritz Foetzl | last post by:
I'm flummoxed. I'm a veteran C++ programmer from the Unix/Linux camp, trying to learn Visual C++. I'm trying to build a project in which I need to include one header in a couple of different files,...
5
by: Dave | last post by:
Hello all, To protect against multiple inclusions, it is standard practice to enclose the contents of a header file in a construct like this: #ifndef FOO_INCLUDED #define FOO_INCLUDED .......
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
4
by: s.subbarayan | last post by:
Dear all, How different is a header file from a library file in C?Under what circumstance u go for library and under what circumstance u go for header?Afaik,both have some declarations which can...
10
by: Allerdyce.John | last post by:
I think Smart Pointer library in C++ is implemented using reference count. How does smart pointer library detect if there is a circular reference? and if yes, what does it do about it? Thank...
6
by: techBoy | last post by:
I am looking for a tool that can scan my soyrce code and check if a header file gets included more then once in a sequece of compiled code. Can some one guide me to such a tool !!
6
by: Juha Nieminen | last post by:
Multiple inclusion of the same header file can cause the compilation to fail because of multiple definitions of the same type. That's why it's standard practice to write all headers like this: ...
1
by: RajinCodingForum | last post by:
I have some idea but i am puzzled. As i understand, file inclusion problems like x includes y and y in turn includes x etc. can be avoided by #ifdef preprocessor checks. Can you please explain with...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.