Re: 'ZeroLink: warning duplicate symbol' Messages.
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.