Find the answer to your Linux question:
Results 1 to 4 of 4
hi, i´m trying to compile some very basic code in mandriva 2009,i´ve started to learn about c++ programing a couple of months ago in windows with microsoft visualc++ without any ...
  1. #1
    Just Joined!
    Join Date
    Mar 2009
    Posts
    2

    Can´t compile in linux

    hi, i´m trying to compile some very basic code in mandriva 2009,i´ve started to learn about c++ programing a couple of months ago in windows with microsoft visualc++ without any kind of problems,however in linux none of those code get compiled(i´ve instaled g++).
    Perhaps i´m not doing the right command(/home/emanuel/Desktop/1cp.cpp g++) or i´m missing something that ´s not instaled.
    also i get always these error while trying to compile:
    line 3: syntax error near unexpected token´('
    line 3: ´int main(void)'
    In function ìnt main()':
    5:error: ´cout´was not declared in this scope
    This is the code :
    #include<iostream>

    int main(void)
    {
    cout << "hello World\n";
    }


    But those error occur in every single code,and when it doesn´t hapen, it simple just doesn´t appear nothing in the next line , not even [emanuel@localhost ~ ]$sow i´m stucked and completly confused and can´t go any further in C++
    Any help regarding these problems would be very thankfull since i stucked here for two weeks now!

  2. #2
    Just Joined!
    Join Date
    Mar 2009
    Posts
    8
    #include<iostream>
    using namespace std;
    int main()
    {
    cout<<"HELLO WORLD";
    retrun 0;
    }


    try this .....

  3. #3
    Just Joined!
    Join Date
    Mar 2009
    Posts
    2
    sow i think it worked but i´m not sure ,after compiling just came back [emanuel@localhost~] $ ,how do see the output and where can i find the compiled code?

    thanks for helping

  4. #4
    Just Joined!
    Join Date
    Feb 2009
    Posts
    45
    Answer:

    Quote Originally Posted by Azzizz
    sow i think it worked but i´m not sure ,after compiling just came back [emanuel@localhost~] $ ,how do see the output and where can i find the compiled code?
    I advise you to become more acquainted with the compiler you plan to use before actually using it.¹

    The GCC-option you are probably looking for is “-o”, which determines the name of the output binary:
    Code:
    $> g++ SOURCE.cpp -o mybinary;
    $> ./mybinary;
    Hello world
    Footnotes:
    1. Google: gcc tutorial

Posting Permissions

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