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.
Consider we created two files test1.cc and test2.cc. Both having a single line of code.
a-2720@N530 /data1/users/a-2720/samp :ls -lrt test1.cc test2.cc
-rw-rw-r-- 1 a-2720 mcs 21 May 18 06:16 test1.cc
-rw-rw-r-- 1 a-2720 mcs 21 May 18 06:16 test2.cc
a-2720@N530 /data1/users/a-2720/samp :cat test1.cc
#include<iostream.h>
a-2720@N530 /data1/users/a-2720/samp :cat test2.cc
#include<iostream.h>
Thus the files have only only one line inside them
I created a Shared library using these files.
SOLARIS
CC -c -library=iostream -g -mt test1.cc
CC -c -library=iostream -g -mt test2.cc
CC -G -h libtestsolaris.so test1.o test2.o -o libtestsolaris.so -library=iostream
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
LINUX
CC -m32 -c -librar开发者_如何学编程y=iostream -g -mt test1.cc
CC -m32 -c -library=iostream -g -mt test2.cc
CC -m32 -G -h libtestlinux.so test1.o test2.o -o libtestlinux.so -library=iostream
/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.
System Details
/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
-g
option will add debugging information to the executable, which will increase its size. Also turn on the options that control various optimizations.
you could play with nm to see what code is in the library.
- do not build with debug symbols (-g option for gcc)
- strip the symbols from the library
After doing steps 1 and 2, do the comparison.
精彩评论