Reputation: 6532
I'm very new to C++ world, so please, sorry for such a dummy question. I googled a little, but wasn't able to find a proper answer.
My question is fairly simple - how should I use libraries in C++ world. For example in Java - there is maven
and gradle
for this task. In Python - I use pip
. In javascript npm
and bower
do all the stuff. In C# you use nuget
or just adding DLL lib to your project. But looks like in C++ things isn't such easy.
I found a tool, called conan
but amount of libraries they have is pretty small and does not include any what I'm looking for.
So, for example - I want to use nlp lib meta
but it seems like they don't provide any installer files. So I assume I need to get sources from Github. Should I compile them and then try to add the compiled files to my project or do I need to have a lib
folder in my project, and put meta's
sources in those folder and after operate with meta's
sources as they are in my project?
My question isn't about how to install specific meta
lib, but more from the source management point of view. If I use Visual Studio
on Windows
for example, but my colleague will be coding Clion
under Linux
. And I don't know the proper way of managing dependencies in C++ world.
Upvotes: 44
Views: 26157
Reputation: 315
I started new project... in cureent time it's just "source package manager" you can provide some source code on github and then it will be just copy to you project (based on cmake + auto generating cmake files)
So links here: https://github.com/wsjcpp/wsjcpp
Upvotes: 0
Reputation: 5389
I recommend vcpkg for cross platform development. It has a number of IDE integrations. GitHub project is here.
I do cross platform development using tools like CMake, Visual Studio, WSL. vcpkg was incredibly helpful.
Upvotes: 1
Reputation: 404
It appears to me that the Crascit/DownloadProject could be of help in your situation. It provides CMake
plugins for downloading projects from a git repository by specifying tags
, etc. Then you can use add_custom_target
to run commands you need to have the project built.
Upvotes: 2
Reputation: 18218
Cget will install any package that uses standard cmake, and works for linux and windows. It has shorten syntax for getting packages directly from github(such as cget install google/googletest
).
In addition, dependencies can be automatically downloaded as well by listing them in a requirements.txt
file.
There is also recipes for installing non-cmake packages and the repository here has over 300 libraries(and growing). So you can install curl with just cget install pfultz2/cget-recipes curl
.
Upvotes: 9
Reputation: 29017
C++ doesn't have anything like pip
or npm/bower
. I don't know if maven
or gradle
can be persuaded to handle C++ libraries.
In general, you are going to have to end up with
You get hold of the library files, either by building them on your machine (typical for open source projects, and projects aimed at Linux platforms), or by downloading the pre-compiled binaries (typical for Windows libraries, particularly paid-for).
Hopefully, the instructions for building the library will be included on the library website. As noted in the comments, 'meta' seems to be quite good at that.
When you try to compile with the library, you may need a command line option (eg -I
) to specify the directory containing the header files, and you may need a linker option (eg -l
) to tell the linker to link against your library.
Upvotes: 13
Reputation: 3741
There are a number of popular C++ released via nuget packages.
You can search on the gallery for them, usually using the native
or c++
tags. Obviously you need a nuget manager for your OS, and I'm pretty sure that the C++ nuget packages rely on MSBuild for a lot of the grunt work, so you may have trouble getting a non-Visual Studio oriented setup to work nicely.
Also Gradle actually does have some support for native dependencies as well. I had a look at little while ago but the work on it was curtailed because the support for VS 2015 was lacking.
Upvotes: 0
Reputation: 5370
C++ sadly has no package manager for libraries. Some are out there and try to be one which are still small and scattered though (like conan).
In linux you have some "-dev" packages you can install but they are also not "all".
You most likely end up downloading them yourself. Next though is you have the problem of integrating those libraries. You have different build systems per operating system so you have to see how you build c++ files.
Like in windows with Visual studio you have to get a visual studio project or a nmake compatible makefile to build the libraries and then add them to your project. Same with linux makefiles.
There are several build frameworks who are higher level like cmake
. The example you have in your post also works with CMake. So integrating that one into a cmake build environment would be easier but this only applies for other libraries also trying to use/integrate cmake build environments to it (e.g. boost / qt is doing this).
Yeah these are some thoughts to this. Sadly there won't be an easy/definitive answer to this because there is no real central c++ packet repository which is also integrated into a build system.
Upvotes: 7