Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

66%
+2 −0
Q&A Managing a dependency for a C application

It depends on what you are distributing. There are two types of distributions: Binary (application is already compiled) Source (users download raw source code and compile themselves) Becaus...

posted 4mo ago by zmzaps‭  ·  edited 4mo ago by zmzaps‭

Answer
#2: Post edited by user avatar zmzaps‭ · 2024-07-06T20:45:42Z (4 months ago)
fix grammar and clarify
  • It depends on _what_ you are distributing.
  • There are two types of distributions:
  • - Binary (application is already compiled)
  • - Source (users download raw source code and compile themselves)
  • Because you are using a header only library, anyone downloading a __binary distribution__ does not need to download the header file(s) because the code they contain is statically compile into your executable! If you did not using a header-only library and instead linked against a shared library, then your problem would be more complex...
  • As for the __source distribution__, yes, you will need to provide a method for developers to install the header file. Some languages (such as Go, Rust, Python, etc.) have package managers built into the core language utilies. Sadly, C/C++ does not. Instead, you must rely upon a smattering of unofficial C/C++ package management tools that the C/C++ community has widely adopted.
  • Popular solutions to managing C/C++ dependencies:
  • 1. [Conan](https://docs.conan.io/2/)
  • 2. [vcpkg](https://github.com/microsoft/vcpkg)
  • 3. [CMake's FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) module
  • 4. [pkg-config](https://en.wikipedia.org/wiki/Pkg-config)
  • 5. Git Submodules; I personally recommend you avoid them.
  • 6. Vendor your dependency (ie. copy + paste it into your app's repo)
  • This is by no means an exhaustive list, however this [blog post](https://moderncppdevops.com/pkg-mngr-roundup/) seems to have some good information too.
  • If you already have a build system, such as CMake, Meson, Spack, etc., then I suggest that you go with whatever is conventional for that build system. If you don't have a build system, then I recommend you use one! I personally use CMake.
  • In the end, I think option #6 is the best option. The [stb-libraries are MIT licensed](https://github.com/nothings/stb/blob/49cbedfab6623f38a8fa65b32d10ab4b2fefd872/LICENSE), so as long as you abide by the terms of the license, you can redistribute the header files in your own source code. By including the header file in your app's repo, you avoid all the extra work of setting up a dependency management solution.
  • It depends on _what_ you are distributing.
  • There are two types of distributions:
  • - Binary (application is already compiled)
  • - Source (users download raw source code and compile themselves)
  • Because you are using a header only library, anyone downloading a __binary distribution__ does not need to download the header file(s) because the code they contain is statically compiled into your executable! If you did not using a header-only library and instead linked against a shared library, then your problem would be more complex...
  • As for the __source distribution__, yes, you will need to provide a method for developers to install the header file. Some languages (such as Go, Rust, Python, etc.) have package managers built into the core language utilities. Sadly, C/C++ does not. Instead, you must rely upon a smattering of unofficial C/C++ package management tools that the C/C++ community has widely adopted.
  • Popular solutions to managing C/C++ dependencies:
  • 1. [Conan](https://docs.conan.io/2/)
  • 2. [vcpkg](https://github.com/microsoft/vcpkg)
  • 3. [CMake's FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) module
  • 4. [pkg-config](https://en.wikipedia.org/wiki/Pkg-config)
  • 5. Git Submodules; I personally recommend you avoid them.
  • 6. Vendor your dependency (ie. copy + paste it into your app's repo)
  • This is by no means an exhaustive list, however this [blog post](https://moderncppdevops.com/pkg-mngr-roundup/) seems to have some good information too.
  • If you already have a build system, such as CMake, Meson, Spack, etc., then I suggest that you go with whatever is conventional for that build system. If you don't have a build system, then I recommend you use one! I personally use CMake.
  • In the end, I think option #6 (vendoring the header file) is the best option. The [stb-libraries are MIT licensed](https://github.com/nothings/stb/blob/49cbedfab6623f38a8fa65b32d10ab4b2fefd872/LICENSE), so as long as you abide by the terms of the license, you can redistribute the header files in your own source code. By including the header file in your app's repo, you avoid all the extra work of setting up a dependency management solution.
#1: Initial revision by user avatar zmzaps‭ · 2024-07-06T20:44:12Z (4 months ago)
It depends on _what_ you are distributing.

There are two types of distributions:
- Binary (application is already compiled)
- Source (users download raw source code and compile themselves)

Because you are using a header only library, anyone downloading a __binary distribution__ does not need to download the header file(s) because the code they contain is statically compile into your executable! If you did not using a header-only library and instead linked against a shared library, then your problem would be more complex...

As for the __source distribution__, yes, you will need to provide a method for developers to install the header file. Some languages (such as Go, Rust, Python, etc.) have package managers built into the core language utilies. Sadly, C/C++ does not. Instead, you must rely upon a smattering of unofficial C/C++ package management tools that the C/C++ community has widely adopted.

Popular solutions to managing C/C++ dependencies:
1. [Conan](https://docs.conan.io/2/)
2. [vcpkg](https://github.com/microsoft/vcpkg)
3. [CMake's FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) module
4. [pkg-config](https://en.wikipedia.org/wiki/Pkg-config)
5. Git Submodules; I personally recommend you avoid them.
6. Vendor your dependency (ie. copy + paste it into your app's repo)

This is by no means an exhaustive list, however this [blog post](https://moderncppdevops.com/pkg-mngr-roundup/) seems to have some good information too.

If you already have a build system, such as CMake, Meson, Spack, etc., then I suggest that you go with whatever is conventional for that build system. If you don't have a build system, then I recommend you use one! I personally use CMake.

In the end, I think option #6 is the best option. The [stb-libraries are MIT licensed](https://github.com/nothings/stb/blob/49cbedfab6623f38a8fa65b32d10ab4b2fefd872/LICENSE), so as long as you abide by the terms of the license, you can redistribute the header files in your own source code. By including the header file in your app's repo, you avoid all the extra work of setting up a dependency management solution.