English 中文(简体)
与海合会直接创建的减少 DLL
原标题:Reduce size of DLL created directly with GCC

Hi1 我刚刚与海合会创建了一个 DLL。 它只包含一个简单的函数 :

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

结果的文件大小为42 Kb, 我不明白为什么它这么大, 当一个简单的可执行文件创建并显示 GUI 窗口时, 它只显示重量 8 Kb。 是否有办法缩小共享库的大小? 为什么它这么大? 谢谢!

<强> UPDATE

如果我用代码: Blocks 创建相同的文件, 它只有24 Kb 。 我想知道 CB 是如何创建它来达到这个大小的?

<强> UPDATE

这很重要,因为我想知道我的图书馆并不包含不必要的代码。 我创建 DLL 的海合会命令是:

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
最佳回答

向连接状态添加 -s ( gcc -s -s - 共享 - o MyLib.dll MyLib.o )

问题回答

暂无回答




相关问题
gcc -fPIC seems to muck with optimization flags

Following along from this question: how-do-i-check-if-gcc-is-performing-tail-recursion-optimization, I noticed that using gcc with -fPIC seems to destroy this optimization. I am creating a shared ...

Generate assembler code from C file in linux

I would like to know how to generate assembler code from a C program using Unix. I tried the gcc: gcc -c file.c I also used firstly cpp and then try as but I m getting errors. I m trying to build an ...

Getting rid of pre-compiled headers

OK, I have old Metrowerks code for Mac and Windows where the previous developer used pre-compiled headers for every project that this code base builds. How does one get rid of Pre-compiled headers, ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

How to compile for Mac OS X 10.5

I d like to compile my application for version 10.5 and forward. Ever since I upgraded to Snow Leopard and installed the latest XCode, gcc defaults to 10.6. I ve tried -isysroot /Developer/SDKs/...

热门标签