Q_OBJECT throwing ‘undefined reference to vtable’ error [duplicate]

It is because the unit generated by MOC isn’t included in the linking process. Or maybe it isn’t generated at all. The first thing I’d do is to put the class declaration in a separate header file, perhaps the build system isn’t scanning implementation files. Another possibility is that the class in question once didn’t … Read more

Multiple definition of … linker error

Don’t define variables in headers. Put declarations in header and definitions in one of the .c files. In config.h extern const char *names[]; In some .c file: const char *names[] = { “brian”, “stefan”, “steve” }; If you put a definition of a global variable in a header file, then this definition will go to … Read more

file was built for archive which is not the architecture being linked (i386)

After struggling with this same problem and following all the accepted answers of updating build settings, clearing the linker search path, etc.. I finally discovered an answer that worked for me. Before building, make sure you select right type (iPhone Simulator) instead of iOS Device. Then rebuild. Otherwise, you’re trying to use a library built … Read more

Undefined reference to sqrt (or other mathematical functions)

You may find that you have to link with the math libraries on whatever system you’re using, something like: gcc -o myprog myprog.c -L/path/to/libs -lm ^^^ – this bit here. Including headers lets a compiler know about function declarations but it does not necessarily automatically link to the code required to perform that function. Failing … Read more

Trying to include a library, but keep getting ‘undefined reference to’ messages

The trick here is to put the library AFTER the module you are compiling. The problem is a reference thing. The linker resolves references in order, so when the library is BEFORE the module being compiled, the linker gets confused and does not think that any of the functions in the library are needed. By … Read more