Solved

Cant compile using g++ -O2 or -O3

Posted on 2008-06-14
2
1,169 Views
Last Modified: 2013-12-14
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
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':

Open in new window

0
Comment
Question by:duncan54747
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
ID: 21787705
>> g++ -o2 csvdemo main.cpp csvparser.cpp

Did you mean :

        g++ -o csvdemo main.cpp csvparser.cpp -O2

The -o flag is for renaming the executable (to csvdemo in this case).
The -O2 flag sets the optimization level (notice the upper case O).
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21787709
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.
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
A list of useful business intelligence software.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question