-2

tl;dr I have code I think others would find useful but don't know how to package it up for others to include in their projects and easily modify.

I'm new to C++ and created an algorithm to solve paths efficiently (enough) for a bot. The algorithm creates the longest path possible within a set of points ("Nodes") with the two limitations being that the Nodes are single-visit only and that the next Node hopped to must be within X distance of the current Node.

After having "finished" the bot (learning exercise) I decided that it would make sense to remove the pathfinding algorithm from the bot and package it up as a more generic and understandable snippet to host on GitHub for others to use.

I'm having an oddly difficult time finding information on how to best construct my "library" - probably because it's really obvious if I were more familiar with C++. I don't want it to be like OpenCV where it's a DLL and my only other example is a .hpp JSON library + the information in the Google Style Guide.

I'm not certain as to whether distributing my code as a Header (with overview + usage documentation) and CPP (with more specific comments) file will result in what I want - which is the JSON .hpp workflow - I simply had to download the file, #include JSON.hpp, and then I was able to call its methods.


<-< PS. How does one name such an algorithm? I'm using a namespace as per the Google recommendations but at the moment that would result in a REALLY long name for devs that aren't #using my namespace.

Google's Styleguide is for a large project - not a single distributed file - so perhaps I should name the GitHub / "official name" something descriptive but give the namespace / project "SVNL" ?

Single Visit Node Linker

Single Visit Node Pathing for Maximum Nodes Traveled Within Distance Between Individual Nodes

Visit Maximizing Node Linker Within Distance Between Individual Nodes

  • 1
    the algo is a traveling salesman issue. Check this one out. http://parano.github.io/GeneticAlgorithm-TSP/ to share... create a github account and post the repo there, it will evolve into something shareable... – g19fanatic Apr 17 '18 at 19:48
  • 2
    You can look at existing projects. The problem is that there is no standard way to distribute or package c++ libraries so you should figure out it yourself. Beside library file itself your repo should contain some test, some example code and some ReadMe notes on what is it. – user7860670 Apr 17 '18 at 19:52
  • Also, [the Google style guide if for people who *have* to use it](https://stackoverflow.com/questions/5184115/google-c-style-guides-no-exceptions-rule-stl), not for someone who has a choice. – Bo Persson Apr 17 '18 at 21:57
  • @VTT What kind of test? Like a standard unit test or? I'm unfamiliar with TDD. – Travis Foster Apr 18 '18 at 22:16

1 Answers1

0

There is no standard way to distribute C++ code, but the easiest way to distribute a small library like yours is to wrap it in a short namespace and post it to GitHub/GitLab/BitBucket/etc.

I would make sure to include a readme explaining what the project is, how to use it, and how to build it. Bonus points for writing a build script and including it in the repository.

Increasingly Idiotic
  • 5,700
  • 5
  • 35
  • 73
  • 1
    in contrary to other languages, package management isn't as trivial for C/C++. though there is one package manager, still in it's baby-steps called Conan... worth a check. – Tomer W Apr 18 '18 at 11:26