Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to mix static, multi-threaded, DLL libraries in one project?

Is it possible to use distinct libraries A, B, C in the same project in Visual Studio, where A is a static library, B is multi-threaded and C is a multi-threaded DLL? Or do they all have to be the same type for a single .exe output?

Edit: Sorry, A is a single-threaded static library. B is a multi-threaded static library, C is a multi-threaded DLL. (I guess A and B are the same from the linker's point of view?)

like image 498
jamesj629 Avatar asked Feb 18 '10 00:02

jamesj629


People also ask

Can a exe link to DLL and static library at the same time?

Yes, the Core and Utils code will be duplicated.

Can you link a static library to a dynamic library?

When you want to “link a static library with dynamic library”, you really want to include the symbols defined in the static library as a part of the dynamic library, so that the run-time linker gets the symbols when it is loading the dynamic library.

Can a DLL link to static library?

It is also necessary to link to the static library (defined previously in this topic) or to the import libraries for the PLUS DLL Interface. An import library tells your EXE how to connect to the PLUS DLL during runtime. Import libraries for Microsoft Visual C++ 6.0 SP6 or later compilers are provided.

Are static libraries linked?

In computer science, a static library or statically-linked library is a set of routines, external functions and variables which are resolved in a caller at compile-time and copied into a target application by a compiler, linker, or binder, producing an object file and a stand-alone executable.


3 Answers

You can freely mix static and dynamic libraries, so long as they all use the same run-time libs.

In Properties -> General -> Configuration Type -> set this to Static Library or Dynamic Library for the libraries A and B you want to static or dynamic.

In Properties -> C/C++ -> Code Generation -> Runtime Library -> Every library which will be linked together must use the same run-time library, for example Multi-Threaded Debug DLL.

Thus you could do:
A - Config Type: Static Library. Runtime Lib: Multi-threaded Debug DLL. (yes this is ok)
B - Config Type: Dynamic Library. Runtime Lib: Multi-threaded Debug DLL

These two libs could be linked into the same exe.

like image 162
rcz Avatar answered Oct 23 '22 06:10

rcz


Not sure what B is but the general idea is yes.

A will get compiled directly into the exe B Not sure about what this one is C Yes, functions within this library will be linked at runtime.

like image 22
Suroot Avatar answered Oct 23 '22 06:10

Suroot


Are you talking about libraries compiler with different CRT linking type(static, dll)? If yes, then it's impossible.

like image 22
BarsMonster Avatar answered Oct 23 '22 05:10

BarsMonster