简体   繁体   English

Windows C ++ Eclipse MinGW链接动态库和静态库

[英]Windows C++ Eclipse MinGW link both dynamic and static library

I am new to C++ programming. 我是C ++编程的新手。 There are 2 libraries in my program, one needs to be linked dynamically, and the other needs to be linked statically, how can I set this up in Eclipse? 我的程序中有2个库,一个需要动态链接,而另一个则需要静态链接,如何在Eclipse中进行设置? I am using Eclipse CDT + MinGW + Windows 7. 我正在使用Eclipse CDT + MinGW + Windows 7。

Thanks. 谢谢。

It's not entirely clear what you're after here. 目前尚不清楚您在这里追求什么。

Most of static vs. dynamic is in the library itself, not how you link to it. 静态与动态的大部分都在库本身中,而不是您如何链接到它。 You can have a static library, which is basically just a collection of object files, stuffed together into a single file, with a directory to tell what parts were originally which files. 您可以拥有一个静态库,该库基本上只是对象文件的集合,并塞入一个文件中,并带有一个目录,以告知最初哪些部分是哪些文件。

You can also have a DLL. 您也可以有一个DLL。 When you create a DLL, the linker will normally also create a link library for that DLL. 当您创建DLL时,链接程序通常还会为该DLL创建一个链接库。 This library basically just contains stubs -- enough information so the linker can insert a link to the DLL into another DLL or executable. 该库基本上只包含存根-足够的信息,因此链接程序可以将DLL的链接插入另一个DLL或可执行文件。

When you use a DLL, you basically have three options for how to use it: 使用DLL时,基本上有三种使用方式的选择:

  1. The most common case: the DLL will be loaded as the parent executable is loaded. 最常见的情况:DLL将在加载父可执行文件时加载。
  2. delayload: doesn't load that DLL until/unless you actually use a function from it (handy if you have, for example, a special DLL that's only used under, say, Windows Vista or newer). delayload:直到/除非您实际使用了它的功能,才加载该DLL(例如,如果您有仅在Windows Vista或更高版本下使用的特殊DLL,则非常方便)。
  3. Explicit dynamic linking. 显式动态链接。 Here, you don't tell the linker about the DLL or an associated library at all. 在这里,您根本不会告诉链接器有关DLL或相关库的信息。 You call LoadLibrary and GetProcAddress to load the library, and get a callable function address. 您调用LoadLibraryGetProcAddress加载库,并获取可调用的函数地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C ++ Windows,使用mingw编译为静态库,并包含在Visual Studio C ++项目中 - c++ windows, compile with mingw as static library and include in visual studio c++ project 动态链接库C ++ - dynamic link library c++ 如何在Eclipse中运行用MinGW编译的C ++程序? 如何“链接(?)”? - How to run a C++ program compiled with MinGW in Eclipse? How to “link(?)”? 无法在 MinGW/CLion (c++) 中将 curl 和 libgcc 编译为静态库 - Cannot compile curl and libgcc as a static library in MinGW/CLion (c++) 如何在Eclipse中将C项目与C ++静态库(使用opencv)链接 - How to link a C project with a C++ static library(using opencv) in eclipse 当我链接它们时,我可以在 C++ 的两个静态库中有两个 main 函数吗? - I can have two main function in two static library of C++ when I link both of them? 在C ++中嵌入python代码(Windows + minGW + Python 2.7.2 + Eclipse) - Embed python code in C++ (Windows + minGW + Python 2.7.2 + Eclipse) 在Eclipse for Java中使用静态C ++库 - Use static C++ library in Eclipse for Java C++ mingw32-make undefined reference to library (Windows) - C++ mingw32-make undefined references to library (Windows) 分发Windows C ++库:如何决定创建静态库还是动态库? - Distributing Windows C++ library: how to decide whether to create static or dynamic library?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM