Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a problem with linking and\or running a simple program in my eclipse. I'll try to first give a full description of the setup I'm using, to help identify the problem. Please notice that this is my first experience with installing and setting up an operating system which is not Windows, though I got to use some version of Ubuntu on my campus.

I created a new Ubuntu virtual machine yesterday on VMware Player. I provided it with the path to an image file of the installation disc of Ubuntu 11.10 for 32 bit systems named "ubuntu-11.10-desktop-i386.iso".

The machine than went on to install Ubuntu 11.10 on itself. Afterwards I logged in (using the Unity-2D option) and did some basic setup:

  1. First, I chose to install all the updates offered to me automatically by Ubuntu (around 400). I let the thing download and install in the background, and when it finished, I restarted (as I was requested).

  2. Second, I ran "sudo apt-get install python-software-properties". I can't remember why, but it was probably some part of a guide of how to install Java on Ubuntu.

  3. I than tried "sudo add-apt-repository ppa:ferramroberto/java", which if I remember correctly did not work.

  4. The bash history than shows a run of "sudo apt-get update", which I remember seemed successful in installing some stuff. Again, the line originated in some tutorial or guide to installing Java on Ubuntu.

  5. I than went on to install the Java version 6 JRE using "sudo apt-get install sun-java6-jdk sun-java6-plugin". This worked and made me happy (as a latter "java -version" showed that Java was installed) - finally, the correct command was found!

  6. Than I unpacked the file "eclipse-cpp-indigo-SR2-incubation-linux-gtk.tar.gz" into my /usr/Apps folder, and than moved it to the /opt/ folder (I don't remember where it's located).

  7. Finally, I installed g++ using the command "apt-get install g++". Things looked good.

I than created a simple HelloWorld program - I created a source file named "try1.cpp" and wrote in this code:

#include <cstdio>
int main(int argc, char* argv[])
{
printf("Hello World1!/n");
return 0;
}

When I build the project using right click on the project and ->'Build Project', I get the following input:

**** Build of configuration Debug for project OS.Ex4 ****

make all 
Building file: ../try1.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"try1.d" -MT"try1.d" -o "try1.o" "../try1.cpp"
Finished building: ../try1.cpp

Building target: OS.Ex4
Invoking: GCC C++ Linker
g++  -o "OS.Ex4"  ./try1.o   
Finished building target: OS.Ex4

**** Build Finished ****

I can see that the try.o object is created in the 'debug' folder of the project, and I can also see that no binary file is created - both by the build log and the lack of it in the 'debug' folder.

That is why it is not surprising that when I try to run my project I get the next error message: "Launch failed. Binary not found."

So, what am I doing wrong? I have the g++ compiler, and it's compiling the code into object files correctly, so why no linking into a binary file is done? I have an intact main function...

I'll appreciate your help with solving this problem.

Thanks,
Shay

share|improve this question
    
Can't say I know the exact reason your build isn't behaving as expected, but I would highly recommend using the Eclipse CDT together with Eclipse's built-in Software Installer instead of the gzip archive you mention. It handles a lot of the build details automagically. –  cqcallaw May 19 '12 at 19:14
    
I don't get it. I didn't see any self-installer at the Eclipse website - at least not for Ubuntu. Anyway, the "Installing new software" feature seems like a way to install modules for Eclipse or something. How do I use it to install Eclipse? –  ShayPal5 May 21 '12 at 19:58
1  
To install Eclipse, run sudo apt-get install eclipse. Then use the Eclipse Software Installer to install the CDT. –  cqcallaw May 22 '12 at 4:05
    
That did the trick! Thanks, Caleb! You can post this as an answer. –  ShayPal5 Jun 3 '12 at 17:57

3 Answers 3

As cqcallaw recommended in his second comment, installing using sudo apt-get install eclipse instead of manually downloading and unpacking the compressed package, solved the weird behaviour eclipse exhibited.

share|improve this answer
    
Heh, sorry I didn't see your comment soon...I should check my profile more regularly. Glad things are working for you. –  cqcallaw Jul 3 '12 at 0:48
  1. apt-get update does not install things, it only updates your package index
  2. g++ -o "OS.Ex4" ./try1.o. Look in your build folder for the file OS.Ext4. To run this in eclipse, you need to set your run configuration to run this file.
  3. You should probably be using the official openjdk for java.
  4. The eclipse website does not host "installers". You just download and unpack the archive and run it from that directory.
  5. Verify that your linker is working correctly by running make manually and doing the g++ job yourself.
share|improve this answer
    
I'm not sure I'd call openjdk 'official' -- it's a bit confusing. –  belacqua Jun 20 '12 at 17:38

I see that your problem is solved, but there's another solution if others stumble upon this answer:

Don't use dots in project name; instead of OS.Ex4, use OS_Ex4 or similar. Eclipse seems to have problems with dots in project name.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.