Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

duplicate symbols for architecture x86_64 error when compiling Qt application

Tags:

c++

macos

qt

I am trying to compile a Qt application on osx using Qt creator. Application successfully compiles in widows. But in mac, it gives following linker errors.

2 duplicate symbols for architecture x86_64
linker command failed with exit code 1 (use -v to see invocation)

Does anybody know a way to check what are the duplicate symbols the linker is complaining about? I used following in my .pro file but no success.

QMAKE_LFLAGS += -v
like image 399
Lahiru Chandima Avatar asked Sep 18 '14 17:09

Lahiru Chandima


2 Answers

Posting comment by N1ghtLight as an answer.

Duplicate symbols found error is a linker error, which says that linker has found more than one symbols with the same name. Following are some common causes for this.

  • You have written a function definition in a header file (outside a class), which is included in two or more cpp files.
  • You have defined a static variable twice.
  • You have written a function definition twice in a cpp file.

You can find out what are the duplicate symbols by checking Compile Output tab in Qt Creator

like image 79
Lahiru Chandima Avatar answered Nov 04 '22 02:11

Lahiru Chandima


In my case, I added duplicate headers at myproject.pro file.

ex) HEADERS += zzzz.h \ 
... a lot of xxxx.h \
zzzz.h (again) 

I deleted duplicate zzzz.h and builded successfully.

like image 33
hjkim Avatar answered Nov 04 '22 02:11

hjkim