This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

program doesn't work with -O2


I'm writing on a c++ program which I recently switched from hand written makefiles to the gnu autotools. This was not that easy as I had expected, as the program is about 25 000 lines. Finally it works, but only when compiled completly without optimazation. When I try for example
make clean; make CXXFLAGS="-O2" I get hundreds of messages like this one from the linker:


/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5/../../../../i686-pc-linux-gnu/bin/ld: `.gnu.linkonce.t._ZN5boost9date_time23gregorian_calendar_baseINS0_19year_month_day_baseINS_9gregorian9greg_yearENS3_10greg_monthENS3_8greg_dayEEEmE16end_of_month_dayES4_S5_' referenced in section `.rodata' of interface/shiftTable/lib_shifttable.a(lib_shifttable_a-dateFields.o): defined in discarded section `.gnu.linkonce.t._ZN5boost9date_time23gregorian_calendar_baseINS0_19year_month_day_baseINS_9gregorian9greg_yearENS3_10greg_monthENS3_8greg_dayEEEmE16end_of_month_dayES4_S5_' of interface/shiftTable/lib_shifttable.a(lib_shifttable_a-dateFields.o)

This messages don't appear when I compile without optimisation. Besides the resulting exectutable is more or less useless because it contains the strange bugs - bugs which are not there when compiled for example with CXXFLAGS="".

Maybe someone can give me a hint what I'm doing wrong.

Here is some additional information, which may or may not be usefull:

I'm using gcc-3.3.5.

I'm using the following libraries:
1.)boost::smart_ptr - from boost-1.32.0
2.)boost::spirit - from boost-1.32.0
3.)boost::date_time - from boost-1.32.0
4.)sqlite-2.8.15
5.)gtkmm-2.4.8

My program is organized into subdirectories. A typical Makefile.am for a sub-dir looks like this:

#################################################################################
noinst_LIBRARIES = lib_shifttable.a

lib_shifttable_a_SOURCES = \
tableField.hpp tableField.cc \
textField.hpp textField.cc \
coloredTextField.hpp coloredTextField.cc \
workerScheduleField.hpp workerScheduleField.cc \
poolScheduleField.hpp poolScheduleField.cc \
statFields.hpp statFields.cc \
dateFields.hpp dateFields.cc \
shiftTable.hpp shiftTable.cc \
shiftTableBox.hpp shiftTableBox.cc \
monthBox.hpp monthBox.cc
lib_shifttable_a_CXXFLAGS = $(GTKMM_CFLAGS)
################################################################################


Linkage is done through the following command:
*g++ -O2 -o dpm dpm-main.o dataStorage/lib_datastorage.a utility/lib_utils.a organizer/lib_organizer.a manpower/lib_manpower.a labourLaw/lib_labourlaw.a schedule/lib_schedule.a helperFunctions/lib_helperfunctions.a shared/lib_shared.a interface/mainWindow/lib_mainwindow.a interface/listView/lib_listview.a interface/attributeWindow/lib_attributewindow.a interface/shiftTable/lib_shifttable.a interface/misc/lib_misc.a htmlExport/lib_htmlexport.a messageMem/lib_messagemem.a -lsqlite -L/usr/lib -lboost_date_time -Wl,--export-dynamic -lgtkmm-2.4 -lgdkmm-2.4 -latkmm-1.6 -lgtk-x11-2.0 -lpangomm-1.4 -lglibmm-2.4 -lsigc-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0


thanks,
            antonio
*


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]