Feeds

Build and manage large-scale C++ on Windows

DLLs versus shared objects

Intelligent flash storage arrays

This becomes a real disadvantage when there are many DLLs in a large project in a configuration used for ongoing and active development. A non-optimized build system may initiate a large-scale relink of dependencies and transitive dependencies at the update of a single import library. Time spent compiling and linking is time lost cumulatively across all developers in code, build, test cycles and an improvement in link time is multiplied by the number of developers and by the number of compile and links performed. It's possible that a static library build configuration could result in significant development time savings in development.

DLLs and duplicate symbols

Another big difference is how a DLL is loaded into the address space versus a shared object. As we said before a shared object contains all of its symbols and all of the code associated with these symbols. When the dynamic loader kicks in, it loads all needed libraries into memory and if there are several containing the same symbol then all are merged into a single symbol and all references are updated to refer to merged address in memory.

This means that even if a shared object contains a reference to a symbol defined internally and this symbol is later merged out then everything will still be OK because the dynamic loader has enough information to resolve everything. In the Windows model, when several DLLs contain the same symbol then they are never resolved. The DLL called depends very much on the location of the code doing the calling.

Of course this isn't a problem if the symbol represents a re-entrant function, but what if the symbol represents a function containing static data? This static data could have several values depending on which instance is called, and any assumptions regarding value transitions between function calls are broken. Even worse, when the imported symbol is itself data then all bets are really off.

There isn't an easy way to work around this because in Windows code inside the DLL will always access internal symbols with base address offset addressing as opposed to relocations. So if we need to use libraries containing static data, which are eventually linked into more than one DLL, then the best approach may be to move all such data out of static libraries and create a DLL containing functions that are engineered specifically to have a single definition in a single DLL just to manage such data.

So, next time think carefully before switching on the /FORCE option in that linker as it could be opening a can of worms.

DLLs and static libraries

What about mixing DLLs and static libraries? In a big project there will be code that makes sense to be packaged in a static library and other code that makes more sense as a DLL.

The choice could be driven by build times or facility to test - as long as data of static duration is both minimized and carefully managed there isn't really any reason to say a project should be all static library only or all DLL. An alternative is to have a levelized system as espoused by our friend and hero Lakos. In levelized systems, dependencies are more predictable because of the hierarchical organization.

Providing a secure and efficient Helpdesk

More from The Register

next story
UNIX greybeards threaten Debian fork over systemd plan
'Veteran Unix Admins' fear desktop emphasis is betraying open source
Netscape Navigator - the browser that started it all - turns 20
It was 20 years ago today, Marc Andreeesen taught the band to play
Redmond top man Satya Nadella: 'Microsoft LOVES Linux'
Open-source 'love' fairly runneth over at cloud event
Google+ goes TITSUP. But WHO knew? How long? Anyone ... Hello ...
Wobbly Gmail, Contacts, Calendar on the other hand ...
Chrome 38's new HTML tag support makes fatties FIT and SKINNIER
First browser to protect networks' bandwith using official spec
Admins! Never mind POODLE, there're NEW OpenSSL bugs to splat
Four new patches for open-source crypto libraries
Torvalds CONFESSES: 'I'm pretty good at alienating devs'
Admits to 'a metric ****load' of mistakes during work with Linux collaborators
prev story

Whitepapers

Forging a new future with identity relationship management
Learn about ForgeRock's next generation IRM platform and how it is designed to empower CEOS's and enterprises to engage with consumers.
Why and how to choose the right cloud vendor
The benefits of cloud-based storage in your processes. Eliminate onsite, disk-based backup and archiving in favor of cloud-based data protection.
Three 1TB solid state scorchers up for grabs
Big SSDs can be expensive but think big and think free because you could be the lucky winner of one of three 1TB Samsung SSD 840 EVO drives that we’re giving away worth over £300 apiece.
Reg Reader Research: SaaS based Email and Office Productivity Tools
Read this Reg reader report which provides advice and guidance for SMBs towards the use of SaaS based email and Office productivity tools.
Security for virtualized datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.