Error:undefined reference to..
-
i am trying build the project i am getting "undefined reference " error
but i have written the declaration and definition bothi have tried changing the order of included header file
i have tried cleaning the project and run qmake option as well
in one of the post it was suggested to remove any function definition outside the class that also i did but no luckbut the same source code is working fine in visual studio i don't understand why it is giving this error here
please somebody help me resolve this (i cannot share the code here sorry for that)
thank you in advance -
i am trying build the project i am getting "undefined reference " error
but i have written the declaration and definition bothi have tried changing the order of included header file
i have tried cleaning the project and run qmake option as well
in one of the post it was suggested to remove any function definition outside the class that also i did but no luckbut the same source code is working fine in visual studio i don't understand why it is giving this error here
please somebody help me resolve this (i cannot share the code here sorry for that)
thank you in advance -
i am trying build the project i am getting "undefined reference " error
but i have written the declaration and definition bothi have tried changing the order of included header file
i have tried cleaning the project and run qmake option as well
in one of the post it was suggested to remove any function definition outside the class that also i did but no luckbut the same source code is working fine in visual studio i don't understand why it is giving this error here
please somebody help me resolve this (i cannot share the code here sorry for that)
thank you in advance@seok said in Error:undefined reference to..:
"undefined reference "
This error means that the source code file containing the undefined symbols is not linked (actually the object file created from that source code file).
As @JonB suggested provide more information. -
@seok said in Error:undefined reference to..:
"undefined reference "
This error means that the source code file containing the undefined symbols is not linked (actually the object file created from that source code file).
As @JonB suggested provide more information.@jsulm
I didn't even know for sure whether at least some compilers would give an Undefined reference to just for a missing symbol in a file at compile time, likeint z = something_undefined
? But it seems this does only come from the linker, the compiler must say something else for that, like Undeclared ... instead? -
@seok said in Error:undefined reference to..:
"undefined reference "
This error means that the source code file containing the undefined symbols is not linked (actually the object file created from that source code file).
As @JonB suggested provide more information.@jsulm @JonB i am really sorry i know that it is wrong of me to not provide the code but i cannot really provide the code and as for the error
"undefined reference to myfilter"
where myfilter is a object of the class filter which is defined in filter.h file and the definition for the functions inside the class are written in filter.cpp fileand in other file i am using myfilter object by using extern keyword
-
@jsulm @JonB i am really sorry i know that it is wrong of me to not provide the code but i cannot really provide the code and as for the error
"undefined reference to myfilter"
where myfilter is a object of the class filter which is defined in filter.h file and the definition for the functions inside the class are written in filter.cpp fileand in other file i am using myfilter object by using extern keyword
@seok
Could you clarify that you get this error message when the build process tries to link your object files together (after all files have been compiled), and not at compile-time, when the build is running the compiler on your source files?Assuming that is the case, the first possibility is the
filter.o
/.obj
to be generated from thefilter.cpp
is not being linked with. Look carefully at your linker command line: do you see that object file at all there? This would sound like the only possibility if the sources really do work in Visual Studio.The next possibility is check 100 times that the spelling, including case, is identical where defined and where used in your source code.
The next possibility is that you only have
extern Filter *myfilter
in your file(s). You must have some one place, in a.cpp
file, which defines storage for the object, likeFilter *myfilter
, noextern
. -
@seok
Could you clarify that you get this error message when the build process tries to link your object files together (after all files have been compiled), and not at compile-time, when the build is running the compiler on your source files?Assuming that is the case, the first possibility is the
filter.o
/.obj
to be generated from thefilter.cpp
is not being linked with. Look carefully at your linker command line: do you see that object file at all there? This would sound like the only possibility if the sources really do work in Visual Studio.The next possibility is check 100 times that the spelling, including case, is identical where defined and where used in your source code.
The next possibility is that you only have
extern Filter *myfilter
in your file(s). You must have some one place, in a.cpp
file, which defines storage for the object, likeFilter *myfilter
, noextern
.@JonB yes i am getting this error when the build process tries to link the object files together
and how do i check the whether it is being linked or not (i don't know how to check the linker stage output in qt)
(sorry for the late replay since i am a new user i can only post after 600 secs)
-
@JonB yes i am getting this error when the build process tries to link the object files together
and how do i check the whether it is being linked or not (i don't know how to check the linker stage output in qt)
(sorry for the late replay since i am a new user i can only post after 600 secs)
@seok said in Error:undefined reference to..:
(i don't know how to check the linker stage output in qt)
Look at the build/compile output pane in Qt Creator. You should be seeing it go past every time you build, so you really should be aware of it.
-
@seok said in Error:undefined reference to..:
(i don't know how to check the linker stage output in qt)
Look at the build/compile output pane in Qt Creator. You should be seeing it go past every time you build, so you really should be aware of it.
-
@JonB yes i tried build now and the problem lies at the linker stage
and i do have a .cpp file, which defines storage for the object, like Filter *myfilter without extern
@seok said in Error:undefined reference to..:
@JonB yes i tried build now and the problem lies at the linker stage
As stated: look at the complete linker line issued, does it include the object file for
filter
, that would be the simplest thing to be missing? -
@seok said in Error:undefined reference to..:
@JonB yes i tried build now and the problem lies at the linker stage
As stated: look at the complete linker line issued, does it include the object file for
filter
, that would be the simplest thing to be missing? -
@jsulm
I didn't even know for sure whether at least some compilers would give an Undefined reference to just for a missing symbol in a file at compile time, likeint z = something_undefined
? But it seems this does only come from the linker, the compiler must say something else for that, like Undeclared ... instead?@JonB Yes, all the compiler needs is to know the type of the symbol. Or, in case of forward declaration, only that it exists and is a data structure (class/struct). But the linker needs the actual definitions to be able to point to them in the binaries (for example it needs to know where a function is to be able to put the address to it where it is called).
-
@JonB sorry for updating this late i was not doing well
my problem solved by deleting the Filter myfilter (in the other .cpp file) and defining it again i don't know what was the problem ( i dint change anything just defined it again)
but i am really thankfull for all of your help