Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Installing C at home

  • 17-05-2005 10:34am
    #1
    Closed Accounts Posts: 680 ✭✭✭


    Can anybody give me any tips for how to do this? I've tried to get Gcc and Cygwin working at home, but haven't had much success, especially with the former. Can somebody explain to me what bootstrapping is, and also how do you use "MAKE"?


Comments

  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    Amaru wrote:
    Can anybody give me any tips for how to do this? I've tried to get Gcc and Cygwin working at home, but haven't had much success, especially with the former. Can somebody explain to me what bootstrapping is, and also how do you use "MAKE"?
    Please explain what problems you had when trying to install gcc and cygwin.
    Did you use the Cygwin setup.exe? Tell it to download the packages and install them from there.

    "bootstrapping" is where you build or install core tools that you will need to complete the rest of the build/install. According to Ask Jeeves (search for 'define bootstrapping') it means "help oneself, often through improvised means".
    For cygwin it uses setup.exe to install cygwin, which will use the downloaded components to configure itself e.g. run bash or sed scripts.

    For "MAKE", here is a *very* basic tutorial. "Make" reads a makefile (a simple text file) to determine the steps required to do something, normally compile and link a C program into an executable.
    Makefiles have 'targets', 'dependencies' and 'actions'.
    If you have a C file, e.g. myprog.c, you will (presumably) want to compile it into myprog.obj and link it to myprog.exe. If myprog.c is newer than myprog.obj then you'll want to recompile it.

    In a Makefile this will look like:
    myprog.exe: myprog.obj
       link -o myprog.exe myprog.obj
    
    myprog.obj: myprog.c
       gcc -c myprog.c
    
    The tutorial explains this.

    Of course, I forgot to ask some questions:
    - What are you trying to compile?
    - Is it for school/college projects?
    - How much do you know about C programming?
    - What are you currently using? (this assumes you are coding at school so may not be an applicable question)


  • Closed Accounts Posts: 680 ✭✭✭Amaru


    Thanks, thats a pretty good answer. A couple of questions for you though, along with some answers.

    I've got cygwin installed, but the problem i've had is tying it into Gcc. I just plain don't know how to do it. It may already be included with Cygwin, because there is already a folder with that name installed in its directory, but i'm not sure how to use it.

    Secondly, do i have to download Make? Or should i already have it?

    As for what i need it for, its for a very important college project, and time is running out. I've spent ages trying to get it installed and working but to no avail. I need it to develop a simple GUI in C, which i'm told i'll need GTK for(i assume this is correct, and i suppose i'll have to deal with the problems of installing this when i come to it). I'm only versed in Java, and have to learn C from scratch, although i'm not worried about that, as i have very good tutorials for building the GUI, and thats pretty much all i care about. As long as i can get the tutorial code working, i should be able to adapt that to what i need.

    Again, i appreciate your help.


  • Registered Users, Registered Users 2 Posts: 441 ✭✭robfitz


    If you haven't already done so use setup.exe to install gcc, make and gtk2-x11-devel . That should pull in all the right dependencies.

    To run gcc you need to start the cygwin enviroment, look for the Cygwin icon.

    In this window you can use the cygwin programs you have installed. This interface is similar to using a Linux machine.

    gcc --help

    To test it you can type "gcc --help", this should display a list of gcc command line options.

    If you can't use the Linux tools to edit the files, you can create the files using windows tools by saving them in the location you installed cygwin, e.g. for me C:\cygwin\home\robfitz .


  • Closed Accounts Posts: 680 ✭✭✭Amaru


    robfitz wrote:
    If you haven't already done so use setup.exe to install gcc, make and gtk2-x11-devel . That should pull in all the right dependencies.

    How do i do this? I've just downloaded all the necessary sources. Do i just run setup.exe again,and it'll install them to the cygwin folder?


  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    its for a very important college project
    It really sounds like you are in way over your head. I suggest you go to your lecturer for assistance. S/He might have gcc or another compiler on a CD that you can borrow.

    Were you told you had to use cygwin/gcc? If so, were instructions on installing it provided?

    If anyone ever reads the 'perl-beginner' group on Yahoo! Groups, Randall Schwartz (big name in perl) always hassles people who ask for help with college projects. His logic is if people are asking for help there, the lecturer must not be doing their job. He always suggests that the student go to the lecturer to get more info (and, by doing so let the lecturer know that the earlier instructions were incomplete).
    Do i just run setup.exe again,and it'll install them to the cygwin folder?
    Yes.

    Sorry that I'm being abrupt and unhelpful. I'd love to help but there appears to be so much you need help with.


  • Advertisement
  • Closed Accounts Posts: 680 ✭✭✭Amaru


    There's not really that much, that i can see, that i need help with. I just need to get it installed, i can take care of the coding myself.

    And i wasn't told to use Gcc/Cygwin, but when i looked into a GUI development kit in C, everybody told me to use GTK+. When i tried to install that, it said it need a compiler, like Gcc, and an X Windows System, like Cygwin. If there's better alternatives, i'll use those?

    I do have cygwin installed now though and working properly, so its only a matter of getting Gcc and GTK+ working, which seems pretty straight forward? I've just never worked with C before, so its just taking me a little while to come to grips with its nuances.


  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    Assuming you're on windows.... download the Cygwin.exe installer. Run it, and in the packages selection window, open the "devel" list. Then scroll down the packages for gcc-c compiler (or something similar) and install the binary package.

    Then, when running cygwin the command to actually compile is "gcc -o OUTPUT.EXE INPUT.C


  • Registered Users, Registered Users 2 Posts: 7,278 ✭✭✭kenmc


    Amaru
    There's a quite detailed instruction set here:
    http://cygwin.com/cygwin-ug-net/setup-net.html

    Essentially the steps are:
    Download the installer, setup.exe
    Run this and you get the choice to install from the internet, download to a local hard drive , or install the stuff that has been downloaded to the hard drive.
    Then select the packages you want (will probably need to activate gcc, make and some other dev stuff - if you don't know what you want then you're missing the info you need, or you need to spend time understanding the options you have).
    It goes and does its funky thing, and when it's done you're good to go.

    I think that you misunderstand what cygwin actually is. It's not "C" or gcc. It's not make. It's an emulator for a unix/linux system which contains the functionality of that system. That functionality includes gcc and make and loads of other things if you so choose it to.


  • Closed Accounts Posts: 680 ✭✭✭Amaru


    You are actually correct, i didn't understand what it was until robfitz posted up what it does. I get what it is now though, i just need to get the relevant .tar files and i can import them then. I already imported one successfully last night(freetype i think). So at least i'm on the right track...


  • Closed Accounts Posts: 19,080 ✭✭✭✭Random


    If you just need a compiler and are using something like Context to write your code, have a look at this guide I did here for some of the lads in college:
    http://www.everythingelsewastaken.net/howto/gcc_compiler_setup/


  • Advertisement
  • Closed Accounts Posts: 680 ✭✭✭Amaru


    Argh! I successfully imported make, gcc and gtk, using cygwin's setup.exe, and it still doesn't recognise gcc as a command! Am i missing something?

    Why can't it be as simple as it says it is here

    http://www.eecg.utoronto.ca/~aamodt/ece242/cygwin.html


  • Registered Users, Registered Users 2 Posts: 7,278 ✭✭✭kenmc


    what do you mean by "imported" make, gcc etc? You should use the Setup.exe program and it will do it all for you. you may already have the files needed to install those on your hard disk, else go and get them from the web.
    your best bet is to
    - click on the "view" button until you see it says "Not Installed"
    - scroll down the package list until you see gcc/make/whatever and click on the "Skip" icon according to that until you get a number that it'll install (this is the version number. go for the higher number you can get, if you click again and again it'll step through the available versions and back to skip)
    - repeat for all the packages you want
    - when you have selected all your packages you want, then click next
    it'll go and do it's funky thing, and when you start up a cygwin window you should be able to type "gcc --version" and it'll give you something like this:
    gcc (GCC) 3.3.1 (cygming special)
    Copyright (C) 2003 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Hope this helps.
    Kenmc

    edit:
    it *is* as simple as it says there I'm afraid. you're just doing something slightly incorrectly, but I dunno what. I've done this a load of times and it just works.


  • Closed Accounts Posts: 680 ✭✭✭Amaru


    But thats exactly what i've done. I've used the setup.exe, pointed it to the .bz2 file for gcc, it goes to the next screen where it spends about 10 minutes copying it all across and everything, and then when i start up cygwin again, it doesn't recognise gcc.


  • Moderators, Science, Health & Environment Moderators Posts: 1,852 Mod ✭✭✭✭Michael Collins


    I'd recommend using Dev C++, the best C/C++ development software i've used.

    www.bloodshed.net


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    GCC comes as part of Cygwin. You sound like your trying to copy in GCC from somewhere else? Not trying to actually run a linux version of GCC are you?


  • Closed Accounts Posts: 680 ✭✭✭Amaru


    Hurray! Got it working last night, after i figured out what i'd being doing wrong all this time. I mistook "importing the packages using setup" to mean download setup, then download the packages independantly and use setup to import them. What you actually do is use the setup program to download the right packages for you. Apparently its not the same thing.

    So i now have Gcc working at home! One more question though. How do i "include" files in c. The gtk tutorial i have has its first line as

    #include <gtk/gtk.h>

    but it says no such file or directory. When i change it to gtk-2.0/gtk/gtk.h it gives me another ton of errors, because that .h file contains pointers to another set of .h files, and when i change those pointers, more errors, and so on. Anybody?


  • Registered Users, Registered Users 2 Posts: 441 ✭✭robfitz


    Amaru wrote:
    How do i "include" files in c. The gtk tutorial i have has its first line as

    #include <gtk/gtk.h>

    The gtk header files are installed in /usr/include/gtk-2.0 . This directory isn't part of the standard system include directories, to add it use the -I command-line option "gcc -I /usr/include/gtk-2.0".

    ...

    Ok, I've just check to make sure that works and there's a bit more that needs to be done.

    Make sure the following packages are installed:

    make
    gcc
    atk-devel
    glib2-devel
    gtk2-x11-devel
    pango-devel
    X-startup-scripts
    xorg-x11-base
    xorg-x11-bin
    xorg-x11-xwin
    xterm

    This was my test source file:
    #include <gtk/gtk.h>
    
    int main(int argc, char ** argv) {
        GtkWidget * window;
    
        gtk_init(&argv, &argc);
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_widget_show_all(window);
        gtk_main();
    
        return 0;
    }
    


    To compile and link the test source file I typed:
    gcc -I /usr/lib/glib-2.0/include -I /usr/include/glib-2.0 -I /usr/lib/gtk-2.0/include -I /usr/include/gtk-2.0 -I /usr/include/pango-1.0 -I /usr/include/atk-1.0 -l gtk-x11-2.0 -o gtktest gtktest.c
    


    To run the program you need to start x windows:
    startx
    

    From the new xterm window you can start your program:
    ./gtktest
    


  • Registered Users, Registered Users 2 Posts: 4,003 ✭✭✭rsynnott


    He be on Windows.

    I'm assuming you've got GTK installed? You should use the copy of BASH included with whatever GNU-for-windows thing you're using. First, run the example programs that come with GTK, to make sure everything's working. See if you're got an app called gtk-config somewhere. If so, try doing 'gtk-config --cflags --libs'. It should print out some command line options for GCC; either add those to your compile string or use the backtick operator (`, the thing to the left of 1 on your keyboard) like so:
    gcc `gtk-config --cflags --libs` -o test test.c


  • Closed Accounts Posts: 680 ✭✭✭Amaru


    You're actually both right. Firstly, the problem was that i was using ' instead of `. This is apparently a common mistake for newcomers to unix.

    After that was all fixed up, i ran into a second problem of

    "Gtk-WARNING **: cannot open display"

    This was then fixed by running the startx, like Robfitz said. So now i finally have a GUI working!

    Cheers guys.


  • Closed Accounts Posts: 680 ✭✭✭Amaru


    Oh yeah, another thing is, when i try to run a GUI with text in it, it says
    No fonts found; this probably means that the fontconfig
    library is not correctly configured. You may need to
    edit the fonts.conf configuration file. More information
    about fontconfig can be found in the fontconfig(3) manual
    page and on http://fontconfig.org

    Have you ever seen this before, and how do i solve it? The internet didn't prove much help. Am i supposed to download fonts to use?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 4,003 ✭✭✭rsynnott


    Ah, you're using X under Windows. Depending on what you're using this for, you might well be better off using a combination of this: http://www.mingw.org/ and this: http://www.gimp.org/~tml/gimp/win32/

    The first is a gcc port for Windows, the other is a GTK port for windows, which uses the windows API instead of X, thus avoiding font nastiness and such.


  • Closed Accounts Posts: 680 ✭✭✭Amaru


    I need it to make a GUI in C, which will be manipulating values inputted through the GUI, then displaying them. Is this suitable? And if so, how hard is it to set up?


Advertisement