哪个库在 gcc 汇编输出中有 __main 函数引用 [英] What library has the __main function reference in gcc assembly output

查看:73
本文介绍了哪个库在 gcc 汇编输出中有 __main 函数引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用 MinGW 编译一个空的 c 程序时,汇编输出包含该行

When compiling an empty c program using MinGW the assembly output contains the line

call __main

这是哪个图书馆的?我希望与 msvcrt.dll 链接工作(使用 ld 链接),但由于它没有,它必须在别处定义.

what library is this from? I expected linking with msvcrt.dll to work (linking using ld), but as it did not, it must be define elsewhere.

其他地方有许多相关/几乎相同的问题,但没有一个(据我所知,现在已经搜索了一段时间)实际上包含这个问题的答案,所以在标记为重复之前请仔细检查.

There are many related/practically the same question elsewhere, but none of them (as far as I have seen, been searching for a while now) actually contain the answer to this question, so please double check before marking as duplicate.

推荐答案

__main 应该由 MinGW 编译器附带的 libgcc 库提供.

__main should be provided by the libgcc library, which comes with the MinGW compiler.

如果您使用编译器驱动程序(即gcc 命令行工具)链接您的程序,而不是直接调用ld,该库应该会自动添加到链接中.出于此原因和其他几个原因,建议使用编译器驱动程序进行链接.

If you use the compiler driver (that is, the gcc command-line tool) to link your program, rather than invoking ld directly, this library should be automatically added to the link. Using the compiler driver to link is recommended practice for this and several other reasons.

具体取决于您拥有的 MinGW 版本以及它嵌入的 GCC 版本,libgcc 或其中的一部分可能是一个 DLL,如果您要发送 MinGW 编译的可执行文件,则必须捆绑它.

Depending on exactly which version of MinGW you have and which version of GCC it embeds, libgcc or part of it may be a DLL, which you must bundle if you are shipping MinGW-compiled executables.

这篇关于哪个库在 gcc 汇编输出中有 __main 函数引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆