Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [DFHack] How to make C++ utility without using Git?  (Read 1704 times)

SlimeOfSteel

  • Bay Watcher
  • Novice Programmer
    • View Profile
[DFHack] How to make C++ utility without using Git?
« on: May 15, 2018, 09:38:41 am »

I want to create a C++ utility for DFHack, and I'm new to C++ in general. So I start looking up how to make C++ plugins when I come across this:

Quote
DFHack doesn't have any kind of system of code snapshots in place, so you will have to get code from the GitHub repository using Git.

It seems kind of pointless to just use a few commands when I could install the files myself, so I was wondering, would downloading the source code zip yield the same results?

EDIT: Also, is using Visual Studio necessary? Could I use Eclipse instead?

EDIT 2: Okay, I lied. I have no idea what I'm doing. Can somebody explain to me how to build dfhack or whatever? It makes zero sense to me.
« Last Edit: May 15, 2018, 10:06:12 am by SlimeOfSteel »
Logged
It works, but I don't know why.

Hugo_The_Dwarf

  • Bay Watcher
  • Modding Mentor
    • View Profile
    • Regeneration: Forced Evolution
Re: [DFHack] How to make C++ utility without using Git?
« Reply #1 on: May 15, 2018, 12:19:11 pm »

Visual Studio isn't necessary however it normally comes with the required C, C++ and C# compiler and libraries. Without a compiler you can't build anything.

You could use Eclipse if you can setup a C++ compiler for your builds

and you can go to the GitHub repo and just "download" the master branch as a zip yes. But using GIT (with or without a supporting GUI) makes getting the latest version much easier. Git is not a scary thing, if anything the commands you will be using is probably "pull" (it's a fetch from master + merge local combo) and I doubt you'd be adding so I doubt you'll be committing and pushing (or branching, committing, pushing, and merge request into master)

I've never made a plugin, and not that great with DFHack. I'm only talking to the high level stuff

 
Logged

SlimeOfSteel

  • Bay Watcher
  • Novice Programmer
    • View Profile
Re: [DFHack] How to make C++ utility without using Git?
« Reply #2 on: May 16, 2018, 09:17:01 am »

Visual Studio isn't necessary however it normally comes with the required C, C++ and C# compiler and libraries. Without a compiler you can't build anything.

You could use Eclipse if you can setup a C++ compiler for your builds

and you can go to the GitHub repo and just "download" the master branch as a zip yes. But using GIT (with or without a supporting GUI) makes getting the latest version much easier. Git is not a scary thing, if anything the commands you will be using is probably "pull" (it's a fetch from master + merge local combo) and I doubt you'd be adding so I doubt you'll be committing and pushing (or branching, committing, pushing, and merge request into master)

I've never made a plugin, and not that great with DFHack. I'm only talking to the high level stuff

Thanks anyways, I've got one part of my problem solved. Now I just need to find out how to actually get everything else working.
Logged
It works, but I don't know why.

lethosor

  • Bay Watcher
    • View Profile
Re: [DFHack] How to make C++ utility without using Git?
« Reply #3 on: May 16, 2018, 06:04:33 pm »

Short version: you need git, and you should follow the instructions in Compile.html as closely as possible to avoid pain and suffering.

Visual Studio isn't necessary however it normally comes with the required C, C++ and C# compiler and libraries. Without a compiler you can't build anything.

You could use Eclipse if you can setup a C++ compiler for your builds
Visual Studio is absolutely necessary. DFHack is loaded in the same memory space as DF, and must use the same runtime libraries, or it will crash. This means that it must be built with the same compiler as DF, which is Visual Studio 2015. Some people have had luck using the 2015 compiler in VS2017, but I'm not sure of the process there, so I would really recommend VS2015 to make things easy.

If you can get Eclipse working with the VS2015 compiler, then it might work, but otherwise it will not.

Quote
and you can go to the GitHub repo and just "download" the master branch as a zip yes.
No, you cannot do that. DFHack contains several other repos as submodules, which will be downloaded if you use git (and follow the instructions in Compile.html), but the "download ZIP" option will not download any of them, so the build will fail at the configuration stage (in fact, we added checks at the configuration stage to prevent people from doing exactly this).

To be clear, we always appreciate contributions, but things go much more smoothly if you follow the build instructions - they were put together for a reason. We also really prefer that you use GitHub to submit pull requests for things to be added - sending in raw files quickly becomes a nightmare when we make changes after merging but you don't update your copy with those changes, etc.

In case you were unaware, there are two main branches of DFHack that you can get with Git - "master" (stable, most recent stable release) and "develop" (less stable, but with newer changes after the last release). I imagine that the master branch is fine for general plugin development, but if you want to work with 0.44.10, you'll need the develop branch for the time being. There are two corresponding versions of Compile.html - they're usually mostly the same, but it's good to look at the right one:
https://dfhack.readthedocs.io/en/stable/docs/Compile.html (master)
https://dfhack.readthedocs.io/en/latest/docs/Compile.html (develop)

EDIT 2: Okay, I lied. I have no idea what I'm doing. Can somebody explain to me how to build dfhack or whatever? It makes zero sense to me.
If it's a matter of the instructions being unclear, I'd be happy to work with you to improve them, but I'd need a bit more specific feedback. How far have you gotten?
« Last Edit: May 16, 2018, 06:06:38 pm by lethosor »
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

SlimeOfSteel

  • Bay Watcher
  • Novice Programmer
    • View Profile
Re: [DFHack] How to make C++ utility without using Git?
« Reply #4 on: May 17, 2018, 09:21:49 am »

Short version: you need git, and you should follow the instructions in Compile.html as closely as possible to avoid pain and suffering.

Visual Studio is bsolutely necessary. DFHack is loaded in the same memory space as DF, and must use the same runtime libraries, or it will crash. This means that it must be built with the same compiler as DF, which is Visual Studio 2015.

DFHack contains several other repos as submodules, which will be downloaded if you use git (and follow the instructions in Compile.html), but the "download ZIP" option will not download any of them, so the build will fail at the configuration stage (in fact, we added checks at the configuration stage to prevent people from doing exactly this).

So I actually do need Visual Studio and Git. Thanks for telling me.

If it's a matter of the instructions being unclear, I'd be happy to work with you to improve them, but I'd need a bit more specific feedback. How far have you gotten?

Right now I'm gathering info about what I need to do, and I'm also planning everything out so I can set up an effective workspace. I'll follow the instructions you've listed as best I can.

Speaking of the instructions, under the dependencies section, it states that Perl and Python are required (Python is said to be optional except for release builds). As stated previously, I plan to use C++ for my plugin. Why is Perl required?
Logged
It works, but I don't know why.

lethosor

  • Bay Watcher
    • View Profile
Re: [DFHack] How to make C++ utility without using Git?
« Reply #5 on: May 17, 2018, 10:06:31 am »

Perl is used for code generation - it produces all of the DF headers in library/include/df/ from XML files in library/xml, and most files in DFHack need those headers. (There's a note in the Linux section saying these are "for the code generation parts", but apparently not in the Windows section.)
You don't need chocolatey to install these, by the way, if you can figure out how to do it manually (there's a manual installation section below the chocolatey one).
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

SlimeOfSteel

  • Bay Watcher
  • Novice Programmer
    • View Profile
Re: [DFHack] How to make C++ utility without using Git?
« Reply #6 on: May 17, 2018, 10:16:13 am »

Perl is used for code generation - it produces all of the DF headers in library/include/df/ from XML files in library/xml, and most files in DFHack need those headers. (There's a note in the Linux section saying these are "for the code generation parts", but apparently not in the Windows section.)
You don't need chocolatey to install these, by the way, if you can figure out how to do it manually (there's a manual installation section below the chocolatey one).

Gotcha. Thanks a ton for the info.
Logged
It works, but I don't know why.

SlimeOfSteel

  • Bay Watcher
  • Novice Programmer
    • View Profile
Re: [DFHack] How to make C++ utility without using Git?
« Reply #7 on: May 18, 2018, 09:17:44 am »

Okay, so now I've run into quite a significant problem. From some of my research, apparently Visual Studio cannot be run on a USB drive. (I probably should have mentioned I was using a USB drive in the first place.)

However, I came across something called Visual Studio Code (https://code.visualstudio.com) that says it IS portable, and I was wondering if that would work if I used the VS 2015 C++ compiler in that. It also says it has built-in Git, so that's pretty cool.

EDIT: Nevermind, you still have to install Git.
« Last Edit: May 18, 2018, 09:53:11 am by SlimeOfSteel »
Logged
It works, but I don't know why.

lethosor

  • Bay Watcher
    • View Profile
Re: [DFHack] How to make C++ utility without using Git?
« Reply #8 on: May 18, 2018, 09:30:12 am »

Are you unable to install things on your main hard drive? I don't know if other dependencies (Perl, CMake, etc.) can be installed on an external drive.

VS Code is completely different from Visual Studio except for its name, but if you can get the VS2015 compilers to work, it might work. BenLubar thinks https://www.visualstudio.com/vs/older-downloads/#microsoft-build-tools-2015-update-3 might be useful.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

SlimeOfSteel

  • Bay Watcher
  • Novice Programmer
    • View Profile
Re: [DFHack] How to make C++ utility without using Git?
« Reply #9 on: May 18, 2018, 09:44:33 am »

Are you unable to install things on your main hard drive?

Yes and no. When I can access my home PC, I can install things just fine on the hard drive. However, I planned to use an external hard drive so even if I can't access my main PC, I can work on the plugin(s) whenever I wanted.

VS Code is completely different from Visual Studio except for its name, but if you can get the VS2015 compilers to work, it might work.

If I can get Visual Studio Code to use the VS2015 compiler, then I think we'd be good to go.
Logged
It works, but I don't know why.

SlimeOfSteel

  • Bay Watcher
  • Novice Programmer
    • View Profile
Re: [DFHack] How to make C++ utility without using Git?
« Reply #10 on: May 25, 2018, 08:52:45 am »

Okay, so I've decided to keep the whole Visual Studio fiasco on this thread instead of clogging up the DFHack thread.

If Visual Studio installs to the C:/ drive, why not just copy the installed files to the drive you want? It seemed kinda obvious, and I don't know why I tried that before. I mean, I could run something like Notepad++ off the flash drive, so why not Visual Studio?

While the version I installed was VS2017, I'll just use the VS2015 compiler. I don't think the version you use matters, as long as you have the 2015 compiler.

Anyways, while it does seem to be starting up from the flash drive, but because I don't have the proper .NET Framework installed on the drive, I can't run it. So I'll install .NET and see what happens.

By the way, I want to apologize to BenLubar because I had to go and overcomplicate things.
Logged
It works, but I don't know why.

SlimeOfSteel

  • Bay Watcher
  • Novice Programmer
    • View Profile
Re: [DFHack] How to make C++ utility without using Git?
« Reply #11 on: June 08, 2018, 04:55:47 pm »

Hello there, it's been a bit of time since I posted, but I have some good news.

I no longer have to worry about Visual Studio running on a flash drive, as I can now freely access my home PC whenever I please!

Now all I have to do is actually learn C++. Easier said than done, though.
Logged
It works, but I don't know why.