• Advertisement
Sign in to follow this  

Standard library directories on Windows?

This topic is 1468 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is more or less a rant, (and somewhat of an inquiry).

 

Linux and Mac users: We all have standard locations where shared and static libraries can be found and linked against. /usr/lib, or /usr/local/lib. We also all have standard locations where header files can be found: /usr/include, or /usr/local/include. We also have a standard about naming conventions for libraries, e.g. every dynamic or static library must begin with "lib" followed by your library name in order to avoid name clashes, because they're all dumped into the same directory, and there's a standard about placing header files in a sub-directory in the respective system "include" directory named after your library name (although not everyone abides to this either for some reason).

 

Now I ask you, what on earth is Windows doing? Is there even a standard? Because it doesn't seem so.

 

Everyone is creating custom environment variables such as "SFML_HOME" or "BOOST_ROOT" or "GMOCK_PATH". Do you even know how cumbersome this makes it to write cross platform build systems?

 

The more libraries you add, the larger your PATH environment variable gets (because it has to point to all kinds of command line tools because Windows doesn't have a "bin" directory), and the more you have to account for in build scripts.

 

Then you have those people (such as myself) who come from a *NIX OS and don't know any better than to create a folder on C:\ called "dev" under which the common directories "include", "lib", "bin", and "share" can be found.

 

What is the standard way of doing this on Windows? I've collaborated with a few Windows developers and they all seem to do something entirely different than the last.

 

 

Share this post


Link to post
Share on other sites
Advertisement
There is no standard way. Everyone has to find a solution that works for them.

What works will also depend on the kind and number of projects you are working on and how many different build settings you need to support. Edited by BitMaster

Share this post


Link to post
Share on other sites

there's a standard about placing header files in a sub-directory in the respective system "include" directory named after your library name (although not everyone abides to this either for some reason)

That's because it's really more of a recent convention that a standard. We certainly never did that on Unix in the 1980s and 1990s.

That said, most GNU/Linux distros and the BSDs bundle projects that tend to follow the FHS ("file heirarchy standard"), a published convention put together by some interested parties and adopted as a de facto standard. Despite the name and widespread use, it's not a de jure standard and if you do a lot of development, you'll find a lot of software does not follow it, and certainly Macintosh and Android/Linux software does not follow it to any great extent, preferring the Windows-style project-specific bundling.

Share this post


Link to post
Share on other sites

If this is for maintaining a build solution cross platform, have you looked into using CMake?

While this may not answer your question about where's standard, but I thought your comment about there not being a good cross platform build solution warranted a comment.

 

You can write some cmake modules for Finding specific packages, some packages even include their own CMake Find modules.

Share this post


Link to post
Share on other sites

The problem on Windows would be incompatible files depending on which compiler and even compiler-version is in use, so the pseudo-standard way would be to put includes, libs and dlls in a subdirectory of the compiler. Then some dll files used to be put in windows/system32 by some people, although thats discouraged especially for anything not globally compatible.

Personally I add whats needed for developing a program to the path, and include+lib directories indirectly through whatever build system used to the compiler+linker command line. Other people copy the dll files near the exe always, and that would be needed for delivering files to other people also.

 

On Unix people may get the opposite problem when they want to use some other library version or replacement library or compiler, as the standard-directories are hardcoded in the buildsystem or even compiler.

Share this post


Link to post
Share on other sites

Personally, i just put all my library files in a custom directory inside my main programming folder somewhere, then i add it to the "additionnal include path" and "additionnal library parth" inside visual studio, that way, there's no conflict whatsoever.

Share this post


Link to post
Share on other sites

^^^ What he said.

 

zlet.png

Problem solved. (And yes, both Boost and SFML are in there)

 

Besides, you'll need different versions of libraries if they were compiled with different compilers, so it makes sense to keep libraries contained under separate folders depending on the compiler, compiler settings, and compiler version that you built them under.

Share this post


Link to post
Share on other sites
Agreed with Hodgman.

Never use environment variables if you can avoid it. Even worse than using global variables in a program. The only one you should ever think about modifying is the PATH variable, and only if you're a command line tool that needs to be run manually by users.


If you're organizing your project, add all dependent libs relative to your root project folder and check the entire damn thing in to source control. If your libraries are compiler-dependent, you're already doing it completely wrong.

If you're distributing an application, your DLLs go in the same folder as your EXE. The only time it's acceptable to install something to a system path is if you're Microsoft (.Net, DirectX). Edited by Nypyren

Share this post


Link to post
Share on other sites

Everyone knows that global variables are bad, and PATH is a system-wide global variable, so building a system that relies on changing PATH in a specific way is not just bad, it's evil.

Agreed.

Having a global environment for common libs and includes is quite nice for small "try out" projects. But every larger project I worked on during my career has a build environment that is as self-contained as possible.

Funny detail:

Last year my children and I played "ace of spades" a lot. But originally it did not run on my machine (needless to say that the support was completely useless). Finally I found that I had a newer Python version installed, and some environment variable that pointed to that installation. This broke some internal component of the game.

Edited by cdoubleplusgood

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement