468,458 Members | 1,745 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,458 developers. It's quick & easy.

[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 1275
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

51 posts views Thread by Reinhold Birkenfeld | last post: by
16 posts views Thread by Nathan Funk | last post: by
5 posts views Thread by Dave | last post: by
43 posts views Thread by Steven T. Hatton | last post: by
10 posts views Thread by Allerdyce.John | last post: by
6 posts views Thread by techBoy | last post: by
6 posts views Thread by Juha Nieminen | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.