Page 1 of 1

Programming Help-- C++ (g++) compile error

Posted: Thu Jul 01, 2010 3:02 pm
by Thomas_Bates
Alright, so I'm a very new programmer, and the following is what I've produced with a bit of Eric's help:

Code: Select all

// Star Trek Captain's Log Program
// by Thomas Bates III
// Hosted by Opticon Studios

#include <iostream>
#include <ctime>
#include <cstdlib>
#include <fstream>
using namespace std;

int main()
{
	ofstream CaptainLog;
	CaptainLog.open ("CptLog.txt", ios::in);
	srand(time(NULL));
	int randnum1 = rand() % 2250 + 99999;
	int randnum2 = rand() % 1 + 0;
	int randnum3;
	
	if (randnum2 == 1) randnum3 = rand() % 2 + 0;
	
	else randnum3 = rand() % 9 + 0;
	
	cout << "Captain's Log, Stardate" << randnum1 << "." << randnum2 << randnum3;
	cout << "\n";
	CaptainLog.close();
	
	return 0;
	
}
When I try to compile, the first time it seemed to work; but I'm now getting the same error on compile, and program start. I believe this is a g++ error, and I did not see it on 9.10:
thomas@thomas-desktop:~/Desktop/CaptainLog$ g++ -o cptlog.cpp CptLog
CptLog: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o:(.text+0x0): first defined here
CptLog:(.rodata+0x0): multiple definition of `_fp_hw'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o:(.rodata+0x0): first defined here
CptLog: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crti.o:(.fini+0x0): first defined here
CptLog:(.rodata+0x4): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o:(.rodata.cst4+0x0): first defined here
CptLog: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o:(.data+0x0): first defined here
CptLog: In function `__data_start':
(.data+0x4): multiple definition of `__dso_handle'
/usr/lib/gcc/i486-linux-gnu/4.4.3/crtbegin.o:(.data+0x0): first defined here
CptLog: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crti.o:(.init+0x0): first defined here
/usr/lib/gcc/i486-linux-gnu/4.4.3/crtend.o:(.dtors+0x0): multiple definition of `__DTOR_END__'
CptLog:(.dtors+0x4): first defined here
/usr/bin/ld: warning: Cannot create .eh_frame_hdr section, --eh-frame-hdr ignored.
/usr/bin/ld: error in CptLog(.eh_frame); no .eh_frame_hdr table will be created.
collect2: ld returned 1 exit status
thomas@thomas-desktop:~/Desktop/CaptainLog$
I've no idea what any of this means, is anyone able to help?

Re: Programming Help-- C++ (g++) compile error

Posted: Thu Jul 01, 2010 3:11 pm
by Thomas_Bates
I used the wrong compile command, and started the program with the wrong command, idiot mistakes on my part.

Re: Programming Help-- C++ (g++) compile error

Posted: Thu Jul 01, 2010 3:33 pm
by short
lol, I like it. Pulling random stardates of ones ass haha.

Re: Programming Help-- C++ (g++) compile error

Posted: Thu Jul 01, 2010 5:45 pm
by eatcomics
That's just how he roles :D but change to solved plz

Re: Programming Help-- C++ (g++) compile error

Posted: Fri Jul 02, 2010 6:07 pm
by Live-Dimension
short wrote:lol, I like it. Pulling random stardates of ones ass haha.
Sadly, the stardates on the shows are actually randomly generated too.

Re: Programming Help-- C++ (g++) compile error

Posted: Mon Jul 05, 2010 10:36 am
by Ginto8
Live-Dimension wrote:
short wrote:lol, I like it. Pulling random stardates of ones ass haha.
Sadly, the stardates on the shows are actually randomly generated too.
Srsly? that really is sad.

Re: Programming Help-- C++ (g++) compile error

Posted: Sat Jul 10, 2010 7:17 pm
by Live-Dimension
Well, if you've ever watched TOS, you'll know a lot of stuff doesn't fit the rest of the ST universe. A lot of stuff was scrapped for TNG and Enterprize, but more wasn't. Naturally, the stardates also come from TOS, which was randomly generated back then.