I've downloaded a dead simple Windows program from GitHub (this if it's relevant). I downloaded it as a ZIP file, but I can't figure out how to install it. It's written in C, I think. Do I need a compiler? (Visual Studio?) Is there something simple that I'm missing?
-
9Sorry, this is obviously a major noob issue I'm having. How? There's no executable file.– Josh FriedlanderApr 20, 2017 at 12:36
-
6You probably need Windows SDK and the associated C headers to compile the program. Normally, the dependencies are mentioned and compile instructions are included in the Readme. In this case, neither is included, so you have to ask the repo owner/project author to get the relevant information.– LarssendApr 20, 2017 at 12:40
-
7You do need a compiler. I would reach out to the dev and ask how to build it. Typically Linux software, for example, provided as source includes build instructions but I don't see any on his Github.– LawrenceCApr 20, 2017 at 12:40
-
12You haven't downloaded an actual program, you have downloaded the source for the program and, yes, you do need to compile it first. Judging by the makefile in there you will need to build whatever it is in MINGW.– Mokubai ♦Apr 20, 2017 at 12:42
-
21here is the executable github.com/renatosilva/winutils/releases– barlopApr 20, 2017 at 12:50
4 Answers
Github is primarily used by programmers to collaborate on projects. The 'Download ZIP' option downloads a copy of the source code to your computer. This usually1 doesn't contain a copy of the compiled usable executables/binaries (ie; exe files)
Releases, is a Github feature for shipping software to end users (who usually aren't interested in the actual coding). Releases are accompanied by release notes and links to download the software or source code. This is the first place you should check for binaries.
In your case, the releases page offers downloads and setup files.
However, many projects won't have any releases (especially not for Windows), in which case you can do one of the following:
Search for binaries elsewhere on the internet. Usually search engines like DuckDuckGo (or Google, if you prefer) will find what you want easily. Try searching for
<application name> for Windows
or<application name> exe
.Compile it yourself. You need to have at least some basic knowledge of the programming language to be able to do so. Here again, search engines can be massively helpful. Try searching for
compile <application name> on Windows
orMinGW compile <application name>
.Here I'll run through the basics of compiling utilities for Widnows:
Download MinGW. I personally favor this package because it comes with boost (which several applications use) and a cool shell. It also comes with
git
, which can be super useful if you want to compile files hosted on Github or other Git version control repositories without having to separately download the source.Run the following commands in
cmd
orpowershell
:cd c:\sources\hello
: Change the directory to wherever it is that the source file(s) is/are located.g++ helloworld.cpp -o helloworld.exe
: herehelloworld.cpp
is the name of the main source file, andhelloworld.exe
is the name of the compiled executable.- In case you have to compile multiple files list them before the
-o
switch:g++ helloworld.cpp foo.cpp -o helloworld.exe
- These are the instructions for C++. If you're dealing with applications programmed in C, the file extension will be
.c
instead of.cpp
, and you should use thegcc
command instead ofg++
. The rest is more or less identical - Note that you may need to specify more command line arguments in order to compile an executable which works properly. The project page will usually have these details.
- You also
probablydefinitely want to look into makefiles. This Stack Overflow post is about makefiles in general, and this one tells us how to use them with MinGW. If a project comes with a makefile, try it before manually compiling the source. - You should now be able to run
helloworld.exe
.
- Note: Most projects come with a README file. Please do what the name implies, these files contain important information regarding compiling and running software and by reading it you can avoid a lot of unnecessary hassle.
1Note: Sometimes there may be a folder called bin
among the downloaded files, which should contain usable executables/binaries
Also see Cygwin and GOW if you want GNU/Linux command line utilities on Windows. I make some the latest version of some useful executables available for download here.
Further reading:
http://www.mingw.org/wiki/MinGW_for_First_Time_Users_HOWTO
https://gcc.gnu.org/onlinedocs/index.html#dir
https://stackoverflow.com/questions/22873884/how-do-i-run-configure-with-mingw
-
Thanks, this is a great answer, and I've changed it to be marked as the definitive one. (I'd earlier edited my question to make it clearer that this was what I was looking for, but for some reason BoundaryImposition edited it out.) Apr 23, 2017 at 14:10
-
I don't think it satisfies Aibobot's bounty request, however, but that's between you and her/him. Apr 23, 2017 at 14:11
-
2@JoshFriedlander Glad to be of any help! I'll add more to the answer later... Yep, I was chatting with JourneymanGeek (Aibobot), he's going to wait for a few days for new answers to surface.– undoApr 23, 2017 at 14:11
-
1This project might not have any, but note that most projects will probably have dependencies, which means that if you're going the compilation route, you may need to track down the libraries that the software depends on, download them, and install them (or compile them as well). It's usually not as simple as just running the makefile; some of them may even have other build scripts such as cmake, configure script, etc.– jrhApr 23, 2017 at 18:58
-
2Is the process really that simple in most cases? Which fraction of github utilities requires substantially greater knowledge to compile them than this what You’ve described here?– gaazkamApr 23, 2017 at 21:33
You look around and find the installer on the release page. Sure you could compile the source, but I don't think that's what you want.
-
49Agreed. If you have to ask, you don't want to be compiling from source. Apr 20, 2017 at 16:59
-
10If you have to ask, you probably shouldn't be installing software that's only available in source form...– jpaughApr 20, 2017 at 19:15
-
11I'm inclined to agree with @jpaugh. While it's very possible and sometimes necessary to build from source, it's not something that you can just go and ask "how do I build a C program" in a generic way. There's just too much variance. Some lucky programs are as simple as "compile these files". Others need makefiles. Some need dependencies to be downloaded first. The process of setting up for build can be complicated and isn't necessarily non-programmer friendly. Above all, though, you want to find a file in the project that explains how to build, because specifics are project dependent.– KatApr 20, 2017 at 19:36
-
35@jpaugh - I'd say you have a much better chance of installing malware by downloading an executable - malware is rarely open-source.– nameyApr 21, 2017 at 0:22
-
3Assuming you can actually read the language. I semi routinely compile stuff on linux and I can't/don't read any of the source. Even if i could, I'm not going to review every.single.line.– Journeyman Geek ♦Apr 22, 2017 at 0:36
.c and .h files are C source code.
You will need to install a C compiler such as Visual Studio, tcc or something similar, load the project and then compile it to run it.
Failing that, the project has a release page (here) that will give you access to a pre-compiled version to save you time and effort.
-
14If he had to compile it then it'd usually be explained in a readme, which you don't even mention he should look for. He is meant to go to the release page, it's not just "failing that(installing a compiler), that he should go to the release page"– barlopApr 21, 2017 at 12:53
-
3
-
1A specific project is usually tailored for use with a specific set of compilation tools (called a "toolchain") - which one it is is normally mentioned in a readme file (in UNIX and cross-platform projects, it's conventionally named BUILD or INSTALL). In less than stellarly maintained projects, or projects for environments with only a few well-known toolchains, a user is supposed to guess from the format and/or content of project files. Apr 22, 2017 at 5:14
-
This answer will be addressing the general question of building a source-only Windows application (in C). If you're lucky like the OP, you might be able to find precompiled binaries.
The first thing to be aware of here is that there's no single way to build an app from source. There are approximately as many variations as there are different projects. That said, here are some general steps:
If you're lucky, the project will provide build instructions, usually within the
README
file. Occasionally, there might also be anINSTALL
file, or other documentation available. If those are available, follow the instructions. They're your best bet.As others have said, unfortunately, it's very difficult to reconstruct the required build steps without instructions. However, we can at least make a best-effort attempt here, which will work for most simple projects.
Lacking instructions, the next port of call is to check which build tool is required.
If you find a file with a
.sln
or.vcxproj
extension, this is probably a MSBuild/Visual Studio project. Download a copy of Visual Studio Community or Express (for C++), open that project file in there, and click the play button in the toolbar (or use the build menu).If you find a
Makefile
, this is probably going to requiremake
. But this is where things get even more difficult, since there's so many independent and incompatible systems that usemake
.Since it's targeted towards Windows, it's probably going to use MinGW. Download a copy of that, launch MSYS from your start menu, navigate (
cd
) to the directory that contains your project, and runmake
.On the rare occasion that it's Cygwin instead (there's no easy way to tell, unfortunately, but if the MinGW build errors out with a "posix"-related error, this is a decent bet), you'll have to install Cygwin instead. Unfortunately, this does not build native Windows binaries -- you'll have to launch the program through Cygwin every time.
The "build tool" could be a custom script by the name of
build.bat
or similar. In this case, you'll have to either open it up and see what's inside, or try running it and see what the errors are. If you open it and see mentions ofGCC
, go back up to the 2.2.1. MinGW step but run the custom script instead ofmake
.
It's possible that there's no build tool at all. If all you encounter is a single
.c
or.cpp
file, then it's probably simple enough that you can do a straight compile. These are, again, almost always MinGW, so download that, launch the MSYS shell, navigate to the directory, and invoke eithergcc
org++
as necessary -- e.g.gcc -o program.exe program.c
It's possible that none of these work. If you got error messages at any step, they might contain a clue of what's missing. One possibility is that you were lacking certain required frameworks or libraries -- if you feel up to it, you can try downloading those and adding them to your build environment, but this is typically not a trivial process and has so many variations there is no way to cover them in an answer.
Glossary
Build tools
A build tool allows you to build a project with very few commands. For most projects with more than a single source file, a build tool will be involved somewhere. There are several build tools, but the most common are:
make, used everywhere on Linux and increasingly common on Windows. Projects using
make
can usually be identified by the presence of aMakefile
.MSBuild is Windows-specific and is typically seen in conjunction with Visual Studio. These will usually be accompanied by a
*.sln
or*.vcxproj
file.
Toolchains
A toolchain is the compiler and supporting tools. Just like the build tools, there are several, and they're usually used with one of the build tools.
MSVC is Microsoft's toolchain. This is the most common toolchain for Windows native development. This is usually used with the MSBuild system, and builds are usually created through Visual Studio. However, modern MSVC projects can use
Makefile
too.GCC (MinGW) is a port of GCC for Windows. Usually used with
make
. If the project is targeted towards Windows natively and has aMakefile
, it's probably for MinGW-GCC.GCC (Cygwin) creates a POSIX-compatible environment. This allows you to directly compile most programs written for Linux or Unix and have it work directly under Windows. More recently in Windows 10, Bash on Ubuntu on Windows is an alternative. GCC is usually used in conjunction with
make
.
Frameworks and libraries
Libraries are reusable sets of code written by other people, that many programs depend on to avoid reinventing the wheel. You need to have these dependencies available in order to build the project. If you're lucky, they'll be included with your initial download, but this is not always the case.
Frameworks are effectively a collection of libraries. Many projects use one framework, which you'll also need. These often come with their own build system too, but listing them all would be impossible.
The hardest part is dealing with extra framework and library dependencies. If, say, the project uses Qt -- then you'll need that whole mess to build it properly. This is a huge undertaking, and unless you have prior experience it's probably better to just ask others for direct help here.
-
1In this particular case the makefile gives you a good clue that it is for mingw as the first line is
MINGW_PREFIX = $(shell which gcc | awk -F/bin/ '{ printf $$1 }')
:)– DavidPostill ♦Apr 23, 2017 at 14:48 -
1