简体   繁体   中英

Visual Studio Solution: static or shared projects?

When a whole project (solution) consists of multiple subprojects (.vcproj), what is a preferable way to tie them: as static libraries or as shared libraries?

Assuming that those subprojects are not used elsewhere, the shared libraries approach shouldn't decrease memory usage or load time.

Opinion: Static, in nearly all cases.

Building interfaces across dynamically loaded libraries is much harder in C++ on Windows. For example, unlike with Unix shared objects, you cannot have a standard singleton for all modules, because a DLL would have it's own set of static variables.

Object oriented interfaces are often hard to export from a DLL.

As for load time, issues like rebasing need to be adressed with shared libraries.

On the other hand, the libraries you do not share today might become shared in future. However, in most cases it is better to pay the price of duplication in RAM or disk image than the price of dependency on extra modules.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM