Lahiru Chandima
Lahiru Chandima

Reputation: 24068

duplicate symbols for architecture x86_64 error when compiling Qt application

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

Upvotes: 7

Views: 13158

Answers (2)

hjkim
hjkim

Reputation: 31

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.

Upvotes: 3

Lahiru Chandima
Lahiru Chandima

Reputation: 24068

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

Upvotes: 11

Related Questions