5

I've just finished my studies in Computer Science and now I'm working. The problem is I'm the only computer scientist in my company and I'm probably taking a lot of bad habits. I would like to correct it if one day I have to work in a team.

I hope this question belongs in this community: In a C++ Git project, where do I put dependencies?

How can I be sure that everyone will have the same versions of dependencies without uploading everything on GitHub for example? Do I have to give the dependencies I downloaded and used to everyone, or do I just have to let people know which I used and let them install how they want?

To give an example, I have a Visual Studio project, in which I added a lot of dependencies, but they are on a personal repository. So I configured VS with them. When I put them on Git, configuration will be saved, but it will be my own configuration. How can one use this project?

  • 1
    This sounds like the problem that NuGet is intended to solve. – Robin Bennett Jan 27 at 10:55
  • 1
    Which programming language? Different languages have their own tools, standards and conventions for dependency management. – Jesper Jan 27 at 11:45
  • This is for c++ projects actually. So I have to look for program or extension similar to NuGet! It gives me a lead! Thanks a lot! – Raph Schim Jan 27 at 12:12
  • 1
    Why do you need something similar to NuGet? If you're using Visual Studio then why not just use NuGet with your C++ dependencies? – Ben Cottrell Jan 27 at 12:57
  • Yes! For Visual Studio! :) this sentence was if I have to use something else one day! Thanks! – Raph Schim Jan 27 at 13:08
1

As per the comments on the question, NuGet would be a solution for you... if only you could use it without Visual Studio... Well, you can!

More precisely, you can use Nuget.exe from command line. No Visual Studio required. You can download Nuget.exe from nuget.org (download link).

Note: Nuget.exe will work on Linux and macOS by using Mono.

If you are not using Visual Studio and want to use NuGet, I suggest a build shell script (or the file format for whatever build automation tool you are using) that calls Nuget.exe to get the dependencies. That leaves the problem of whatever or not Nuget.exe is in path... well, you can also download it from the script.

See NuGet CLI reference and Manage packages using the nuget.exe CLI.

| improve this answer | |
1

The decision of where to put dependencies, well, depends. Even if you were writing this in c# and had the assembly loading power of the Common Language Runtime at your disposal using NuGet is not a forgone conclusion.

With a c# project, I'm in the process of copying code from some NuGet packages directly into my solution simply because this code isn't used anywhere else. It is just too much of a pain to change one line of code and spend 5 minutes packaging, pushing and upgrading a NuGet package, only to find out I have another one line code change to make.

If the code is only going to be used in one project, keep the source in the same solution, regardless of whether or not you are writing c#, c or c++ — even if it is extremely generic and reusable. With the second solution that needs it, I would say copy and paste. Only after you encounter a third solution that needs it would I recommend investigating building a NuGet package. It is the same guideline as copying any other kind of code. Make sure you have enough use cases to identify a proper abstraction. If you can identify a proper abstraction, then build a NuGet package.

Until you have enough use cases, copy and paste is the better route.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.