Saturday 16 April 2016

Graphical C++ program in the Codenvy cloud

Graphical FLTK based C++ program in the Codenvy cloud with CMAKE

(Updated in October 2018 to reflect the changes in Codenvy and the fact that the X-Window is gone)
(Update Nov 2019 Codeenvy lives on as https://che.openshift.io )

Let's draw some Acid-Smileys on an FLTK window from a C++ program compiled with gcc using the CMake build tool.

You might want to read my earlier Blog about running a C++ Hello World with Codenvy if you are not familiar with Codenvy.



Step 1: Create the project by cloning this Git repo:

git@github.com:richardeigenmann/CppAcidSmileys.git

The code is based on sample code and a learning exercise from Bjarne Stroustrup's Programming -- Principles and Practice Using C++

Step 2: Add the build tools and libraries

The project requires some tools to be installed in the build envrionment like cmake. Go to the Terminal and type the following:

sudo add-apt-repository ppa:george-edison55/cmake-3.x
sudo apt-get update
sudo apt-get install -y cmake libfltk1.3-dev



Step 3 Compile

Go to the Terminal and runn the following:

cd /projects
cd CppAcidSmileys
mkdir build
cd build
cmake ..
make

you now have the binary ClassedAcidSmiley but when you run it, it doesn't have a DISPLAY:


Step 4 There used to be a built-in X-Desktop 

But it was removed. Also there used to be a VNC facility.
As of October 2018 I can't figure out how to bring this back.

Step 5 Copy to local

We can use our ssh trust to copy the compiled file down to our local machine:

scp -P 56219 user@node10.codenvy.io:/projects/CppAcidSmileys/build/ClassedAcidSmiley .

Of course you need to put in the correct port and node. Notice that ssh uses a lowercase -p and scp uses an uppercase -P

You can then run the file locally.

No comments:

Post a Comment