undefined reference error

V

vfunc

I get an undefined reference error for a definition that clearly looks
like it is in a .h file. So
what can be the cause of an undefined reference error, when this .h
file containing the definition has been included and the namespace has
been declared.

I blame engineers they are all ponsey zealots.
 
V

Victor Bazarov

I get an undefined reference error for a definition that clearly looks
like it is in a .h file.

You cannot put "clearly" and "looks like" in the same sentence. It's
either there or it isn't.
> So
what can be the cause of an undefined reference error, when this .h
file containing the definition has been included and the namespace has
been declared.

The error is on the line 42 of your source code.
I blame engineers they are all ponsey zealots.

Yes. That's it.

V
 
H

Howard

I get an undefined reference error for a definition that clearly looks
like it is in a .h file. So
what can be the cause of an undefined reference error, when this .h
file containing the definition has been included and the namespace has
been declared.

Without seeing the code (or even the specific text of the error), it's
impossible to know. Perhaps, since you use the word "undefined", it's a
link error, not a compile error? You might have declared something but not
defined it. (There is a difference.) Or, you might not have properly
included the source file in your build.

More info, please.
I blame engineers they are all ponsey zealots.

What???


-Howard
 
V

vfunc

Why do you bother responding if that is your attitude? It does clearly
look like the same reference, I cannot say for sure that it is the same
thing, one is a class member and the other is I don't know, the
definition is...

namespace audiere
{
....
class ParameterList {
public:
ParameterList

and the reference to it is said to be...

audiere::parameterList::parameterList(char const*)

by the compiler.

Does that satisfy your curiosity?
 
V

vfunc

The lib is referenced using -L ../lib in the compiler
and the header file included.
 
V

vfunc

"Why do you bother responding if that is your attitude?"
was directed at that Victor guy.
Without seeing the code (or even the specific text of the error), it's
impossible to know.

I think that is the problem with using other peoples code and any
hidden information but then again
not many people have the time to create there own electronics,
operating system, compiler ...
 
V

Victor Bazarov

Why do you bother responding if that is your attitude? It does clearly
look like the same reference, I cannot say for sure that it is the same
thing, one is a class member and the other is I don't know, the
definition is...

namespace audiere
{
...
class ParameterList {
public:
ParameterList

And??? Don't bother. I've lost interest in helping you.
and the reference to it is said to be...

audiere::parameterList::parameterList(char const*)

by the compiler.

Does that satisfy your curiosity?

Yes. Now go solve your own problem. I was curious how far your arrogance
stretched, and you've shown that it stretches too far for my taste.

If you want help, learn to supply enough information. And read the FAQ
(http://www.parashift.com/c++-faq-lite/).
 
D

Daniel T.

I get an undefined reference error for a definition that clearly looks
like it is in a .h file. So
what can be the cause of an undefined reference error, when this .h
file containing the definition has been included and the namespace has
been declared.

Please understand, there are many of us here that are happy to help you,
however your question above is equivalent to the following one, "The
compiler says that my code is broken but everything is right. What is
the problem?"

Trust me, the compiler is right. If it says you have an "undefined
reference error for a definition" then you in fact have one no matter
what you may think.

Now, can we see the exact text of the error message? No one can help you
without it.
 
M

Markus Moll

Hi

I am definitely not an arrogant person.

But you try hard to make other people think you are.
What do you think does "that Victor guy" sound like?

But I'm more and more getting the impression that your only interest is in
trolling... so... feel free.

Markus
 
V

vfunc

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&)'
/cygdrive/c/DOCUME~1/Daniel/LOCALS~1/Temp/ccZxZ4i6.o:mytest.cpp:(.text+0x540):
u
ndefined reference to `audiere::parameterList::parameterList(char
const*)'
/cygdrive/c/DOCUME~1/Daniel/LOCALS~1/Temp/ccZxZ4i6.o:mytest.cpp:(.text$_ZN7audie
re14ThreadedDeviceC1EPNS_11AudioDeviceE[audiere::ThreadedDevice::ThreadedDevice(
audiere::AudioDevice*)]+0xae): undefined reference to
`audiere::AI_CreateThread(
void (*)(void*), void*, int)'
/cygdrive/c/DOCUME~1/Daniel/LOCALS~1/Temp/ccZxZ4i6.o:mytest.cpp:(.text$_ZN7audie
re14ThreadedDeviceD0Ev[audiere::ThreadedDevice::~ThreadedDevice()]+0x5f):
undefi
ned reference to `audiere::AI_Sleep(unsigned int)'
/cygdrive/c/DOCUME~1/Daniel/LOCALS~1/Temp/ccZxZ4i6.o:mytest.cpp:(.text$_ZN7audie
re14ThreadedDeviceD1Ev[audiere::ThreadedDevice::~ThreadedDevice()]+0x5f):
undefi
ned reference to `audiere::AI_Sleep(unsigned int)'
collect2: ld returned 1 exit status
make: *** [mytest] Error 1
 
H

Howard

"Why do you bother responding if that is your attitude?"
was directed at that Victor guy.

What??? Who was _this_ statement directed to?
I think that is the problem with using other peoples code and any
hidden information but then again
not many people have the time to create there own electronics,
operating system, compiler ...

Umm, ok.... still no information here. If you want help, you've got to try
to help us help you.

You could start by quoting relevant portions of the message you're
responding to, and continue by adding any additional information you are
asked for and have access to. For more info on how to properly post to this
newsgroup, see:

http://www.parashift.com/c++-faq-lite/

(esp. section 5.8)

-Howard
 
V

vfunc

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.
You might have declared something but not
defined it. (There is a difference.)

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.

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?
 
D

Daniel T.

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&)'
/cygdrive/c/DOCUME~1/Daniel/LOCALS~1/Temp/ccZxZ4i6.o:mytest.cpp:(.text+0x540):
u
ndefined reference to `audiere::parameterList::parameterList(char
const*)'
/cygdrive/c/DOCUME~1/Daniel/LOCALS~1/Temp/ccZxZ4i6.o:mytest.cpp:(.text$_ZN7aud
ie
re14ThreadedDeviceC1EPNS_11AudioDeviceE[audiere::ThreadedDevice::ThreadedDevic
e(
audiere::AudioDevice*)]+0xae): undefined reference to
`audiere::AI_CreateThread(
void (*)(void*), void*, int)'
/cygdrive/c/DOCUME~1/Daniel/LOCALS~1/Temp/ccZxZ4i6.o:mytest.cpp:(.text$_ZN7aud
ie
re14ThreadedDeviceD0Ev[audiere::ThreadedDevice::~ThreadedDevice()]+0x5f):
undefi
ned reference to `audiere::AI_Sleep(unsigned int)'
/cygdrive/c/DOCUME~1/Daniel/LOCALS~1/Temp/ccZxZ4i6.o:mytest.cpp:(.text$_ZN7aud
ie
re14ThreadedDeviceD1Ev[audiere::ThreadedDevice::~ThreadedDevice()]+0x5f):
undefi
ned reference to `audiere::AI_Sleep(unsigned int)'
collect2: ld returned 1 exit status
make: *** [mytest] Error 1

OK, simple. Your compiler isn't finding the audiere object file. You
will have to ask in a newsgroup that specializes in your particular
compiler to find out how to set it up so that it can find the right file.
 
A

Andre Kostur

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?

Exactly the section he specified. Section 5.8.
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"

The general answer is that you have constructed an identifier that does
not exist in the object code. There, now wasn't that a useful answer?
if you people are not prepared to give a straight forward answer that
question then I am not asking in the right place.

The straightforward answer is probably useless (see the answer above).
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.

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).
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.

Many of us know quite a bit about the error message (including Victor).
We ask the clarification questions so we can show you what's wrong.
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?

Because "the devil is in the details". You apparently think that your
code is perfectly constructed. Your compiler disagrees. The only way
that we can "arbritrate" on who's right (and unfortunately, it's likely
the compiler...) is to see the code. At which point we can then point
out exactly what's wrong (or determine that the problem actually does lie
with the compiler).
 
A

Andre Kostur

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&)'
/cygdrive/c/DOCUME~1/Daniel/LOCALS~1/Temp/ccZxZ4i6.o:mytest.cpp:(.text+
0x540): u
ndefined reference to `audiere::parameterList::parameterList(char
const*)'
/cygdrive/c/DOCUME~1/Daniel/LOCALS~1/Temp/ccZxZ4i6.o:mytest.cpp:(.text$
_ZN7audie
re14ThreadedDeviceC1EPNS_11AudioDeviceE[audiere::ThreadedDevice::Thread
edDevice( audiere::AudioDevice*)]+0xae): undefined reference to
`audiere::AI_CreateThread(
void (*)(void*), void*, int)'
/cygdrive/c/DOCUME~1/Daniel/LOCALS~1/Temp/ccZxZ4i6.o:mytest.cpp:(.text$
_ZN7audie
re14ThreadedDeviceD0Ev[audiere::ThreadedDevice::~ThreadedDevice()]+0x5f
): undefi
ned reference to `audiere::AI_Sleep(unsigned int)'
/cygdrive/c/DOCUME~1/Daniel/LOCALS~1/Temp/ccZxZ4i6.o:mytest.cpp:(.text$
_ZN7audie
re14ThreadedDeviceD1Ev[audiere::ThreadedDevice::~ThreadedDevice()]+0x5f
): undefi
ned reference to `audiere::AI_Sleep(unsigned int)'
collect2: ld returned 1 exit status
make: *** [mytest] Error 1

OK, where are all of the function bodies for audiere::parameterList ?
Also, where are the function bodies for audiere::AI_Sleep ? As Daniel C.
has mentioned, this looks like the compiler (well, linker actually) can't
find the object code for these functions/classes.

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.
 
H

Howard

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?

As I said, check section 5.8, which describes the best way to post here to
get answers to questions.
My qualm with this group is that you sidestep general questions,

That's not our intent. We assumed you wanted specific help with your
problem, and there simply wasn't enough info to go on. So we asked for more
info.
my general question is
"what can be the cause of an undefined reference error"

I gave you a couple "general reasons". If that's all you wanted, then I
guess we're done here...? If you ned more help, then we need more info,
that's all.
if you people are not prepared to give a straight forward answer that
question then I am not asking in the right place.


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.

That's good, but just saying the definition is there doesn't solve the
problem. If you still need help, and you don't want to post all your code
(which is quite reasonable on your part) then your best bet is to try to
recreate the problem in a small separate project, and post _that_ code so
that we can try it out and see for ourselves.
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.

Until you actually posted the error messages, nobody knew for certain what
the error message really was. And without knowing your code, it's just too
hard to tell why you might have gotten an error.
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?

You don't have to do anything, but if you want help, then the easier you
make it for us, the easier we can make it for you.

If you just want a "general" answer, then you might make that very explicit
in your question. We're just trying to help you find the _actual_ answer to
your question, not make random guesses. But I gave you two random guesses.
If those help, then I'm glad I could help. If not, then you need to decide
if you want more help or not, and if you do, then some more effort on your
part will be required.

-Howard
 

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,787
Messages
2,569,629
Members
45,329
Latest member
InezZ76898

Latest Threads

Top