undefined reference error

D

Daniel T.

There are alot of sections in that faq, most of them are not relevant
to my query. Where is that info you are refering to?
My qualm with this group is that you sidestep general questions,
my general question is
"what can be the cause of an undefined reference error"
if you people are not prepared to give a straight forward answer that
question then I am not asking in the right place.

The straight forward answer is: Your code makes a reference to something
that isn't defined.

Did you notice how easy it was for me to answer the question when you
actually produced the error message rather than the general question
above (in which the answer is obvious?)
Thanks for that Howard. I checked this and it made no difference, I
have included the .h file of the cpp file that contains the definition.

The only info I've got from all this is that there are other people
hunched over there computers who don't seem to know any more than I do
about this particular error message.

We know a lot about that particular error message, unfortunately it was
like pulling teeth to get you to actually *show* us the error message.
Why should I have divulge my knowledge, or lack of it to elicit a
useful answer?
Why should people have to post their exact code / compiler setup to get
an answer?

"I have a question. What's the answer?" "Why should I have to explain
what the question is or why I am asking? Just answer the question
already!" Bet you can't answer it...
 
D

Daniel T.

Andre Kostur said:
So far you've told the compiler to compile mytest.cpp, and to make an
executable. You've mentioned where your libraries are, but you haven't
told the compiler which libraries to use.

My guess is he never compiled the audiere library after he d/l'ed it
from sourceforge.
 
D

Daniel T.

Andre Kostur said:
Then there is probably something you are failing to see. Can't see the
forest for the trees, and that sort of thing. Kindof a form of tunnel
vision where you are reading what you want to read, not what's on the
screen (note that this isn't a criticism or failing of you, I'm sure
quite a few of us have spent a long time (OK, probably the first time you
encounter it) trying to track down a compiler problem which worked out to
be a missing semicolon somewhere).

I remember once spending two weeks (at 40 hrs/week) tracking down an
error that resolved to a '2' in the code instead of a '4'. (It was
causing memory overwrites.) My boss was very unhappy, I'm glad I didn't
write the original code. :-/
 
A

Andre Kostur

I remember once spending two weeks (at 40 hrs/week) tracking down an
error that resolved to a '2' in the code instead of a '4'. (It was
causing memory overwrites.) My boss was very unhappy, I'm glad I
didn't write the original code. :-/

My favourite is spending a day and a half trying to figure out why my
program was crashing when I was calling a 3rd party library. After large
amounts of frustration and finally resorting to printf's all over the
place (OK, this was originally in C, but is perfectly applicable to C++),
I found out that one of my pointers was NULL. So, as I was yelling to
myself "That pointer can't POSSIBLY be NULL!!! I check it for NULL right
THERE!" as I pointed to the following short code block:

if (ptr = NULL)
{
return;
}

I then proceeded to profusely swear at myself....... (this was before the
compiler would warn me about those sorts of accidental code
constructs....)
 
?

=?iso-8859-1?q?Stephan_Br=F6nnimann?=

Victor said:
The error is on the line 42 of your source code.
Just for the fun of it: what's behind the magic number 42?
It's now the 2nd time within a few days I've seen it.
Could I use my personal favorite 27 instead (smiling)?
Cheers, Stephan
 
H

Howard

Stephan Brönnimann said:
Just for the fun of it: what's behind the magic number 42?
It's now the 2nd time within a few days I've seen it.
Could I use my personal favorite 27 instead (smiling)?
Cheers, Stephan

Check (or Google) "The Hitchhiker's Guide to the Galaxy". It's a _very_
important number! :)

-Howard
 
?

=?iso-8859-1?q?Stephan_Br=F6nnimann?=

Howard said:
Check (or Google) "The Hitchhiker's Guide to the Galaxy". It's a _very_
important number! :)

Thanks Howard, I got it. I've read all the books but I had to google
Stephan :)
 
?

=?iso-8859-1?q?Stephan_Br=F6nnimann?=

I am only looking at the top error at this time (5 lines down)

$ make
g++ mytest.cpp -I ../src -L ../lib -o mytest.exe
/cygdrive/c/DOCUME~1/Daniel/LOCALS~1/Temp/ccZxZ4i6.o:mytest.cpp:(.text+0x492):
u
ndefined reference to
`audiere::NullAudioDevice::create(audiere::parameterList c
onst&)' [snipped]
collect2: ld returned 1 exit status
make: *** [mytest] Error 1

I was in this thread for about 10 minutes wondering if ever you'd post
the compiler messages. Toghether with your statement "all the library
stuff is there" the problem is immediately clear after I see the
command line: You never link against the library.

Regards, Stephan
 
R

red floyd

Andre said:
[story redacted]

if (ptr = NULL)
{
return;
}

I then proceeded to profusely swear at myself....... (this was before the
compiler would warn me about those sorts of accidental code
constructs....)

Reminds me of the very first piece of code I wrote as a professional (as
opposed to a student. This was back in '84, so it was C, not C++...

int index;
/* ... */
for (index = 0 ; index < NUM_ELEMS; ++index);
{
some_array[index].somefield = INITIAL_VALUE;
}

You could hear the swearing four corridors down when I finally found the
bug... :)
 
R

red floyd

Howard said:
Check (or Google) "The Hitchhiker's Guide to the Galaxy". It's a _very_
important number! :)

-Howard

Perhaps as an alternative, we could tell people that they have errors on
lines 4, 8, 15, 16, 23, and 42?
 
V

vfunc

So how do I link a file ? In this case say that I am including
"audiere.h" and in audiere.cpp there is a reference to device.cpp and
device.cpp is included at the top of audiere.cpp.
 
V

vfunc

"In article <[email protected]>,
Andre Kostur said:
So far you've told the compiler to compile mytest.cpp, and to make an
executable. You've mentioned where your libraries are, but you haven't
told the compiler which libraries to use.

My guess is he never compiled the audiere library after he d/l'ed it
from sourceforge"

There are different versions of the source.
1 is does not compile withoug java, xpcom and VC6. At least that is if
you want to bind it to java and xpcom, VC6 I don't know. Another file
has the windows source and this already has executables and a lib file,
do I need to recompile this?
 
V

vfunc

"Markus Moll
Feb 6, 6:45 pm show options

Thanks for the confirmation. "


How can your file welcome me? You use too many similies or labels,
talk in English! I don't understand what you are on about.
 
A

Andre Kostur

So how do I link a file ? In this case say that I am including
"audiere.h" and in audiere.cpp there is a reference to device.cpp and
device.cpp is included at the top of audiere.cpp.

Now you're getting beyond the scope of this newsgroup. Time to head over
to gnu.gcc.help for more detailed (and implementation-specific) answers to
your questions. comp.lang.c++ is for discussing the language itself. How
to use a specific compiler is better served in a newsgroup dedicated to
that compiler.
 
V

vfunc

Link as in
g++ mytest.cpp -I ../src ../lib/audiere.lib -o mytest.exe
or
g++ mytest.cpp -I ../src -L ../lib/audiere.lib -o mytest.exe

neither of these worked there were still unresolved references.
I think the problem is that
there are includes off includes in this project and these are not being
linked.
 
V

vfunc

Victor Bazarov said:
The error is on the line 42 of your source code.

Just for the fun of it: what's behind the magic number 42?
It's now the 2nd time within a few days I've seen it.
Could I use my personal favorite 27 instead (smiling)?
Cheers, Stephan "


42 is the answer to everything in the story, but if I remember
correctly it originates in from a game of scrabble. I guess Adams got
the idea from 41 which has some unusual mathematical properties. Phhh,
what the hell do I know anyway?
 
J

Jim Langston

Just for the fun of it: what's behind the magic number 42?
It's now the 2nd time within a few days I've seen it.
Could I use my personal favorite 27 instead (smiling)?
Cheers, Stephan "


42 is the answer to everything in the story, but if I remember
correctly it originates in from a game of scrabble. I guess Adams got
the idea from 41 which has some unusual mathematical properties. Phhh,
what the hell do I know anyway?

Umm.. no. Arther Dent got the question to the answer 42 from a game of
scrabble. Seems the earth was just a hugh computer built to find out what
the true question to the answer 42 was. Kinda funny actually, I won't say
what the true question was cause it's a spoiler, and people really should
read the Hitchhikers trilogy (with 4 books in it).
 
V

vfunc

Well some people have turned that idea on its head, if they run a
simulation say like a climate model for a period of time and then look
at the difference between the climate model and the simulation then in
a way... like...
 
S

Sjouke Burry

Just for the fun of it: what's behind the magic number 42?
It's now the 2nd time within a few days I've seen it.
Could I use my personal favorite 27 instead (smiling)?
Cheers, Stephan "


42 is the answer to everything in the story, but if I remember
correctly it originates in from a game of scrabble. I guess Adams got
the idea from 41 which has some unusual mathematical properties. Phhh,
what the hell do I know anyway?
"the hitchhikers guide to the galaxy" SF book carries
a story about a gigacomputer calculating the answer
to everything.
It tells them : 42.
When people complained about the answer, the computer
told them they should have asked the right question.
 

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,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top