User Tools

Site Tools


getting_started:write_app:use_on_host

Writing EEROS Applications for the Host

Back to Compile on the Host.

You will use C++ to develop your EEROS applications. For this you need at least some knowledge of the basic language features. A good starting point might be https://www.cplusplus.com/doc/tutorial/. Minimal help can also be found under C++ for Beginners.

What do you want to do next?

Say Hello with EEROS

  1. Create a project directory within your EEROS project directory and change into it with
    $ mkdir hello
    $ cd hello 
  2. Create a text file “main.cpp” and copy the following code into it
    #include <iostream>
    #include <eeros/logger/Logger.hpp>
    #include <eeros/logger/StreamLogWriter.hpp>
     
    int main() {
      using namespace eeros::logger;
     
      Logger::setDefaultStreamLogger(std::cout);
      Logger log = Logger::getLogger();
     
      log.info() << "Hello, EEROS";
     
      return 0;
    }
  3. Create a text file “CMakeLists.txt” and copy the following text into it:
    cmake_minimum_required(VERSION 3.5.1)
    project(helloworld)
     
    set(CMAKE_CXX_STANDARD 14)
     
    find_package(EEROS REQUIRED)
    include_directories(${EEROS_INCLUDE_DIR})
    link_directories(${EEROS_LIB_DIR})
     
    add_executable(helloworld main.cpp)
    target_link_libraries(helloworld eeros ucl ${CMAKE_DL_LIBS})
  4. Create a build directory for your new project and change into it with
    $ mkdir ../build-x86/hello
    $ cd ../build-x86/hello
  5. Build the project with
    $ cmake -DCMAKE_INSTALL_PREFIX=../../install-x86 ../../hello
    $ make
  6. Make changes to “main.cpp”, save them and rebuild with
    $ ./make.sh

    In order to be able to write your own EEROS programs, you could use any text editor. However, we recommend to use an integrated development environment, see Use KDevelop with Existing Build Configuration.

Continue with Working on the Host.

Use Existing Project

As an example we use the Control a Single Motor demo program.

  1. Fetch the code of the application from within your EEROS directory with
    $ git clone https://github.com/eeros-project/simple-motor-control.git
  2. Create a build directory for your new project and change into it with
    $ mkdir build-x86/simple-motor-control
    $ cd build-x86/simple-motor-control
  3. Build the project with
    $ cmake -DCMAKE_INSTALL_PREFIX=../../install-x86 -DREQUIRED_EEROS_VERSION=1.2.0.0 ../../simple-motor-control
    $ make

Continue with Working on the Host.

getting_started/write_app/use_on_host.txt · Last modified: 2021/03/31 10:26 by ursgraf