Thread: gcc problems with Fedora Core 3

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    2

    gcc problems with Fedora Core 3

    All,
    Please excuse me, I'm rather new at working with C on LINUX. I'm trying to implement some code that will read information off of my weather station then post it to the web. Thought it would be as simple as running 'make' and then executing the code, but gcc came back with pages of errors. So I've stepped back to the simple 'hello world' code to familiarize myself with gcc.

    My code is as follows:
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
       cout<<"HEY, you, I'm alive!  Oh, and Hello World!\n";
       cin.get();
    }
    I'm also using the following makefile:

    Code:
    CC= gcc
    LIBDIR= -I/usr/include/c++/3.4.2
    SRC= test.c
    OBJS= test.o
    PROG= test
    
    test:  ${OBJS}
               ${CC} -o ${PROG} ${SRC} ${LIBDIR}
    When I run make, I get the following errors:

    test.c:1:20: iostream: No such file or directory
    test.c:3: error: syntax error before "namespace"
    ......

    I've been unable to correctly characterize the header files locations so that the gcc recognizes it.

    Thanks

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    1) This is not the general Linux support forum.
    2) You're not programming in C at all. That's C++.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    2
    Like I said! I'm new at this

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Ok, well I'm just telling you, you are in the wrong place for your question. You need the Fedora newsgroup or a basic "help me set up my linux box" site. The problem, as with your previous post on the same thing, appears to be that you don't have your compiler installed correctly.

    I'd suggest looking for a linux forum or newsgroup.


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > So I've stepped back to the simple 'hello world' code
    So write it in C then
    Code:
    #include <stdio.h>
    int main ( void ) {
      printf( "hello world\n" );
      return 0;
    }
    And since this is C, there's no need for LIBDIR

    >test: ${OBJS}
    Calling programs test in Linux/Unix is a bad idea, there's also a shell command of the same name.
    Which if you invoke without parameters does nothing.
    Code:
    $ cat test.c
    #include <stdio.h>
    int main ( void ) {
      printf( "hello world\n" );
      return 0;
    }
    $ gcc -o test test.c
    $ test
    $ ./test
    hello world
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. gcc asm code syntax
    By Uberapa in forum C Programming
    Replies: 4
    Last Post: 06-15-2007, 01:16 AM
  3. segfault with gcc, but not with TC
    By koodoo in forum C Programming
    Replies: 15
    Last Post: 04-23-2007, 09:08 AM
  4. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 06:35 AM