Compiling Issue

Discussion in 'Mac Programming' started by ktalebian, Dec 1, 2008.

  1. ktalebian macrumors regular

    Joined:
    Dec 25, 2007
    #1
    Hi there,
    I have the following Makefile:
    sudoku-solver: sudoku2.c
    g++ sudoku2.c -o sudoku-solver

    When I run make on my Mac, the sudoku2.c compiles flawlessly and works fine.
    Now, on my Linux machine, I "tried" to install the GNU compiler (i suck at Linux! So I don't know if I installed it correctly or not!)
    But when I run make on Linux, I get an error saying that the files
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    where not found!!
    So is this because I didn't correctly install the libraries, or do I have to include these files some other way on a Linux?

    Thanks!
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    You should be using gcc not g++ to compile as it is a C source file not a C++ source file.
     
  3. ktalebian thread starter macrumors regular

    Joined:
    Dec 25, 2007
    #3
    Is that the only problem??
    Because my computer broke down and I don't have a linux to check this out!!
    So I don't have any other problem other than the way I compiled it right?! :p

    Thanks!!
     
  4. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #4
    Hard to say. I don't know which Linux distro you are using, which version of GCC you have, whether you installed it from source or it came with the distro, what your paths are setup as or any number of other things that could cause an issue.
     

Share This Page