pure virtual function call (C/C++)

armv7 toolchain Error

error message:
pure virtual function call

solve:
1. Occurs when calling a virtual function from a constructor or destructor.
2. Compiler option did not write -march==armv7-a.

example :
arm-linux-gnueabi-g++ -fno-omit-frame-pointer -march=armv7-a -funwind-tables

#toolchain #embedded #C #C++

Terminate called out an active extension / Aborted (C/C++)


You can build it, but when you run it,
Execute and die when an error occurs.

Error Message:
Terminate called out an active extension
Aborted


Problem
Occurs when coding using "std::thread"

Cause / Solution
When coding using "std::thread", it is caused by not inserting "join"


Example Code:
class TEST {
TEST();
~TEST();

void init();
void end();
std::shared_ptr<std::thread> th = nullptr;

void exec(){}
}

void TEST::init() {
    th = std::make_shared<std::thread>(&TEST::exec , this);
}
void TEST::end() {
if(th != nullptr) {
th->join();
th = nullptr;
}
}

int main() {
Test *t = new TEST();
t->init();

if( t != nullptr ) {
delete t;
t = nullptr;
}
// If this program ends here, an error will occur.

//add code
t->end();
if( t != nullptr ) {
delete t;
t = nullptr;
}
//solved code !
}




#linux #embedded #C #C++ #debug #error #thread #join

wstring to string / string to wstring / utf16 to utf8 / utf8 to utf16(C/C++)

wstring to string / string to wstring

for utf16 parsing error


#include <locale>
#include <codecvt>
#include <string>

std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::string Str_UTF8 = converter.to_bytes(utf16String);
std::wstring wideString_UTF16 = converter.from_bytes(utf8String);

For use, you should modify the bold writing.

#utf16 #utf8 #wstring #string #C #C++ #Embedded #Linux

Function execution time Example. (C++)


std::chrono::system_clock::time_point start = std::chrono::system_clock::now();

myFunc();

std::chrono::duration<double> sec = std::chrono::system_clock::now() - start;

std::cout << "The time taken to perform the function myFunc()  : " << sec.count() << " seconds" << std::endl;


Create Thread Class Example (C++)


The class "std :: thread" exists but has been created for fun.



ThreadClass.h

#pragma once
#include <iostream>
#include <windows.h>

class ThreadClass
{
public:
ThreadClass();
~ThreadClass();

void start();
void stop();
bool isRun();

static DWORD __stdcall run_(void* p);

virtual void run() = 0;

protected:
bool threadRunFlag;
HANDLE m_Thread;
};




ThreadClass.cpp


#include "ThreadClass.h"


//
//\brief constructor,
//\param
//\return
//
ThreadClass::ThreadClass()
{
this->threadRunFlag = false;
}


//
//\brief destructor
//\param
//\return
//
ThreadClass::~ThreadClass()
{
if (this->isRun()) {
this->stop();
}
}

//
//\brief  thread start
//\param
//\return
//
void ThreadClass::start()
{
m_Thread = CreateThread(0, 0, run_, (void*)this, 0, 0);
}

///
///\brief thread end
///\param
///\return
///
void ThreadClass::stop()
{
this->threadRunFlag = false;
// to be...
}

//
//\brief thread status
//\param
//\return
//
bool ThreadClass::isRun()
{
return this->threadRunFlag;
}

//
//\brief thread run
//\param
//\return
//
DWORD __stdcall ThreadClass::run_(void * p)
{
ThreadClass* const THISCLASS = static_cast<ThreadClass*>(p);
THISCLASS->threadRunFlag = true;
THISCLASS->run();

return 0;
}

Shared folder permission setting (If you can not access the shared folder)


Problem :
I set up a shared folder in Virtualbox, but I can not access the shared folder.  

Solve :
Installing the VirtualBox Guest Additions  -> Automatically mount shared folders with VirtualBox ("/media /sh_foldername" will be shown) -> Add Ubuntu users to your vboxsf group

$ sudo -s
Input root password

$ usermod -aG vboxsf <youruser>

$ reboot

Qmake error (QT)


Error:
linux Could not determine which "make" command to run. Check the "make" step in the build configuration.

Solve :
$ sudo apt install cmake g++
$ sudo apt remove libgl1-mesa-dev
$ sudo apt install libgl1-mesa-dev

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’...