Ld /Users/rahulshrestha/Library/Developer/Xcode/DerivedData/101-bdjjlwlibkuaakgjcxqoslsirofh/Build/Products/Debug/101 normal x86_64cd /Users/rahulshrestha/Dropbox/C++/101export MACOSX_DEPLOYMENT_TARGET=10.9/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/rahulshrestha/Library/Developer/Xcode/DerivedData/101-bdjjlwlibkuaakgjcxqoslsirofh/Build/Products/Debug -F/Users/rahulshrestha/Library/Developer/Xcode/DerivedData/101-bdjjlwlibkuaakgjcxqoslsirofh/Build/Products/Debug -filelist /Users/rahulshrestha/Library/Developer/Xcode/DerivedData/101-bdjjlwlibkuaakgjcxqoslsirofh/Build/Intermediates/101.build/Debug/101.build/Objects-normal/x86_64/101.LinkFileList -mmacosx-version-min=10.9 -stdlib=libc++ -Xlinker -dependency_info -Xlinker /Users/rahulshrestha/Library/Developer/Xcode/DerivedData/101-bdjjlwlibkuaakgjcxqoslsirofh/Build/Intermediates/101.build/Debug/101.build/Objects-normal/x86_64/101_dependency_info.dat -o /Users/rahulshrestha/Library/Developer/Xcode/DerivedData/101-bdjjlwlibkuaakgjcxqoslsirofh/Build/Products/Debug/101duplicate symbol _main in:/Users/rahulshrestha/Library/Developer/Xcode/DerivedData/101-bdjjlwlibkuaakgjcxqoslsirofh/Build/Intermediates/101.build/Debug/101.build/Objects-normal/x86_64/main.o/Users/rahulshrestha/Library/Developer/Xcode/DerivedData/101-bdjjlwlibkuaakgjcxqoslsirofh/Build/Intermediates/101.build/Debug/101.build/Objects-normal/x86_64/praca.old: 1 duplicate symbol for architecture x86_64clang: error: linker command failed with exit code 1 (use -v to see invocation)


#include <iostream>using namespace std;int main() {double radius, circumference, area; // Declare 3 floating-point variablesconst double PI = 3.14159265; // Declare and define PIcout << "Enter the radius: "; // Prompting messagecin >> radius; // Read input into variable radius// Compute area and circumferencearea = radius * radius * PI;circumference = 2.0 * radius * PI;// Print the resultscout << "The radius is: " << radius << endl;cout << "The area is: " << area << endl;cout << "The circumference is: " << circumference << endl;return 0;}
2

Best Answer


You can only have one main() - you decide which one you need to keep and which one needs to be deleted. Keep only one page, with the main() method.

Others on the thread have already indicated the issue here. I will try give the context.

When you compile your program the c++ compiler looks for main function definition amongst the object files it has compiled as an entry-point to invoke your program.

As your error indicates the compiler finds 2 main function definition one in praca.o(praca.cpp ?) and the other in main.o(main.cpp ?)

So you have to choose either the main in main.cpp or praca.cpp and remove the other.