Re: Linux c++ rozhodování stiskem klávesy v konzoli

Pavel Hudeček edizon na seznam.cz
Pátek Září 3 16:35:06 CEST 2021


Překlad mi skončí takhle

/usr/bin/ld: /tmp/ccIfu328.o: undefined reference to symbol '__gxx_
personality_v0@@CXXABI_1.3'

/usr/bin/ld: //lib/arm-linux-gnueabihf/libstdc++.so.6: error adding symbols:
DSO missing from command line




Jak bych to měl správně kompilovat?




PH
---------- Původní e-mail ----------
Od: Miroslav Mraz <mrazik na volny.cz>
Komu: hw-list na list.hw.cz
Datum: 3. 9. 2021 16:13:11
Předmět: Re: Linux c++ rozhodování stiskem klávesy v konzoli 
"10 minut :

#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>

class Keyboard {
struct termios initial;
public:
explicit Keyboard () {
tcgetattr(0, &initial);
struct termios my_settings;
memcpy (&my_settings, &initial, sizeof (struct termios));
my_settings.c_lflag &= ~ICANON;
my_settings.c_lflag &= ~ECHO;
my_settings.c_cc[VMIN] = 1;
my_settings.c_cc[VTIME] = 0;
tcsetattr(0, TCSANOW, &my_settings);
}
~Keyboard () {
tcsetattr(0, TCSANOW, &initial);
}
char getc () const {
char c;
ssize_t r = read (0, &c, 1);
if (r) return c;
else return '\0';
}
};

int main () {
Keyboard kbd;
for (;;) {
const char c = kbd.getc();
printf ("key \'%c\', code 0x%02X pressed\n", c, (unsigned char) c);
if (c == 'q') break;
}
return 0;
}
Mrazík

Dne 03. 09. 21 v 16:01 Pavel Hudeček napsal(a):
> Aha, no já se na to nakonec vykašlal tím způsobem, že za něco jako
> "Start the beam souce and press M to measure, or press R to repeat 
> previous, S to skip this, A to abort:"
> Dopíšu ještě
> "and press Enter"
"
------------- další část ---------------
HTML příloha byla odstraněna...
URL: <http://list.hw.cz/pipermail/hw-list/attachments/20210903/7e27cbb0/attachment.html>


Další informace o konferenci Hw-list