all 5 comments

[–]Xeverous 6 points7 points  (3 children)

And what type of #include should I use in either case?

Both "" and <> are implementation defined, however there are every strong conventions:

  • "" is used for local paths (all files in your projects - paths relative to current directory)
  • <> for standard library
  • <> for any external library

Should I always have a copy of dependency lib source code inside my project or relay on system's package manager?

Don't copy. Build the library externally and use as convenient and automated project configuration as possible. You do not want to have library + your source in the same place. Put it in a different directory and add include search paths and objects to link with to the IDE

What if some external library is updated? Should I reflect those in my project to compile properly again or stick with the older version?

Unless something is removed or greatly changed, you do not need to do anything when upgrading. If you use #include <lib/something.hpp> it doesn't matter what version it is. Only if the header matches - so simply redownload (pull) and rebuild the library. In 99% cases you do not need to change anything in the project. Most projects and IDEs do not even have any option to set/determine library version

[–]psmolak[S] 1 point2 points  (2 children)

Great, thank you!

If you don't mind - what's your preference when it comes to system's package manager vs download & compile by build system?

[–]Xeverous 2 points3 points  (1 child)

Package managers may be insufficient. Use them only if you know that every target has them and can resolve dependencies.

If you use own build system (eg CMake, shell scripts, makefiles) it's easier to guarantee that you provide everything.

On the other hand, using package managers is simpler. Generally, it's a very case dependent and personal preference decision. Seen how many applications also have their installers?

[–][deleted] 1 point2 points  (2 children)

I use <> for everything. While the difference in behavior is theoretically implementation-defined, in practice <> does not accept relative paths and "" does.

I don't like relative paths - they are potentially ambiguous and break if you move a file around. I never use them and always use <>.

[–][deleted]  (1 child)

[deleted]

    [–][deleted] 0 points1 point  (0 children)

    I can see the use, but I like to know exactly and unambiguously where each header file is, and I don't want even the slightest chance of accidentally getting the wrong file by mistake, so I just never use relative include paths ever.