Problems with GNU linker

L

luca

Hi,

i have a problem with linking under linux. I have written a C++
library and
a C++ program that uses that library (i use Eclipse IDE under Mandriva
under Virtual Box..).
I succesfully compile the library, obtaining the file libfvlib.a (one
under the Debug directory,
the other under the Release directory).

After that, i have created a new C++ project that uses that library.
I have added the library path of the debug (release) version of
libfvlib.a for the debug (release) version
of the program. I have added the .a file with -l option (to be used in
the linking process).

My program compiles but does not link. I obtain this error:

**** Build of configuration Debug for project pmrplib ****
make all
Building target: pmrplib
Invoking: GCC C++ Linker
g++ -L/home/luca/Sviluppo/projects/pmrplib/fvlib/Debug -o"pmrplib" ./
cpmrplib.o ./cpmrp.o ./main.o -llibfvlib.a
/usr/bin/ld: cannot find -llibfvlib.a
collect2: ld returned 1 exit status
make: *** [pmrplib] Error 1

pmrplib is the program name. It must be created linking togheter the
following files:
cpmrplib.o cpmrp.o main.o libfvlib.a (plus all the default
libraries...).

But the linker (ld) cannot find the file libfvlib.a, even if it is
specified the path where to found it.

Help!

Luca

Ps.
I have tried to use -L/home/luca/Sviluppo/projects/pmrplib/fvlib/
Debug/ , that is, i have added the final / , but didn't work...
 
V

Victor Bazarov

Hi,

i have a problem with linking under linux. I have written a C++
library and
a C++ program that uses that library (i use Eclipse IDE under Mandriva
under Virtual Box..).
I succesfully compile the library, obtaining the file libfvlib.a (one
under the Debug directory,
the other under the Release directory).

After that, i have created a new C++ project that uses that library.
I have added the library path of the debug (release) version of
libfvlib.a for the debug (release) version
of the program. I have added the .a file with -l option (to be used in
the linking process).

My program compiles but does not link. I obtain this error:

**** Build of configuration Debug for project pmrplib ****
make all
Building target: pmrplib
Invoking: GCC C++ Linker
g++ -L/home/luca/Sviluppo/projects/pmrplib/fvlib/Debug -o"pmrplib" ./
cpmrplib.o ./cpmrp.o ./main.o -llibfvlib.a
/usr/bin/ld: cannot find -llibfvlib.a

Try putting that command line option *before* the first .o file in your
list. And next time do ask in the newsgroup where this is on topic,
like 'gnu.gcc.help'.

And do 'man g++' every morning for about fifteen minutes.
collect2: ld returned 1 exit status
make: *** [pmrplib] Error 1

[...]

V
 
M

Marc

luca said:
g++ -L/home/luca/Sviluppo/projects/pmrplib/fvlib/Debug -o"pmrplib" ./
cpmrplib.o ./cpmrp.o ./main.o -llibfvlib.a

-llibfvlib.a doesn't make sense (see the documentation of either g++ or
ld). Use -lfvlib or /path/to/libfvlib.a .

Note: if there is no code involved (or pattern or something like that),
it is likely not a c++ question.
 
L

luca

luca  wrote:

-llibfvlib.a doesn't make sense (see the documentation of either g++ or
ld). Use -lfvlib or /path/to/libfvlib.a .

Note: if there is no code involved (or pattern or something like that),
it is likely not a c++ question.

I have written in the wrong newsgroup. Sorry.
And thanks for the replies
 
J

Jorgen Grahn

.
Try putting that command line option *before* the first .o file in your
list. And next time do ask in the newsgroup where this is on topic,
like 'gnu.gcc.help'.

Or rather the group for whatever build system he uses. Eclipse?
The messages above seem to be part GNU make, and part something
horrible that's completely alien to me.

/Jorgen
 
J

James Kanze

Which command line option? Not the -l, certainly. (-l
specifies a library. And Unix linkers process libraries in the
order they see them, so libraries must be specified after the
object files.)

And just for the record (because the following comment is
correct), -lxyz causes libxyz.a or libxyz.so to be included;
unless he really has a library names liblibfvlib.a.a or
liblibfvlib.a.so, what he probably wants is -lfvlib.

Well, reading the manual would help for starters---there's
really no need for a newsgroup at all. (But if there is, then
a g++ group would be most appropriate.)
Or rather the group for whatever build system he uses. Eclipse?
The messages above seem to be part GNU make, and part something
horrible that's completely alien to me.

The error message is quite clearly from /usr/bin/ld. The Unix
linker, invoked indirectly by g++. (And while GNU make
certainly is horrible in some ways, there doesn't seem to be any
other game in town. At least, I've yet to find another build
tool that actually works.)
 
J

Jorgen Grahn

....


The error message is quite clearly from /usr/bin/ld. The Unix
linker, invoked indirectly by g++.

Yes, but something is feeding the linker strange command-line
arguments. For example the absolute paths and the odd quoting.
If the build system is one of those Visual Studio-style "wizards",
that's where the change has to be made ...
(And while GNU make
certainly is horrible in some ways, there doesn't seem to be any
other game in town. At least, I've yet to find another build
tool that actually works.)

You misunderstood -- I share your feelings about GNU make, and
my "something horrible" referred to whatever software printed e.g.

Invoking: GCC C++ Linker

which looks very odd to me (if you're going to emit superfluous
messages, you might as well say something useful, like "linking
pmrplib").

/Jorgen
 
S

spacemoose

I'm curious, have you ever tried the boost build system, and what do you
think of it?
 
E

Ebenezer

That was from Kanze not Jorgen.

I'm curious, have you ever tried the boost build system, and what do you
think of it?

I am able to use it, but it should be recalled that much of Boost
is header only -- they may not have the best build system around
as they frequently take a side step around the build process.


Brian Wood
Ebenezer Enterprises
http://webEbenezer.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top