• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: 'ZeroLink: warning duplicate symbol' Messages.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'ZeroLink: warning duplicate symbol' Messages.


  • Subject: Re: 'ZeroLink: warning duplicate symbol' Messages.
  • From: Drew McCormack <email@hidden>
  • Date: Tue, 8 Jun 2004 22:45:20 +0200

On Jun 8, 2004, at 9:01 PM, email@hidden wrote:

I entered C++ Code into a 'C++ Tool' Project. The Code included the Class definition, Class implementation, and main() Function.

When the 'Build and Run' Button was clicked on the expected Results were presented.
When in 'Terminal' and 'g++ main.cpp -o main' and then './main' entered - again the expected Results are presented.


A new 'C++ Tool' Project was created. The Code of above was entered into two separate Files - 'main.cpp' ['int main(...) Function only - with '"include "Fraction.cpp"' added above the 'int main(...)' Function] and 'Fraction.cpp' [Class definition and Class implementation]

When the 'Build and Run' Button in 'Xcode' is click - the Results are presented but, preceded by a slew of 'ZeroLink: warning duplicate symbol' Messages.
When in 'Terminal', and 'g++ main.cpp -o main' and then './main' are entered - again the expected Results are presented - with not 'ZeroLink' Messages.


Questions:
Why does 'Xcode' display all the 'ZeroLink' Messages - when the Code is placed into separate Files?
What can / must I do to avoid the 'ZeroLink' Messages?


For System, OS, and XCode Version Information, as well as, the actual Code, and displayed Results - please go to '<http://xcode.250free.com/XcodeQ1.html#top>'.
You have to use a Fraction.h file, with only the declaration of the Fraction class. That is what should be included in main.cpp.
What you are doing now is defining the Fraction class twice: once in Fraction.cpp, and once in main.cpp (via the include). Either only include the declaration of the class in main.cpp, via a Fraction.h header file, OR, do not compile Fraction.cpp (ie select it in Xcode, and uncheck the box).
The reason your g++ command line works is that you only compile main.cpp. When you are using Xcode, you are compiling main.cpp and Fraction.cpp, leading to two definitions of Fraction. The command that is equivalent to what Xcode is doing is


g++ main.cpp Fraction.cpp -o main

To avoid this, deselect Fraction.cpp in Xcode.

Drew

---------------------------------------------------------
Drew McCormack

www.maniacalextent.com
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: 'ZeroLink: warning duplicate symbol' Messages.
      • From: email@hidden
References: 
 >'ZeroLink: warning duplicate symbol' Messages. (From: email@hidden)

  • Prev by Date: Variable object not found
  • Next by Date: Re: 'ZeroLink: warning duplicate symbol' Messages.
  • Previous by thread: 'ZeroLink: warning duplicate symbol' Messages.
  • Next by thread: Re: 'ZeroLink: warning duplicate symbol' Messages.
  • Index(es):
    • Date
    • Thread