Jump to content

  • Log In with Google      Sign In   
  • Create Account

Standard library directories on Windows?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 TheComet   Crossbones+   -  Reputation: 1642

Like
0Likes
Like

Posted 14 January 2014 - 04:18 AM

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.

 

 


YOUR_OPINION >/dev/null

Sponsor:

#2 BitMaster   Crossbones+   -  Reputation: 4431

Like
1Likes
Like

Posted 14 January 2014 - 04:20 AM

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, 14 January 2014 - 04:21 AM.


#3 Bregma   Crossbones+   -  Reputation: 5435

Like
3Likes
Like

Posted 14 January 2014 - 06:24 AM

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.
Stephen M. Webb
Professional Free Software Developer

#4 morbik   Members   -  Reputation: 363

Like
0Likes
Like

Posted 14 January 2014 - 01:53 PM

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.



#5 wintertime   Members   -  Reputation: 1876

Like
0Likes
Like

Posted 14 January 2014 - 05:02 PM

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.



#6 Vortez   Crossbones+   -  Reputation: 2704

Like
1Likes
Like

Posted 14 January 2014 - 10:07 PM

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.



#7 Servant of the Lord   Crossbones+   -  Reputation: 20998

Like
0Likes
Like

Posted 14 January 2014 - 11:34 PM

^^^ 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.


It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#8 Hodgman   Moderators   -  Reputation: 31800

Like
8Likes
Like

Posted 15 January 2014 - 12:00 AM

As a counter view-point of someone who's worked in corporate software dev, written using the same level of ignorant outrage* biggrin.png --

The Linux convention that you're trying to implement on Windows is bad. 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. It's the enemy of professional software development and decades of science and engineering knowledge. It shouldn't just not be emulated on Windows, it should also be abandoned on Linux. Oh wait, you can't, because sticking to GPL ideology is more important than good engineering practices...

 

If I get a bug report from a user, claiming there's a crash in the PNG loader, how the hell am I meant to replay the crash using their memory dump? Do they send me their whole system? Their stack trace doesn't line up with my system's libpng.a, just producing garbage results in the stack viewer! In fact, if I follow their reproduction steps, the application doesn't even crash at all! Their version of the application is obviously different to mine, because they've assembled the whole using different parts than I did...

 

On Windows, every engineer worth hiring knows that you never install files into C:\Windows\System, because unregulated unilateral developer decisions on shared dependencies cannot be relied upon when trying to create quality software products. If someone tells you "oh, just put this file into C:\Windows and it will fix my software" then the correct response is to immediately stop using that person's software because they're an idiot. Yet on Linux this seat of your pants culture is accepted and normalized.

 

If you're selling a car with certain performance and safety guarantees, then you test the car as a whole before letting any customers have one.

You do not just go ahead with selling the car without wheels, instructing the user to supply their own, and then gladly accepting the customer's complaints about crashes when they used different wheels than you did during your testing.

 

That is to say, if you're serious about making solid products, you need to internalize all of your 'external dependencies'. Leaving them as being the users' responsibility is for DIY kits only.

 

*[n.b. I'm not really this outraged by the subject and mean no offense with this forced-rant-style reply laugh.png this is meant to demonstrate and explain the clash of cultures]


Edited by Hodgman, 15 January 2014 - 12:14 AM.


#9 Nypyren   Crossbones+   -  Reputation: 4796

Like
1Likes
Like

Posted 15 January 2014 - 12:26 AM

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, 15 January 2014 - 12:33 AM.


#10 cdoubleplusgood   Members   -  Reputation: 848

Like
0Likes
Like

Posted 15 January 2014 - 07:36 AM


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, 15 January 2014 - 07:38 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS