Search code examples
c++codenvy

Codenvy C++ Hello World program won't build?


I am starting to try and use an online IDE, so I started with Codenvy. I created a workspace and a project and I typed in the following code for a Hello World program just to test the IDE.

#include <iostream>

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

It didn't build correctly. This is what the build log says:

[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-readable POM /projects/Testing-CPP/pom.xml: /projects/Testing-CPP/pom.xml (No such file or directory) @ 
@ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project  (/projects/Testing-CPP/pom.xml) has 1 error
[ERROR]     Non-readable POM /projects/Testing-CPP/pom.xml: /projects/Testing-CPP/pom.xml (No such file or directory)
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

Can anyone point me in the right direction to getting the IDE to build and run my code?


Solution

  • It looks like you have your project setup as Java/Maven type so it's looking for a pom.xml and probably trying to run mvn clean install.

    Project typing is one of the powerful paradigms in Codenvy and Eclipse Che - it allows projects with specific "types" to assume certain behaviors and auto-setup certain things in the environment. So a Java Maven typed app knows that maven must be installed and can auto-add a build command for mvn clean install since that will work with nearly every Maven app.

    Try starting with a clean workspace based on the Codenvy C++ stack and the console-cpp-simple sample application. When you get in the workspace you'll see you have a build command that executes a gcc command.

    Then you can import your project from inside the IDE by going to Workspace > Import Project. You can then copy the build command from the sample app and (if necessary) modify it for your app. Once your app compiles you can just deleted the hello world C sample app.

    You can also select the project you have now and choose Project > Configuration but that won't necessarily add the right compile command for you.