Find the answer to your Linux question:
Results 1 to 3 of 3
Hey, I am not entirely new to linux, but I am jsut starting to getting into programming with it. Before now I was using an antique compiler (Borland TurboC++ in ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! th3dougler's Avatar
    Join Date
    Nov 2005
    Posts
    11

    Starting C++ w/ linux


    Hey, I am not entirely new to linux, but I am jsut starting to getting into programming with it. Before now I was using an antique compiler (Borland TurboC++ in command prompt) and I have tried compilig a few simple programs w/ it but i get a variety errors... none of which I am able to understand

    for example, my first C++ program
    Code:
    #include<iostream.h>
    #include<conio.h>
    void main&#40;&#41;
    &#123;
    cout<<"Hello World";
    getch&#40;&#41;;
    &#125;
    gets such errors as...
    Code:
    &#40;phlak@Phlak&#41;&#40;5/ttyp0&#41;&#40;05&#58;58pm&#58;11/17/05&#41;-
    &#40;%&#58;~&#41;- cc test.cpp
    In file included from /usr/include/c++/3.3/backward/iostream.h&#58;31,
                     from test.cpp&#58;4&#58;
    /usr/include/c++/3.3/backward/backward_warning.h&#58;32&#58;2&#58; warning&#58; #warning This fi
    le 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 in
    clude substituting the <X> header for the <X.h> header for C++ includes, or <sst
    ream> instead of the deprecated header <strstream.h>. To disable this warning us
    e -Wno-deprecated.
    test.cpp&#58;5&#58;18&#58; conio.h&#58; No such file or directory
    test.cpp&#58;7&#58; error&#58; `main' must return `int'
    test.cpp&#58; In function `int main&#40;...&#41;'&#58;
    test.cpp&#58;9&#58; error&#58; `getch' undeclared &#40;first use this function&#41;
    test.cpp&#58;9&#58; error&#58; &#40;Each undeclared identifier is reported only once for each 
       function it appears in.&#41;
    test.cpp&#58;10&#58;2&#58; warning&#58; no newline at end of file
    if there are any articles or something comparing the two compilers, I would really appreciate it... thx in advance

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    You're getting some errors that are likely related to a Windows upbringing in C++.

    From my understanding, conio.h is a file not seen in Linux, and so your attempt to include it is failing. You might also note that "iostream.h" is not really the proper way to do it, rather you do
    Code:
    #include <iostream>
    using namespace std;

    You are also being told that "void main" is not valid, and that it must rather be called "int main" and return 0 at the end. This is due to using an ANSI standard compiler, as opposed to the nonstandard Borland.

    As far as comparisons, I dunno where to look, but GCC is by far the most popular Linux compiler. I see that you're using "cc", which is, I believe, the standard C/++ compiler, but you might want to consider gcc.

  3. #3
    Just Joined! th3dougler's Avatar
    Join Date
    Nov 2005
    Posts
    11
    thx a bunch, im gonna put on gcc and try to compile again...

  4. $spacer_open
    $spacer_close

Posting Permissions

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