Sunday, November 02, 2014

Compiling Qt code gave: multiple definition of ...

Got an error when compiling our code:

In Windows 7 and visual studio, I at first did not notice the problem, but it was giving a warning:
LNK4042: object specified more than once; extras ignored

In Linux and gcc it gave an error, so I could not compile the code:
multiple definition of `<constructor of class>'
collect2: ld returned 1 exit status

I took som time to figure it out, but turned out to be a bad merge in subversion, 
the *.pro file had the same class twice in

HEADERS += \ Class1.h /
                         Class1.h
SOURCES += \ Class1.cpp /
                         Class1.cpp

Rremoving the second time the class name where entered in the *.pro file solved the problem. See http://stackoverflow.com/questions/4722400/qt-compiler-warning-overriding-commands-for-target-ignoring-old-commands-for 

1 comment:

top 10 essay writing sites said...

Whoa, a really amazing trip you had mate. your blog is surely one of the best places out there and I will visit it one day for sure. Glad you enjoyed a lot and hoping to see more pictures soon.