Jump to content

Cannot compile any C++ program (Ubuntu)

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
8 replies to this topic

#1
Decae

Decae

    Newbie

  • Members
  • Pip
  • 8 posts
I'm using Anjuta for programming C++ right now, but it cannot compile properly at all. When I press "compile" this is the error shown:

make New file 1
make: *** No rule to make target 'New'. Stop.

Can someone please explain what is going on? I've already tried compiling on a lot of different IDEs. D:

Also, I'm just doing the simple "Hello world" program if you were wondering. It doesn't make a difference whether it's complicated or as simple as hell right now though.

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
Did you create a new project for it and save before building? I don't recommend Anjuta among others, make files for a simple project is just plain messy. Ensure the build essentials packages is installed:
sudo apt-get install build-essential
And then you can install a more lightweight and simpler IDE such as Geany:
sudo apt-get install geany
It's almost as lightweight as a text editor, and allows you to build directly the file with a compiler (rather than creating a "project" for each source), simpler IMO.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
Decae

Decae

    Newbie

  • Members
  • Pip
  • 8 posts
Okay, I installed Geany and everything, but I still cannot compile/run my code. The compile button is faded out, and I can't click on it. (I saved the file first btw)

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts

Decae said:

Okay, I installed Geany and everything, but I still cannot compile/run my code. The compile button is faded out, and I can't click on it. (I saved the file first btw)

Are you sure build-essentials is installed? What are in the textboxes in build->set includes and arguments when you're in a .cpp file?

Try running this on your .cpp file as well to ensure you can compile:
g++ ./file.cpp -o ./file && ./file
I'm off to an appointment , so I may not be of help for the next while.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#5
Decae

Decae

    Newbie

  • Members
  • Pip
  • 8 posts
I'm sure build-essentials is installed and the "set includes and arguments" is also faded and cannot be selected.

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Have you tried opening a command prompt and using "g++ file.cpp" on a simple one file program?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
Decae

Decae

    Newbie

  • Members
  • Pip
  • 8 posts

WingedPanther said:

Have you tried opening a command prompt and using "g++ file.cpp" on a simple one file program?
No I haven't tried that, and I really don't know how... heh. :S

#8
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
Open up a command prompt (most likely through system->console or something, not aware of gnome's structure) and traverse to the directory where your .cpp file is, such as:
cd /home/decae/projects/foo

Then type "ls" to ensure your .cpp file is there, if it is, try running:
g++ foo.cpp -o foo

This will output an executable named "foo" in the current directory, run it in command line by typing:
./foo

This will ensure your compiler is installed and actually works.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#9
Decae

Decae

    Newbie

  • Members
  • Pip
  • 8 posts
YES, I finally got it to work, thank you very much. I thought it automatically saved to .cpp, but when I put that in, it worked just fine. To think it was that simple...

Thanks again for all your help! ;D