3

Hi1 I just created a DLL with GCC. It only contains this simple function:

extern "C" {
    char* Message() {
        return (char*)"Cool";
    }
}

The resulted file's size is 42 Kb and I don't understand why is it so big, when a simple executable that creates and shows a GUI window only weights 8 Kb. Is there a way of reducing the size of the shared library? Why is it so big? Thanks!

UPDATE

If I create the same file with Code::Blocks, it only has 24 Kb. I wonder what way does CB create it in order to achieve that size?

UPDATE

It matters because I want to know that my library doesn't contain unnecessary code. My GCC command to create the DLL is:

gcc -c Source/MyLib.cpp -s -Os -nostartfiles -nostdlib -nodefaultlibs -o MyLib.o
ar  rcs libMylib.a MyLib.o
gcc -shared -o MyLib.dll MyLib.o
4

1 回答 1

2

Add -s to the linking state (gcc -s -shared -o MyLib.dll MyLib.o)

于 2012-05-25T16:53:10.723 回答