Solved

Cant compile using g++ -O2 or -O3

Posted on 2008-06-14
2
1,148 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
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…
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now