How to link toolchain to qtcreator (download toolchain in linaro)

1. Download Toolchain 
https://www.linaro.org/downloads/

2. Click on Tools at the top of the Qtcreator -> build& run 

3. Set up the Cmake. (This is just a skip. I won't use it even if I set it up.)
Press "Add…" and set as below (based on default path when installing the toolchain)
Path : /usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/cmake

Qt Creator 
File 
•.7 Apply 
Edit 
Design 
ProJects 
Build 
*bug 
Analyz 
Projects 
Examples 
Tutorials 
New to Qt? 
Learn how to develop: 
own applications and 
explore Qt Creator. 
Get Started Nou 
Qt Account 
Online Community 
Blogs 
user Guide 
1001s window Help 
Options 
Filter 
Environment 
Text Editor 
FakeVim 
Help 
QtQuick 
Build & Run 
Debugger 
Designer 
Analyzer 
Version Control 
Devices 
Code Pasting 
QA Testing 
Build & Run 
General Kits 
Name 
• Auto-detected 
Qt Versions 
Compilers 
Debuggers 
Qbs 
CMake 
System CMake at /usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/cmake 
System CMake at /usr/bin/cmake (Default) 
Manual 
ü)cation 
/usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/•• 
/usr/bin/cmake 
Add 
Clone 
Remove 
Make Default 
Name: System CMake at /usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/cmake 
Path: /usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/cmake 
Autorun CMake 
Auto-create build directories 
Browse... 
X 
Cancel


4. Click Debuggers -> "Add…" and add as below
Path: /usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-gdb
Options 
Filter 
Environment 
Text Editor 
FakeVim 
Help 
QtQuick 
Build & Run 
Debugger 
Designer 
Analyzer 
Version Control 
Code Pasting 
QA Testing 
•.7 Apply 
Build & Run 
General Kits 
Name 
Qt Versions 
Compilers 
ü)cation 
/usr/bin/gdb 
Debuggers 
Qbs 
CMake 
Auto-detected 
System GDS at /usr/bin/gdb 
Manual 
New Debugger 
Add 
Clone 
Remove 
-linux/aarch64-gnu-linux-gdb 
Type 
GOB 
GOB 
Name: 
Path: 
Type: 
ABIs: 
Version: 
Wo rking directory. 
New Debugger 
-linux/aarch64-gnu-linux-gdb 
GOB 
unknown-linux-generic-elf-unknown 
7.11.1 
Browse... 
Browse... 
Cancel


5. Compiler -> "Add…" and add C++(g++) / C(gcc)
c++ compiler path : /usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-g++
c compiler path: /usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-gcc

Options 
Filter 
Environment 
Text Editor 
FakeVim 
Help 
QtQuick 
Build & Run 
Debugger 
Designer 
Analyzer 
Version Control 
Devices 
Code Pasting 
QA Testing 
•.7 Apply 
Build & Run 
General Kits 
Name 
Qt Versions 
Compilers Debuggers 
Type 
Qbs 
CMake 
GCC (C++, x86 32bit in /usr/bin) 
GCC 5 (C++, x86 64bit in /usr/bin) 
GCC 5 (C++, x86 32bit in /usr/bin) 
GCC (C, x86 64bit in /usr/bin) 
GCC (C, x86 32bit in /usr/bin) 
GCC 5 (C, x86 64bit in /usr/bin) 
GCC 5 (C, x86 32bit in /usr/bin) 
GCC (C, x86 64bit in /usr/bin) 
GCC (C, x86 32bit in /usr/bin) 
GCC 5 (C, x86 64bit in /usr/bin) 
GCC 5 (C, x86 32bit in /usr/bin) 
Manual 
Name: 
Compiler path: 
GCC 
GCC 
GCC 
GCC 
GCC 
GCC 
GCC 
GCC 
GCC 
GCC 
GCC 
Clone 
Remove 
Platform codegen flags: 
Platform linker flags: 
arm-linux-generic-elf-64bit 
-linux/aarch64-gn u-linux-gccl 
generic 
l' 
Browse... 
64bit 
X 
Cancel


6. Select Qt versions -> "Add…" and select qmake in toolcain

Options 
Filter 
Environment 
Text Editor 
FakeVim 
Help 
QtQuick 
•.7 Apply 
Build & Run 
General Kits 
Name 
Qt Versions 
Compilers Debuggers 
qmake Location 
Qbs 
CMake 
Auto-detected 
Qt5.10.o GCC 64bit 
Manual 
/opt/Qt5.10.O/5.10.0/gcc_64/bin/qmake 
Add... 
Remove 
Clean up 
QA 
Build & Run 
Debugger 
Designer 
Analyzer 
Version Control 
Devices 
Code Pasting 
Testing 
At 5.5.1in PATH 
Qt 5.9.3 in PATH (qt5) /usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/qt5/qmake 
Version name: Qt in PATH (qt5) 
qmake location: /usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/qt5/qmake 
Qt version 5.9.3 for Embedded Linux 
Browse... 
Details 
Cancel


7. Select "Kits" -> Set to the same value as below
Device type: Generic linux device
sysroot: /usr/local/oecore-x86_64/sysroots/aarch64-gnu-linux
compiler: 5.Compiler
debugger: 4.debugger
qt: 6.qmake
cmake : /usr/bin/cmake


8. Input Command in Command
$ sudo -s

modify bashrc (add command)
$ vi ~/.bashrc
.…
alias qtcreator='source /usr/local/oecore-x86_64/environment-setup-aarch64-gnu-linux;
/opt/Qt5.10.0/Tools/QtCreator/bin/qtcreator'
...

And save 
$source ~/.bashrc

9. When running Qt, you must always run qtcreator as command from the terminal to build... I don't know why.


#QT #QtCreator #Qmake #C++ #C #Linux #Embedded #Download Toolchain  #toolchain #Linaro

RAII(Resource Acquisition Is Initialization)


Resource acquisition is initialization (RAII) is a programming idiom used in several object-oriented languages to describe a particular language behavior.

RAII (Resource Acquisition Is Initialization) is one of the famous design patterns.
The technique was developed for exception-safe resource management in C++ during 198489, primarily by Bjarne Stroustrup and Andrew Koenig.

RAII patterns are important techniques for preventing leakage in languages such as C++ that require developers to directly manage resources.


The following C++11 example demonstrates usage of RAII for file access and mutex locking:

#include <fstream>
#include <iostream>
#include <mutex>
#include <stdexcept>
#include <string>
void WriteToFile(const std::string& message) {
  // |mutex| is to protect access to |file| (which is shared across threads).
  static std::mutex mutex;
// Lock |mutex| before accessing |file|.
  std::lock_guard<std::mutex> lock(mutex);
// Try to open file.
  std::ofstream file("example.txt");
  if (!file.is_open()) {
    throw std::runtime_error("unable to open file");
  }
// Write |message| to |file|.
  file << message << std::endl;
// |file| will be closed first when leaving scope (regardless of exception)
  // mutex will be unlocked second (from lock destructor) when leaving scope
  // (regardless of exception).
}



<Ref : https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization>

#RAII #Resource Acquisition Is Initialization #C++ #mutex #Memory leakage #std::auto_ptr

How to install docker in Ubuntu linux system


How to install docker in Ubuntu linux system

Install Docker
$ curl -fsSL https://get.docker.com/ | sudo sh

Install Docker Compose

Docker Compose Permission
$ sudo chmod 777 /usr/local/bin/docker-compose


Command (  ${xxxx} <- input your info )

Root permission
$ sudo usermod -aG docker <NAME>


Docker Image Command

Download Image
docker pull ${IMAGE:Version}
$ docker pull ubuntu:latest

Run Docker Image
docker run ${IMAGE:Version}
$ docker run ubuntu:latest

Build Docker Image
$ docker build

Show Downloaded Docker Image
$ docker images

Remove Docker Image
$ docker rmi ${IMAGE:Version}

Remove All Docker Image
$ docker rmi ${docker images -q}

Show Running Docker Image(Container) List
$ docker ps

Restart Docker image
$ docker restart




Container Command

Stop Running Container
docker stop ${CONTAINER ID}
$ docker stop ${CONTAINER ID}

Remove Container
$ docker rm <CONTAINER ID>

Remove All Container
$ docker rm $(docker ps -a -q)

Show Detailed Container Infomation
$ docker container inspect <CONTAINER ID>

Show Container volume
$ docker volume ls




#docker #linux docker #install docker

Signal Handling Example (linux C/C++)


Signal Handling Example (linux C/C++)

#include <iostream>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <fstream>

class TestClass{
public:
    static void handle_signal(int signal);
};
void TestClass::handle_signal(int signal) {
    //char *signalName;
    std::string signalName = "";
    sigset_t pending;
    switch(signal) {
        case SIGHUP:
            signalName = "SIGHUP";
            break;
        case SIGINT:
            signalName = "SIGINT";
            break;
        case SIGTERM:
            signalName = "SIGTERM";
            break;
        case SIGQUIT:
            signalName = "SIGQUIT";
            break;
        case SIGKILL:
            signalName = "SIGKILL";
            break;
        default:
            printf("Caught unknown signal: %d\n", signal);
            return;
    }
    //실행하고 싶은 함수        
    std::ofstream outFile("./output.txt"std::ios::app);
    printf("Linux signal occurred. signal[%d] : name[%s]\n", signal, signalName.c_str());
    std::string str(std::string("Linux signal occurred. signal[") + std::to_string(signal) + "] signal Name["std::string(signalName) + "]");
    outFile << str << std::endl;
    outFile.close();
    //exit(0);
}
int main(int argcchar* arv[]) {
    TestClass *A = new TestClass();
    struct sigaction signalhandler;
    //stack_t sigstk; //for seg.fault
    //if ((sigstk.ss_sp = (char *)//malloc(SIGSTKSZ*2))==NULL) {
    //fprintf(stderr, "can't alloc alt stack\n");
    //}
    //sigstk.ss_size = SIGSTKSZ*2;
    //sigstk.ss_flags = 0;
    //if(sigaltstack(&sigstk, (stack_t *) 0) < 0) {
    //perror("sigaltstack");
    //}
    signalhandler.sa_handler = &TestClass::handle_signal;
    sigemptyset(&signalhandler.sa_mask);
    signalhandler.sa_flags = SA_RESETHAND | SA_ONSTACK;
    sigaction(SIGSEGV, &signalhandler,NULL);
    sigaction(SIGHUP, &signalhandler,NULL);
    sigaction(SIGINT, &signalhandler,NULL);
    sigaction(SIGTERM, &signalhandler,NULL);
    sigaction(SIGQUIT, &signalhandler,NULL);
    sigaction(SIGKILL, &signalhandler,NULL);

    while(1) {
    }

    return 1;
}



#Signal #Signal Handling #Signal Handler #C #C++ #Linux #Embedded

Apartment Buying Guide 2025: Shocking Red Flags You Should NEVER Ignore!

 🏙️ Apartment Buying Guide 2025: Shocking Red Flags You Should NEVER Ignore! 🚨 Are you thinking about buying an apartment in 2025? 🏢  It’...