编译语言基础知识 [英] Compiled languages basics

查看:180
本文介绍了编译语言基础知识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请,可能有人向我解释有关与类似C语言的工作的一些基本的东西呢?特别是在Windows?


  1. 如果我想使用一些其他图书馆,有什么事我从图书馆需要什么?头文件h和..?


  2. 什么是.dll和.dll.a之间的区别? .dll和.LIB? .dll和.EXE?什么是的.def?


  3. 不要紧,怎么着图书馆编译的?我的意思是,它可以使用,在Windows上,++库由VC从MinGW的编译我的C code编译内一个C?


  4. 要使用另一个库,什么是preferred方式?调用LoadLibrary()或#包括LT&;?>


  5. 有一些库只提供源$ C ​​$ C或.dll - 如何使用这些库?难道我每次都重新编译他们,我重建我的项目?


  6. 如何创建一个大的.exe文件?这是所谓的静态链接?


  7. 如何包括一些随机文件到的.exe?说一个程序图标或启动的歌吗?


  8. 如何分割我的巨大的.c成小的?我是否需要创建每一个部分的头文件,然后我包括与的WinMain()或main()的?

  9. 部分
  10. 如果有,需要另一个库,是有可能这两个成一个文件合并在一起库?比方说,python26.dll需要MSVCR90.DLL和Microsoft.VC90.CRT.manifest


  11. 如果我没有免费的previously分配的内存会发生什么?这是将要清理如果程序(进程)死?


那么,这么多的问题...感谢每一个信息!


解决方案

  

1:如果我想使用一些其他图书馆,有什么事我从图书馆需要什么?头文件h和..?


...而且,通常是你作为参数传递到你的链接 *。LIB 文件。


  

2:是什么.dll和.dll.a之间的差异。? .dll和.LIB? .dll和.EXE?什么是的.def?


这可能是有用的:静态库,动态库文件,DLL入口点,报头......如何摆脱这种活着的


  

3:它不管怎么着图书馆编译的?我的意思是,它可以使用,在Windows上,++库由VC从MinGW的编译我的C code编译内一个C?


是的,这很重要。对于编译器之间的互操作,以正常的方式是使用C风格的(不是C ++ - 风格)API,具有良好定义的参数传递约定(如 __ STDCALL ),或使用COM接口。


  

4:使用其他库,什么是preferred方式?调用LoadLibrary()或#包括LT&;?>


的#include 为编译器(例如,以便它可以编译成库调用);和调用LoadLibrary (或者使用 *。LIB 文件)是运行时链接器/加载(使它可以替代这些库方法的实际地址到你的code):也就是你既需要


  

5:有一些图书馆只提供源$ C ​​$ C或.dll - 如何使用这些库?难道我每次都重新编译他们,我重建我的项目?


如果这是唯一的来源,那么你可以编译源(一次)到库中,然后(当你建立你的项目)链接到库(无需重新编译库)。


  

6:如何创建一个大的.exe文件?这是所谓的静态链接?


是的,编译所有这一切传递给链接器。


  

7:如何加入一些随机文件到的.exe?说一个程序图标或启动的歌吗?


定义,在一个特定的Windows的资源文件,这是由资源编译器的编译。


  

8:我如何拆分我巨大的.c成小的?我是否需要创建每一个部分的头文件,然后我包括与的WinMain()或main()的?

部分


  

9:如果是需要另一个库出库,是否有可能将这两个合并成一个文件?比方说,python26.dll需求MSVCR90.DLL和Microsoft.VC90.CRT.manifest


我不明白你的问题/例子。


  

10:如果我不免费previously分配的内存会发生什么?这是将要清理如果程序(进程)死了?


please, could someone explain to me a few basic things about working with languages like C? Especially on Windows?

  1. If I want to use some other library, what do I need from the library? Header files .h and ..?

  2. What is the difference between .dll and .dll.a.? .dll and .lib? .dll and .exe? What is .def?

  3. Does it matter how was the library compiled? I mean, is it possible to use, on Windows, a C++ library compiled by VC from within my C code compiled by MinGW?

  4. To use another library, what is preferred way? LoadLibrary() or #include <>?

  5. There are some libraries which only provide the source code or .dll - how to use such libraries? Do I have to recompile them every time I rebuild my project?

  6. How do I create one big .exe? Is this called "static linking"?

  7. How to include some random file into .exe? Say a program icon or start-up song?

  8. How do I split my huge .c into smaller ones? Do I need to create for every part a header file which then I include in the part with WinMain() or main()?

  9. If there is a library which needs another library, is it possible to combine these two into one file? Say, python26.dll needs msvcr90.dll and Microsoft.VC90.CRT.manifest

  10. What happens if I don't free previously allocated memory? Is this going to be cleaned up if the program (process) dies?

Well, so many question... Thanks for every info!

解决方案

1: If I want to use some other library, what do I need from the library? Header files .h and ..?

... and, usually a *.lib file which you pass as an argument to your linker.

2: What is the difference between .dll and .dll.a.? .dll and .lib? .dll and .exe? What is .def?

This might be useful: Static libraries, dynamic libraries, DLLs, entry points, headers … how to get out of this alive?

3: Does it matter how was the library compiled? I mean, is it possible to use, on Windows, a C++ library compiled by VC from within my C code compiled by MinGW?

Yes, it matters. For interop between compilers, the normal way is to use a C-style (not C++-style) API, with well-defined parameter-passing conventions (e.g. __stdcall), or to use 'COM' interfaces.

4: To use another library, what is preferred way? LoadLibrary() or #include <>?

#include is for the compiler (e.g. so that it can compile calls to the library); and LoadLibrary (or, using a *.lib file) is for the run-time linker/loader (so that it can substitute the actual address of those library methods into your code): i.e. you need both.

5: There are some libraries which only provide the source code or .dll - how to use such libraries? Do I have to recompile them every time I rebuild my project?

If it's only source then you can compile that source (once) into a library, and then (when you build your project) link to that library (without recompiling the library).

6: How do I create one big .exe? Is this called "static linking"?

Yes, compile everything and pass it all to the linker.

7: How to include some random file into .exe? Say a program icon or start-up song?

Define that in a Windows-specific 'resource file', which is compiled by the 'resource compiler'.

8: How do I split my huge .c into smaller ones? Do I need to create for every part a header file which then I include in the part with WinMain() or main()?

Yes.

9: If there is a library which needs another library, is it possible to combine these two into one file? Say, python26.dll needs msvcr90.dll and Microsoft.VC90.CRT.manifest

I don't understand your question/example.

10: What happens if I don't free previously allocated memory? Is this going to be cleaned up if the program (process) dies?

Yes.

这篇关于编译语言基础知识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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