Help: Visual Studio, Github and Libraries

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
NapalmHammer
Posts: 3
Joined: September 29th, 2016, 11:13 am

Help: Visual Studio, Github and Libraries

Post by NapalmHammer » April 28th, 2019, 12:31 am

Good evening, all. This may take a moment to explain, so bear with me, please.

I want to separate my reusable code into libraries, but I'm not sure how to go about this in conjunction with Visual Studio, and Github. I want to perform this in such a way that I can update them, or incorporate them into new projects easily and smoothly without hassle. Which makes me think that means hosting them on GH/some other VC is a good idea.

I have done a lot of googling on the issue, but I'm left almost more confused about what I should do than I was before. I've looked into Git submodules, but have been unable to understand how I can utilize that particular feature inside of Visual Studio. My understanding of Github is "just enough to be dangerous". I have had poor success using the git console, and prefer using the Github extension in Visual Studio.

Should it be as simple having a separate library project for each .lib, and when updating the code the library project, building it, and replace the .lib in my main projects whenever I make changes to the library(s)?

Is there some elegant and automatic way to go about this where when I update the code in my libraries, that they are somehow connected or linked to my main projects and are subsequently updated automatically?

Thank you, all!

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Help: Visual Studio, Github and Libraries

Post by albinopapa » April 28th, 2019, 3:34 am

I just keep the library code in separate folders without compiling them into a lib.

In the properties of your projects, you can add the folders to your Includes, Source and Library folders as well as add the .lib to your Linker / Input property for each project you need to use it on.

I wouldn't worry about compiling to a lib until you're done modifying ( with the exception of bug fixes ).
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

NapalmHammer
Posts: 3
Joined: September 29th, 2016, 11:13 am

Re: Help: Visual Studio, Github and Libraries

Post by NapalmHammer » April 28th, 2019, 7:35 pm

Thanks for your advice! I may just do that.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Help: Visual Studio, Github and Libraries

Post by chili » May 4th, 2019, 3:04 am

If you wanna do stuff like submodules, you are probably gonna have to get dirty with the command line. At the least, MSVC plugin will not be able to help you out.

Just copying the code like papa suggest is definitely gonna be the simplest solution. For myself, I usually don't even bother with separate folders. I try to organize my reusable code so that the classes have their own files, and when starting a new project i can just copy files over for the classes that I need.

If you want a slick automated way of adding packages of code to your projects, you can look into a package manager like conan. It also allows you to use the same system for pulling 3rd party code as for your own internal libs. But it will likely be annoying to setup, so try this only if you're interested in that kind of stuff.
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Help: Visual Studio, Github and Libraries

Post by albinopapa » May 4th, 2019, 3:22 am

@Chili, I usually use that approach more often than not, but usually forget the latter step of copying over the reusable code so I have had in the past like 5 different versions of Vec2 and the like, mostly because I could never settle on a revision I liked. Some versions were like yours ( ok most ) and some I took the dot and cross product and other manipulative functions out of the vector classes and made global functions, some I put in a namespace like namespace vector_math or just math. Some I've optimized for SIMD and some were not so optimized. I have tried making type traits for them, but really only useful in template metaprogramming cases. I've tried making them more like arrays giving them subscript operators to which was nice for interacting with templated matrices where the sizes weren't a part of the class itself but a part of the type matrix<T, size_t, size_t>, vector<T, size_t>.

In the current project, I'm using a separate folder for my 2D algorithms, iterators, containers and wrappers. I kind of want to put them in a sub-folder to make it easier to tell what files are a part of that collection though. While using this library of mine, I'm noticing how frustrating it must be for library authors.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply