Tutorials/Compiling: Difference between revisions

From LifeWiki
Jump to navigation Jump to search
No edit summary
fmt
Line 2: Line 2:


== Getting Cygwin for Windows Users ==
== Getting Cygwin for Windows Users ==
'''Skip if you have a unix-ish command line'''
:'''Skip this section if you're using a Unix-compatible system.'''
Before you dive into compiling and you don't have a Unix-ish command line, you'll want to download [https://cygwin.com/ Cygwin], the 64 bit one, click dat link and then open the installer. While in the setup for packages, '''make sure''' to select the '''gcc-g++''' and '''make''' and include their dependencies when asked. Next you want to make a folder for your c stuff, preferably in your Cygwin folder, for this, make a folder in your C:\cygwin64\ folder, let's call it ''C'', and make a folder for the program in the C folder called ''gfind''. Now put your gfind.c file there. Now move on!
 
Before you dive into compiling and you don't have a Unix-ish command line, you'll want to download [https://cygwin.com/ Cygwin], the 64 bit one, click that link and then open the installer. While in the setup for packages, make sure to select the '''gcc-g++''' and '''make''' and include their dependencies when asked. Next you want to make a folder for your c stuff, preferably in your Cygwin folder, for this, make a folder in your <tt>C:\cygwin64\</tt> folder, let's call it ''C'', and make a folder for the program in the C folder called ''gfind''. Now put your gfind.c file there. Now move on!


== Compiling the Code ==
== Compiling the Code ==
Now we can actually compile. In the terminal, type in the following: <br/>
Now we can actually compile. In the terminal, type in the following:
<code>cd /C/gfind</code> <br/>
 
You should now see a yellow little thing that says "~/gfind", this means you are in the folder. Now, to compile, type: <br/>
<pre>cd /C/gfind</pre>
<code>gcc -o gfind gfind.c</code> <br/>
 
It will pause for a while, there might be some errors, but don't worry. After the command line comes back... Done! You've compiled gfind. To use it, do <br/>
You should now see a yellow little thing that says "~/gfind", this means you are in the folder. Now, to compile, type:
<code>./gfind</code> <br/>
 
<pre>gcc -o gfind gfind.c</pre>
 
It will pause for a while, there might be some warnings, but don't worry. After the command line comes back... done! You've compiled gfind. To use it, do
 
<pre>./gfind</pre>
 
You can do this for any other C program, just replace gfind with the program (e.g. zfind).
You can do this for any other C program, just replace gfind with the program (e.g. zfind).



Revision as of 11:47, 1 July 2017

Ah, so you've downloaded a search software but don't know what to do with that jumble of code. For this example, we will use gfind

Getting Cygwin for Windows Users

Skip this section if you're using a Unix-compatible system.

Before you dive into compiling and you don't have a Unix-ish command line, you'll want to download Cygwin, the 64 bit one, click that link and then open the installer. While in the setup for packages, make sure to select the gcc-g++ and make and include their dependencies when asked. Next you want to make a folder for your c stuff, preferably in your Cygwin folder, for this, make a folder in your C:\cygwin64\ folder, let's call it C, and make a folder for the program in the C folder called gfind. Now put your gfind.c file there. Now move on!

Compiling the Code

Now we can actually compile. In the terminal, type in the following:

cd /C/gfind

You should now see a yellow little thing that says "~/gfind", this means you are in the folder. Now, to compile, type:

gcc -o gfind gfind.c

It will pause for a while, there might be some warnings, but don't worry. After the command line comes back... done! You've compiled gfind. To use it, do

./gfind

You can do this for any other C program, just replace gfind with the program (e.g. zfind).

Examples you can try