crt0是否加载msvcrt.dll? [英] Does crt0 load msvcrt.dll?

查看:49
本文介绍了crt0是否加载msvcrt.dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚如何将标准C函数(例如 printf())加载到Windows环境中的内存中.我知道 crt0.obj 准备堆栈,调用 int main(int argc,char ** argv),然后使用main返回的退出代码退出进程./p>

我还听说C标准函数位于名为 msvcrt.dll 的共享库中.我想知道 crt0 是否还加载msvcrt.dll或是否有 msvcrt.lib 也会由编译器自动链接.

谢谢您,我的英语很抱歉:)

解决方案

安装环境时始终会加载运行时环境,例如msvcr80.dll(适用于Windows变体),无论它是什么,例如MSVCxx,带有MinGW的Code :: Blocks等.环境安装程序将包含标准C库(用于C环境)的.dlls放入您的系统目录中,并提供在构建过程中要链接到的所有必需的静态库以及标头文件.原型并定义使用该环境所必需的.您只需要设置路径(以查看.libs)并在源代码中#include正确的标题即可.

请注意,对于Linux之类的操作系统,运行时环境已内置在OS中,并且包括所有共享库(与.dll等同)静态库和.h(对于标准C).

关于msvcrt.dll的问题,请阅读上面的@Eric注释.微软当前的RTE使用msvcrnnn.dll形式的命名约定(例如msvcr80.dll,msvcr100.dll等,具体取决于寻址方式(32位或64位),操作系统版本等)

关于您的陈述:也由编译器自动链接.这完全取决于环境.如果您使用的是Microsoft的开发环境,则可以,它可能已经设置了默认值,以使您的链接即开即用.如果使用Microsoft库,但使用的是非Microsoft环境,则需要设置路径和其他环境变量,以获取.lib和.h位置.

(关于您的英语:这比我与之合作的大多数工程师所说的要好.)

I'm trying to figure out how are Standard C Functions like printf() loaded into memory on Windows environment. I know that crt0.obj prepares the stack, calls int main(int argc, char **argv) and then exits the process with the exit code that main returned.

I also heard that C standard functions are located in a shared library called msvcrt.dll. I'm wondering if crt0 also loads msvcrt.dll or there is a msvcrt.lib which is also linked automatically by the compiler.

Thank you and sorry for my English :)

解决方案

There will always be a run-time environment, such as msvcr80.dll (for Windows variants), loaded when you install your environment, what ever it is, i.e. MSVCxx, Code::Blocks with MinGW, etc. The environment installer places .dlls containing the standard C libraries (for C environments) into your system directory, and provides all necessary static libs to link to during your builds, and header files for prototypes and defines necessary to use that environment. You just need to set your path, (to see the.libs) and #include the right headers in your source code.

Note, for Operating systems such as Linux varieties the run-time environment is built into the OS, and incudes all shared libraries (synonymous with .dll) static libraries and .h for standard C.

Regarding your question on msvcrt.dll, read @Eric's comment above. Current RTEs from Microsoft use a nameing convention in the form msvcrnnn.dll (eg. msvcr80.dll, msvcr100.dll,... and so on depending on addressing (32 or 64 bit), OS version, etc.)

Regarding your statement: also linked automatically by the compiler. That is completely environment dependent. If you are using Microsoft's development environment, then yes, it is likely already set up with defaults to allow your linking to work right out of the box. If using Microsoft libraries, but from a non-Microsoft environment, paths and other environment variables need to be set in order to pick up the .lib and .h locations.

(Regarding your English: it is better than that spoken by most of the engineers I work with.)

这篇关于crt0是否加载msvcrt.dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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