undefined symbols error in c++

December 2, 2010 at 05:56:30
Specs: Macintosh

Sorry if I'm asking a dumb question, but I've been stuck on this one for quite some time now. So, I'm trying to compile a program using cmake, that calls functions from a videosource.cpp file, with its corresponding videosource.h file.

The compiler finds the file, but when linking makes this error:

Undefined symbols:
"VideoSourceFactory::construct()", referenced from:
_main in main.cpp.o

However, in the videosource.h, the function is defined, as:

class VideoSourceFactory {

Does anyone have an idea what can be causing this kind of errors to happen??

Thanks in advance!

See More: undefined symbols error in c++

Report •

December 2, 2010 at 08:06:53
What you have in the header file is the declaration. Where's the definition?

Report •

December 2, 2010 at 08:53:56
VideoSourceFactory::construct() is not VideoSourceFactory::VideoSourceFactory()

How To Ask Questions The Smart Way

Report •

December 2, 2010 at 23:54:17

Thanks for the answers. It was actually my (double) bad:
- the definition I put as an example was the wrong one, but VideoSourceFactory() was defined in the .h file
- while the directory in which the .h file was included in the project tree, the .h file itself was not explicitly linked, which caused the error.

Anyway, thanks for the quick replys!

Report •

Related Solutions

December 3, 2010 at 00:04:28
That doesn't make sense. You don't link a .h file, you lnk an object file (.o). But if the definition was in the .h file, the compiled object will be in whatever .cpp file included it.

Report •

Ask Question