We have a 32bit Gui application created using C++. We ported the application from Solaris to Linux. Issue we are facing is the size of the library and executable is very large in LINUX compared to Solaris.
Red Hat Enterprise Linux 5.4 is the Linux version we using.
Please find a sample dynamic library created. We would like to know the following behavior of LINUX is normal or not.
a-2720@N530 /data1/users/a-2720/samp :cat test1.cc
a-2720@N530 /data1/users/a-2720/samp :cat test2.cc
Thus the files have only only one line inside them
I created a Shared library using these files.
CC -c -library=iostream -g -mt test1.cc
CC -c -library=iostream -g -mt test2.cc
a-2720@N530 /data1/users/a-2720/samp :ls -lrt test1.o test2.o libtestsolaris.so
-rw-rw-r-- 1 a-2720 mcs 20944 May 18 06:16 test1.o
-rw-rw-r-- 1 a-2720 mcs 20944 May 18 06:16 test2.o
-rwxrwxr-x 1 a-2720 mcs 7384 May 18 06:16 libtestsolaris.so
CC -m32 -c -library=iostream -g -mt test1.cc
CC -m32 -c -library=iostream -g -mt test2.cc
/data1/users/adarsh/samp :ls -lrt test1.o test2.o libtestlinux.so
-rw-r--r-- 1 adarsh ifo 20220 May 18 06:44 test1.o
-rw-r--r-- 1 adarsh ifo 20220 May 18 06:44 test2.o
-rwxr-xr-x 1 adarsh ifo 41680 May 18 06:44 libtestlinux.so
Here we can see that the Linux shared library are in much bigger size than solaris once. Please note that the source file for
these libraries are same. Our application uses thousand of files having these header files and hence a notable difference in size occurs.
We would like to know this size difference is a normal behavior of LINUX.
/data1/users/adarsh/samp :cat /etc/*-release Red Hat Enterprise Linux Server release 5.4 (Tikanga)
/data1/users/adarsh/samp :uname -a Linux N280 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
Thanks in advance.
Have you tried using another compiler like g++? g++ has a lot of optimization options, most notably -Os.
I haven't created shared libraries yet, so the following might not be correct or the best way to do it, but it might help you:
in the test-files. The difference is explained here.
It seems to me that you're comping without optmization. -O2 should be the minimum in your case. -Os is another choice.
answered 23 May '11, 17:14