Find the answer to your Linux question:
Results 1 to 4 of 4
hi, how can i know whether i have installed C++ libraries in the debian i have tried out with gcc command but it is not working gcc sample.cpp student@debian:~$ gcc ...
  1. #1
    Linux Newbie
    Join Date
    Jul 2007
    Location
    india,andhra pradesh,hyderabad
    Posts
    125

    how to execute C++ files ?

    hi,

    how can i know whether i have installed C++ libraries in the debian
    i have tried out with
    gcc command but it is not working

    gcc sample.cpp

    student@debian:~$ gcc 1.cc
    In file included from /usr/include/c++/4.2/backward/iostream.h:31,
    from 1.cc:1:
    /usr/include/c++/4.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
    1.cc:3: error: ‘::main’ must return ‘int’
    student@debian:~$ ./a.out
    bash: ./a.out: No such file or directory
    rocky

  2. #2
    Just Joined! sum7's Avatar
    Join Date
    Aug 2008
    Location
    Mysore,India
    Posts
    18
    Use the command below
    g++ -v
    This will show all the info about the c++ compiler you have in your system.
    Do
    g++ file_name.cpp
    This will compile and generate a.out file if your program has no errors.
    Do
    ./a.out to see the output on display.

  3. #3
    Linux Engineer rcgreen's Avatar
    Join Date
    May 2006
    Location
    the hills
    Posts
    1,112
    1.cc:3: error: ‘::main’ must return ‘int’
    Correct this error in your code.

  4. #4
    Linux Guru techieMoe's Avatar
    Join Date
    Aug 2004
    Location
    Texas
    Posts
    9,496
    To summarize the last two posts, there are two problems with your program. The first is that you're trying to compile a C++ program using the regular GNU C Compiler. That just won't work. You have to use g++ to compile C++.

    The second issue, as stated above, is that you have an error in your code. Code will not compile (and therefore not produce an a.out file) unless it is free of errors. Fix that error in your code and use the right compiler and you should be fine.
    Registered Linux user #270181
    TechieMoe's Tech Rants

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •