duncan54747
asked on
Cant compile using g++ -O2 or -O3
Hi
I can run my code using O mode but when I try to use the compilers advanced optimization settings I get whole load of funny errors. Any suggestions?
Thanks
Niall
I can run my code using O mode but when I try to use the compilers advanced optimization settings I get whole load of funny errors. Any suggestions?
Thanks
Niall
This isn't all of the errors, just the first few!
pclxb10>make
g++ -o2 csvdemo main.cpp csvparser.cpp
csvdemo: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crt1.o:(.text+0x0): first defined here
csvdemo:(.rodata+0x0): multiple definition of `_fp_hw'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crt1.o:(.rodata+0x0): first defined here
csvdemo: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o:(.fini+0x0): first defined here
csvdemo:(.rodata+0x4): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crt1.o:(.rodata.cst4+0x0): first defined here
csvdemo: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crt1.o:(.data+0x0): first defined here
csvdemo:(.rodata+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/i386-redhat-linux/4.1.2/crtbegin.o:(.rodata+0x0): first defined here
csvdemo: In function `_init':
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The reason for all those errors, is because the compiler compiled the two .cpp files, and then the linker tried to link them together with the csvdemo executable that was there from an earlier build. Obviously these contain the exact same symbols.