Programming Help-- C++ (g++) compile error
Posted: Thu Jul 01, 2010 3:02 pm
Alright, so I'm a very new programmer, and the following is what I've produced with a bit of Eric's help:
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:
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;
}
I've no idea what any of this means, is anyone able to help?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$