I'm a beginner to C++, and I was recently figuring out the process of downloading an external library and linking it to a project I'm working on. Coming from languages where adding new dependencies and installing necessary ones are a command away, it seems that there are several ways to download and link a library in C++, and so I'm struggling to imagine how experienced developers with large scale projects are able to make their scripts and libraries portable and straightforward to setup.
To give an example, what I ended up doing in my project was using a CMakeLists.txt
file with a hardcoded path to a library I'm using, libxml2, something like this:
include_directories(/opt/homebrew/Cellar/libxml2/2.10.3_1/include);
link_directories(/opt/homebrew/Cellar/libxml2/2.10.3_1/lib);
But this would require libxml2 to be separately downloaded onto every machine this project is cloned on, and the path would change too depending on the version and environment. So my specific question is, what is considered best practice to package C++ projects with external dependencies?
For example, node.js has a package.json
and npm install
, python has a requirement.txt
and pip install -r requirements.txt
. Is there a C++ equivalent?
I'm sorry if this is a silly question, but I'm really struggling finding the right search terms to find a proper answer. Thank you in advance!