Getting started with Linux desktop

Home / Support / Tutorials / Getting Started / Getting started with Linux desktop

Required tools and SDKs

For Linux desktop you can develop with an IDE such as Eclipse, use makefiles or use a shell script to compile your source. In this sample we use a shell script. EDGELIB requires X11 libraries which needs to be installed on the Linux desktop. For this sample we assume EDGELIB is installed on the desktop folder.

If you want to create a Linux build from a Windows desktop system, you need to use a virtual machine to emulate Linux. You can get VMWare player from www.vmware.com. Also download a Linux image from VMWare (we recommend Ubuntu).

Installation

To install the X11 libraries, open the terminal and give the following command:

apt-get install xserver-xorg-dev

Create a helloworld example

We're going to create a working sample for Linux desktop. Create helloworld.cpp and paste the following code inside the editor window:

helloworld.cpp (88 lines)
  1. /////////////////////////////////////////////////////////////////////
  2. // Code/helloworld.cpp
  3. // One of the EDGELIB tutorial samples for Linux desktop
  4. //
  5. // Copyright (c) 2017 Elements Interactive Mobile B.V.
  6. // http://www.edgelib.com
  7. //
  8. // Show "hello world" on the screen and exit by tapping the screen or
  9. // hitting a key
  10. /////////////////////////////////////////////////////////////////////
  11.  
  12.  
  13. /////////////////////////////////////////////////////////////////////
  14. // Include and link the library                                    //
  15. /////////////////////////////////////////////////////////////////////
  16.  
  17. //Include EDGELIB
  18. #include "edgemain.h"
  19.  
  20. //Link the EDGELIB static library
  21. #pragma comment(lib, "edge.lib")
  22.  
  23. //Include internal resources
  24. #include "resource.h"
  25.  
  26. /////////////////////////////////////////////////////////////////////
  27. // Class definition                                                //
  28. /////////////////////////////////////////////////////////////////////
  29.  
  30. //The main class
  31. class ClassMain : public ClassEdge
  32. {
  33.     public:
  34.         ClassMain(void);
  35.         ~ClassMain(void);
  36.         ERESULT OnDisplayConfig(EDISPLAYCONFIG *config);
  37.         ERESULT OnNextFrame(ClassEDisplay *display, unsigned long timedelta);
  38.         void OnButtonDown(unsigned long bnr, EBUTTONLIST *blist);
  39.         void OnStylusDown(POINT pnt);
  40. };
  41.  
  42.  
  43. /////////////////////////////////////////////////////////////////////
  44. // ClassMain: public                                               //
  45. /////////////////////////////////////////////////////////////////////
  46.  
  47. //ClassMain: constructor
  48. ClassMain::ClassMain(void)
  49. {
  50. }
  51.  
  52. //ClassMain: destructor
  53. ClassMain::~ClassMain(void)
  54. {
  55. }
  56.  
  57. //Configure display
  58. ERESULT ClassMain::OnDisplayConfig(EDISPLAYCONFIG *config)
  59. {
  60.     ClassEStd::StrCpy(config->caption, "Hello World!");
  61.     return(E_OK);
  62. }
  63.  
  64. //Callback: Called every frame
  65. ERESULT ClassMain::OnNextFrame(ClassEDisplay *display, unsigned long timedelta)
  66. {
  67.     display->buffer.DrawFont(0, 0, &display->fontinternal, "Hello World!");
  68.     return(E_OK);
  69. }
  70.  
  71. //Callback: Called when the user pressed a key or button
  72. void ClassMain::OnButtonDown(unsigned long bnr, EBUTTONLIST *blist)
  73. {
  74.     Quit();
  75. }
  76.  
  77. //Callback: Called when the user points the stylus down or clicks the left mouse button
  78. void ClassMain::OnStylusDown(POINT pnt)
  79. {
  80.     Quit();
  81. }
  82.  
  83.  
  84. /////////////////////////////////////////////////////////////////////
  85. // The program entry point                                         //
  86. /////////////////////////////////////////////////////////////////////
  87.  
  88. ClassEdge *EdgeMain(EDGESTARTUP *data){ return(new ClassMain); }

This sample code has been written specifically for Linux desktop. A multi-platform version can be found at the multi-platform section.

Creating a shell script

We're going to create a shell script file which compiles and helloworld.cpp source file and links it into an executable. Create a build.sh file and paste the following code:

build.sh (12 lines)
  1. echo Compiling...
  2. echo helloworld.cpp
  3. g++ -O3 -I ../../../include -D__LINUX__ -c ../code/helloworld.cpp -o helloworld.o
  4.  
  5. echo
  6.  
  7. echo Linking...
  8. g++ helloworld.o --whole-archive -ledge -ledgerender -lz -lX11 --no-whole-archive -L $HOME/Desktop/edge/lib/linux-x86 -o helloworld
  9.  
  10. echo
  11.  
  12. echo helloworld

Getting started tutorials

Latest forum posts