我在 Windows 中有一个 MinGW 编译器设置。并进行项目设置,其中一些第三方*.a
文件直接从 Linux 机器复制。
尝试编译一个简单的 C 程序,当我查看*.o
文件的符号表时,它的所有符号名称都有前导下划线。
示例程序:
int main(int argc, char** argv)
{
int xyz=0;
printf("I am Here\n");
}
符号表条目:
部分: Idx 名称大小 VMA LMA 文件关闭 Algn 0 .文本 00000040 00000000 00000000 0000008c 2**2 内容、分配、加载、重新定位、只读、代码 1 .数据 00000000 00000000 00000000 00000000 2**2 分配、加载、数据 2 .bss 00000000 00000000 00000000 00000000 2**2 分配 符号表: [ 0](秒 -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x00000000 abcd01.c 文件 [ 2](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x0000000b **_main** [ 3](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .text AUX scnlen 0x3e nreloc 4 nlnno 0 [ 5](秒 2)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .data AUX scnlen 0x0 nreloc 0 nlnno 0 [ 7](秒 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss AUX scnlen 0x0 nreloc 0 nlnno 0 [ 9](秒 0)(fl 0x00)(ty 20)(scl 2) (nx 1) 0x00000000 ___main AUX tagndx 0 ttlsiz 0x0 lnnos 0 下一个 0 [ 11](秒 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __alloca [ 12](秒 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 **_printf** [.text] 的搬迁记录: 偏移类型值 00000020 DISP32 __alloca 00000025 DISP32 ___main 00000033 dir32 .text 00000038 DISP32 **_printf**
在这里,甚至基本 C 函数都带有下划线。
尝试使用-fno-leading-underscore
,但没有用。
明文版:
$ gcc -v 从 C:/PROGRA~1/GNUCFO~1//ncbin/../lib/gcc-lib/i386-pc-mks/3.3.1/ 读取规范 眼镜 配置:configure --prefix=/usr/gnu i386-pc-mks --enable-languages=c,c+ + --disable-nls --disable-shared --enable-sjlj-exceptions --enable-threads --dis 能够-win32-注册表 线程型号:win32 gcc 3.3.1 版(mingw 特别版 20030804-1)