Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sari210

macrumors newbie
Original poster
Jun 8, 2009
9
0
St. Paul, MN
I keep getting this error when I try to run a program I have written in Xcode. I know the problem works because my co-worker can get it to run on his PC. Any help you can offer is greatly appreciated.

This is the error:

Command/Developer/usr/bin/g++-4.0 failed with exit code 1


Thank you!!
 
Might be useful if you actually supply the command line you are using. All that tells me is that gcc failed.
 
I keep getting this error when I try to run a program I have written in Xcode. I know the problem works because my co-worker can get it to run on his PC. Any help you can offer is greatly appreciated.

This is the error:

Command/Developer/usr/bin/g++-4.0 failed with exit code 1


Thank you!!

Command/Developer/usr/bin/g++-4.0 failed with exit code 1 is not the error. It is what XCode says whenever _anything_ goes wrong, so there is no information here whatsoever.

Any compiler error messages, or linker error messages?
 
My guess it is a linker error message. But what do I do to fix it seeing it worked on Dev C++ from my friend?


Here is the full error message:

Linking/Users/sjahnke2008/C++/particles_in_ring/build/Debug/particles_in_ring.app/Contents/MacOS/particles_in_ring (1 error)

duplicate symbol TApplication::Init(__CFString const*, __CFString const*)in /Users/sjahnke2008/C++/particles_in_ring/build/particles_in_ring.build/Debug/particles_in_ring.build/Objects-normal/i386/TApplication-8969F669.o and /Users/sjahnke2008/C++/particles_in_ring/build/particles_in_ring.build/Debug/particles_in_ring.build/Objects-normal/i386/TApplication-8969F669.o
 
Sounds like one source file is added to the project twice..? Or there really are two Init() methods in one source file, which makes it strange that it does work on your colleague's machine.
 
Dump the code of the project, or zip it up and post it. I can't tell you based upon that linker message.
 
So Here is the code, I just copied and pasted it. If there is a better way to do this let me know. The code isn't 100% complete. I don't have it outputting the data yet or have it linked with the random number generator I want to use. Maybe that is the problem. I don't know. Thanks everyone for your help.

//
// The purpose of this program is to find the probabilities
// that Number of Particles will exist in the nth Spaces of
// the ring lattice with nNumberofSpaces
//
//

#include <Carbon/Carbon.h>
#include "TApplication.h"
#include "TWindow.h"
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

double ran2();

int main()
{
int* Ring;
int* Location;
int numberOfSpaces = 0, numberOfParticles = 0, monteCarlo = 0, choice = 0;
char programEnd = 'R';
double alpha = 0, success = 0;
srand(time(0));

do
{
cout << "Enter the Number of Spaces in the Ring:" ;
cin >> numberOfSpaces;

cout << "Enter the number of particles: ";
cin >> numberOfParticles;

cout << "Choose a number, up to one decimal place to be alpha,\n"
<< "the rate at which the particles can move:";
cin >> alpha;

cout << "Enter the number of steps that you want the process to complete:";
cin >> monteCarlo;

// Creates Ring
Ring = new int[numberOfSpaces];
for(int i = 0; i < numberOfSpaces; i++)
{
Ring = 0;
}

//Places particles in the ring
for (int i = 1; i == numberOfParticles; i++)
{
Ring[i-1] = i;
}

//Stores Particle Placement on the Ring
Location = new int[numberOfParticles + 1];
for(int i = 0; i == numberOfParticles; i++)
{
Location = i-1;
}

//Runs the MonteCarlo Steps
for (int i = 0; i < monteCarlo; i++)
{
for (int i2 = 0; i2 < numberOfParticles; i2++)
{
choice = random() % numberOfParticles + 1;
if (Location[choice] != (Location[choice + 1] - 1))
{
success = random() % 100 + 1;
if(alpha >= success)
{
Ring[Location[choice] + 1] = choice;
Ring[Location[choice]] = 0;
Location[choice]++;
if (Location[choice] = numberOfSpaces - 1)
{
Location[choice] = 0;
}
}
}
}
}
cout << "Program is Finished. Enter R to rerun:" ;
cin >> ProgramEnd;
delete [] Ring;
Ring = NULL;
}
while ((rrogramEnd == 'R') || (programEnd == 'r'));
return 0;
}

double ran2()
{
int RandomNumber = 0;
RandomNumber = rand();
return RandomNumber;
}
 
I'd start fresh with a new project, starting with "New Project" -> "Command Line Tool" -> "C++ Tool", and not "Application" -> "Carbon C++ Application".
 
Code:
		//Places particles in the ring
		for (int i = 1; i == numberOfParticles; i++)
		{
			Ring[i-1] = i;
		}

Finding out yourself what this bit of your code does should be very educational.
 
I'd start fresh with a new project, starting with "New Project" -> "Command Line Tool" -> "C++ Tool", and not "Application" -> "Carbon C++ Application".

So just that alone made a world of difference. After walking through my code with someone who is far better at C++ than I, I was able to get my program fixed. Thanks!

P.S. I ended up fixing that other stuff too.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.