Author Topic: Problem compiling and running plain file ( on ubuntu)  (Read 2754 times)

Offline san_zoulapi

  • Single posting newcomer
  • *
  • Posts: 3
Problem compiling and running plain file ( on ubuntu)
« on: October 23, 2009, 08:13:20 pm »
Hello I'm new to ubuntu (and linux generaly) and am presently trying to use code::blocks on Uuntu 9.04 for simple school projects on c++. I installed the package without getting any errors , created a new empty file and typed a simple hello world program:

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}

After clicking on build --> compile (and setting the text file executable manualy-did not find other way of rendering it possible to execute ) , and then Run , I get the following message :

/home/username/filename:2:using:not found
/home/username/filename: 4 : Syntax error: "(" unexpected

Press ENTER to continue.

The same error apears every time i try to compile/run other sources that work on windows dev for example. Any help? Thx
« Last Edit: October 23, 2009, 08:16:06 pm by san_zoulapi »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Problem compiling and running plain file ( on ubuntu)
« Reply #1 on: October 23, 2009, 08:26:22 pm »
Do you have a compiler? gcc, g++?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline san_zoulapi

  • Single posting newcomer
  • *
  • Posts: 3
Re: Problem compiling and running plain file ( on ubuntu)
« Reply #2 on: October 23, 2009, 09:23:24 pm »
Yes i have them installed and working. I tried manually compiling the text file using gcc via the terminal  (after adding a .cpp extension to it) and it worked fine.

Offline koso

  • Multiple posting newcomer
  • *
  • Posts: 58
Re: Problem compiling and running plain file ( on ubuntu)
« Reply #3 on: October 23, 2009, 09:37:01 pm »
Have you saved that new file with proper C/C++ extension before compilation?

Offline san_zoulapi

  • Single posting newcomer
  • *
  • Posts: 3
Re: Problem compiling and running plain file ( on ubuntu)
« Reply #4 on: October 23, 2009, 09:46:40 pm »
 It worked.....I thought the IDE would set the .cpp extension itself before compiling and i didnt think of it. Thx a lot