Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

2 votes
3 answers
482 views
Xlib. How to make XGrabButton not consume click?
First question so please forgive me if I am neglecting a requirement here. I am attempting to build a window manager for arch linux. Currently, I am adding grab events before mapping a window. I have the following: ``` XGrabButton(display, Button1, 0, window, false, ButtonPressMask, GrabModeAsync, G...
First question so please forgive me if I am neglecting a requirement here. I am attempting to build a window manager for arch linux. Currently, I am adding grab events before mapping a window. I have the following:
XGrabButton(display, Button1, 0, window, false, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None);
When Button1 is pressed I run this:
XRaiseWindow(display, frame);
The issue is now I cannot click anything in the window. Only the ButtonPressed callback function is being run. How could I go about (1) making sure the ButtonPress event is also received by the window and (2) only running the XRaiseWindow function if the window is not currently the top window (I assume stack_mode can be used here)?
Eshy (295 rep)
Sep 13, 2022, 03:58 AM • Last activity: Jan 17, 2024, 02:15 AM
2 votes
3 answers
1939 views
How to find the icon file linked to an executable?
I am building a window manager and I need to locate the icons related to a running executable for the taskbar. I found the Icon Specifications and was able to locate all the icons in `/usr/share/icons/theme_name` (I am on arch linux, if that matters). I also found the `.desktop` files (which contain...
I am building a window manager and I need to locate the icons related to a running executable for the taskbar. I found the Icon Specifications and was able to locate all the icons in /usr/share/icons/theme_name (I am on arch linux, if that matters). I also found the .desktop files (which contain the icon path and executable path) in /usr/share/applications. The issue is linking the .desktop files with running executables. I was thinking the name of the running window would match the name of the .desktop file; however, the name of the running window is more specific to the window itself. E.g. calling XGetWindowProperty on the terminal returns name as the directory the terminal is currently in, and visual studio code returns the file name, user name, and "Visual Studio Code." Is there any way to link the two. As in know which .desktop file is used by which running window. Or even directly know which icon is supposed to be used by which running window?
Eshy (295 rep)
Nov 10, 2022, 10:42 AM • Last activity: Jul 18, 2023, 02:57 PM
1 votes
1 answers
875 views
Programmatically query last DHCP lease time
I have a buildroot embedded Linux where I change the ethernet port settings (i.e. disabled, static or DHCP) from a C++ program. When switching to DHCP, it would be nice to determine when (i.e. timestamp) the device actually gets the DHCP lease. How can I determine that? Polling the current IP addres...
I have a buildroot embedded Linux where I change the ethernet port settings (i.e. disabled, static or DHCP) from a C++ program. When switching to DHCP, it would be nice to determine when (i.e. timestamp) the device actually gets the DHCP lease. How can I determine that? Polling the current IP address and waiting for a chanage is not an option.
Niko O (143 rep)
Apr 28, 2023, 06:33 AM • Last activity: May 2, 2023, 08:14 AM
9 votes
3 answers
3347 views
Box character doesn't display properly in Linux terminal
I was just writing a C++] program that uses the box characters to display information.  I ran the program on macOS and used the terminal app and it worked fine. When I switched to [Debian Linux][2] using the same code and recompiling it, I only then encountered this problem!  I'v...
I was just writing a C++] program that uses the box characters to display information.  I ran the program on macOS and used the terminal app and it worked fine. When I switched to Debian Linux using the same code and recompiling it, I only then encountered this problem!  I've searched online for answers, but I have found none related to this problem.  I've tested this with both LXTerminal and URXVT . Here is my minimal reproducible example of this problem:
#include 
#include 

int ch;

int main() {
    setlocale(LC_CTYPE, "");
    initscr();
    noecho();
    keypad(stdscr, true);
    nodelay(stdscr, true);
    curs_set(0);
    start_color();
    use_default_colors();

    init_pair(1, COLOR_BLUE, -1);

    clear();
    refresh();

    while ((ch = getch()) != 'q' && ch != 'Q') {

        attrset(COLOR_PAIR(1));

        mvprintw(0,0,"┏━┓");
        mvprintw(1,0,"┗━┛");

    }

    refresh();
    endwin();

    return 0;
}
Compile this demo with this command below:
g++ -g -c -o main.o test.cpp && g++ -g -o test main.o -std=c++11 -Wall -pedantic -lncurses
or
LDLIBS=-lncurses make test
Instead of displaying
┏━┓
┗━┛
it displays this:
M-b~T~OM-b~T~AM-b~T~S
M-b~T~WM-b~T~AM-b~T~[
### Actual screen images Normal (desired) display on macOS: Normal (desired) display on macOS Abnormal display on Linux: Abnormal display on Linux
sherbit fish (147 rep)
Mar 6, 2023, 09:43 AM • Last activity: Mar 11, 2023, 08:09 PM
1 votes
1 answers
113 views
How to use Imlib2 in a Cmake project?
I have a Cmake project on arch linux and I need to use Imlib2. However, the cmake cannot find the package (see attached screenshot). Usually, this is resolved by installing the dev version of the library, but I cannot seem to find one on arch linux. Sorry if this is stupid, but I am new to linux dev...
I have a Cmake project on arch linux and I need to use Imlib2. However, the cmake cannot find the package (see attached screenshot). Usually, this is resolved by installing the dev version of the library, but I cannot seem to find one on arch linux. Sorry if this is stupid, but I am new to linux dev. I would appreciate if someone could point me in the right direction! see screenshot
Eshy (295 rep)
Nov 8, 2022, 05:16 AM • Last activity: Nov 10, 2022, 10:27 AM
1 votes
1 answers
4575 views
GCC and Clang can't compile C++ code
Trying to run command `gcc code.cpp -o runthis` However it gives me errors in this format: /usr/bin/ld: /tmp/cco6J3Vh.o: warning: relocation against `_ZSt4cout' in read-only section `.text' /usr/bin/ld: /tmp/cco6J3Vh.o: in function `main': code.cpp:(.text+0x28): undefined reference to `std::cout' /u...
Trying to run command gcc code.cpp -o runthis However it gives me errors in this format: /usr/bin/ld: /tmp/cco6J3Vh.o: warning: relocation against _ZSt4cout' in read-only section .text' /usr/bin/ld: /tmp/cco6J3Vh.o: in function `main': code.cpp:(.text+0x28): undefined reference to `std::cout' /usr/bin/ld: code.cpp:(.text+0x30): undefined reference to `std::basic_ostream >& std::operator >(std::basic_ostream >&, char const*)' /usr/bin/ld: code.cpp:(.text+0x3e): undefined reference to `std::cin' /usr/bin/ld: code.cpp:(.text+0x46): undefined reference to `std::istream::operator>>(int&)' /usr/bin/ld: code.cpp:(.text+0x9e): undefined reference to `std::cout' /usr/bin/ld: code.cpp:(.text+0xa6): undefined reference to `std::ostream::operator >& std::operator >(std::basic_ostream >&, char const*)' /usr/bin/ld: code.cpp:(.text+0xc9): undefined reference to `std::cout' /usr/bin/ld: code.cpp:(.text+0xd1): undefined reference to `std::ostream::operator >& std::operator >(std::basic_ostream >&, char const*)' /usr/bin/ld: /tmp/cco6J3Vh.o: in function `__static_initialization_and_destruction_0(int, int)': code.cpp:(.text+0x12d): undefined reference to `std::ios_base::Init::Init()' /usr/bin/ld: code.cpp:(.text+0x148): undefined reference to `std::ios_base::Init::~Init()' /usr/bin/ld: warning: creating DT_TEXTREL in a PIE collect2: error: ld returned 1 exit status From checking it out online, it seems to be a linker issue. I'm on Arch Linux. Clang gives me the same error as gcc however I can compile using c++. Any help is appreciated
itsKia2 (13 rep)
Nov 2, 2021, 01:13 PM • Last activity: Nov 2, 2021, 01:26 PM
0 votes
2 answers
118 views
SSH session does not get terminated with cpp reboot comand
I have a small cpp application which will reboot the system. This works very well so far. sync(); //need for data safety reboot(RB_AUTOBOOT); Unless you are connected via SSH and run this program on the connected device. Then the SSH connection hangs. If you are connected via SSH and use the CLI com...
I have a small cpp application which will reboot the system. This works very well so far. sync(); //need for data safety reboot(RB_AUTOBOOT); Unless you are connected via SSH and run this program on the connected device. Then the SSH connection hangs. If you are connected via SSH and use the CLI commands sudo reboot or sudo shutdown -r now The SSH connection will be terminated with the following message Connection to xxx.xxx.xxx.xxx closed by remote host. Connection to xxx.xxx.xxx.xxx closed. How do I get the same behaviour with the cpp reboot method? I read https://man7.org/linux/man-pages/man2/reboot.2.html and search the internet, but didn't found something about this topic.
svanschu (63 rep)
Sep 1, 2021, 02:51 PM • Last activity: Sep 6, 2021, 11:42 PM
0 votes
1 answers
387 views
cmake and Installing opencv 4.x on Linux Debian 10 with Kernel 4.19.x
I am finding this info. online for building OpenCV 4.x on their homepage. I have not found a way to compile the samples or examples. Is it possible with cmake to install examples from the OpenCV 4.x build process? https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html is the link I follow...
I am finding this info. online for building OpenCV 4.x on their homepage. I have not found a way to compile the samples or examples. Is it possible with cmake to install examples from the OpenCV 4.x build process? https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html is the link I followed to install with cmake and make, and sudo make install. I got the cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local .. down pat but I am trying to configure the examples/samples. I have not been able to compile these examples or samples from the /build dir. I also tried to install and compile the Python3 libraries but the compilation only allows for Python2. Are any other people having this issue and could you please provide some feedback?
De Funct (105 rep)
Jul 9, 2020, 08:45 AM • Last activity: Oct 12, 2020, 06:15 PM
1 votes
1 answers
4970 views
Installing and compiling log4cpp on Debian
How to install log4cpp framework package stored locally as tar.gz, and which file from that package to use for bulding. I read some articles on internet, but I'm getting stucked at this part: ./configure make make check make install Can someone please explain me how to install and build app from tar...
How to install log4cpp framework package stored locally as tar.gz, and which file from that package to use for bulding. I read some articles on internet, but I'm getting stucked at this part: ./configure make make check make install Can someone please explain me how to install and build app from tar.gz? Thanks
user120425
Jun 30, 2015, 08:04 AM • Last activity: May 8, 2020, 07:55 AM
3 votes
0 answers
214 views
Preprocess the Linux source code and save to another directory
Suppose I have the entire Linux source code in `/tmp/linux-src`. After `menuconfig` I want to do "some kind of `gcc -E`" where all the preprocessor macros other than `#include` are expanded so the _actual configured preprocessed source code_ (for compilation) will be saved in `/tmp/linux-src-to-comp...
Suppose I have the entire Linux source code in /tmp/linux-src. After menuconfig I want to do "some kind of gcc -E" where all the preprocessor macros other than #include are expanded so the _actual configured preprocessed source code_ (for compilation) will be saved in /tmp/linux-src-to-compile - not in single file but rather keeping the whole tree structure leaving out the files that are not needed. Is this kind of trickery possible? Is it also possible when prepping for cross-compilation? Thanks
turbocoder (31 rep)
Dec 4, 2019, 02:05 AM • Last activity: Dec 4, 2019, 03:08 AM
2 votes
2 answers
2293 views
Error compiling source code, possibly related to cpp
I am trying to compile some source code however when I enter the "make" command in the terminal it produces an error. From my limited understanding the problem seems to arise when the code attempts to produce .f90 files from the .F files. From reading on the web it seems that problem may be somethin...
I am trying to compile some source code however when I enter the "make" command in the terminal it produces an error. From my limited understanding the problem seems to arise when the code attempts to produce .f90 files from the .F files. From reading on the web it seems that problem may be something to do with the c pre-processor. It looks like a c header is being added to the .f90 files which gfortran is then having an issue with. The output following the "make" command is as follows: make: Circular mod_prec.o mod_prec.f90 /usr/bin/gfortran-4.8 -c -I/home/dan/FVCOM3.2.2/FVCOM_source/libs/install/include mod_prec.f90 Warning: Nonexistent include directory "/home/dan/FVCOM3.2.2/FVCOM_source/libs/install/include" mod_prec.f90:1.1: /* Copyright (C) 1991-2012 Free Software Foundation, Inc. 1 Error: Invalid character in name at (1) mod_prec.f90:2.3: This file is part of the GNU C Library. 1 Error: Unclassifiable statement at (1) mod_prec.f90:4.3: The GNU C Library is free software; you can redistribute it and/or 1 Error: Unclassifiable statement at (1) mod_prec.f90:4.39: The GNU C Library is free software; you can redistribute it and/or 1 Error: Unclassifiable statement at (1) mod_prec.f90:5.3: modify it under the terms of the GNU Lesser General Public 1 Error: Unclassifiable statement at (1) mod_prec.f90:6.3: License as published by the Free Software Foundation; either 1 Error: Unclassifiable statement at (1) mod_prec.f90:6.57: License as published by the Free Software Foundation; either 1 Error: Unclassifiable statement at (1) mod_prec.f90:7.3: version 2.1 of the License, or (at your option) any later version. 1 Error: Unclassifiable statement at (1) mod_prec.f90:9.3: The GNU C Library is distributed in the hope that it will be useful, 1 Error: Unclassifiable statement at (1) mod_prec.f90:10.3: but WITHOUT ANY WARRANTY; without even the implied warranty of 1 Error: Unclassifiable statement at (1) mod_prec.f90:10.29: but WITHOUT ANY WARRANTY; without even the implied warranty of 1 Error: Unclassifiable statement at (1) mod_prec.f90:11.3: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1 Error: Unclassifiable statement at (1) mod_prec.f90:12.3: Lesser General Public License for more details. 1 Error: Unclassifiable statement at (1) mod_prec.f90:14.3: You should have received a copy of the GNU Lesser General Public 1 Error: Unclassifiable statement at (1) mod_prec.f90:15.3: License along with the GNU C Library; if not, see 1 Error: Unclassifiable statement at (1) mod_prec.f90:15.41: License along with the GNU C Library; if not, see 1 Error: Unclassifiable statement at (1) mod_prec.f90:16.4: . */ 1 Error: Invalid character in name at (1) mod_prec.f90:19.1: /* This header is separate from features.h so that the compiler can 1 Error: Invalid character in name at (1) mod_prec.f90:20.3: include it implicitly at the start of every compilation. It must 1 Error: Unclassifiable statement at (1) mod_prec.f90:21.3: not itself include or any other header that includes 1 Error: Unclassifiable statement at (1) mod_prec.f90:22.4: because the implicit include comes before any feature 1 Error: Invalid character in name at (1) mod_prec.f90:23.3: test macros that may be defined in a source file before it first 1 Error: Unclassifiable statement at (1) mod_prec.f90:24.3: explicitly includes a system header. GCC knows the name of this 1 Error: Unclassifiable statement at (1) mod_prec.f90:25.3: header in order to preinclude it. */ 1 Error: Unclassifiable statement at (1) mod_prec.f90:27.1: /* Define __STDC_IEC_559__ and other similar macros. */ 1 Error: Invalid character in name at (1) Fatal Error: Error count reached limit of 25. make: *** [mod_prec.o] Error 1 I am new to linux and I have no real knowledge of C or FORTRAN so I apologies if the question is daft. The output file (in this case mod_prec.f90) contains the following header which is the cause of the error due to the comment being in C format: /* Copyright (C) 1991-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see . */ /* This header is separate from features.h so that the compiler can include it implicitly at the start of every compilation. It must not itself include or any other header that includes because the implicit include comes before any feature test macros that may be defined in a source file before it first explicitly includes a system header. GCC knows the name of this header in order to preinclude it. */ /* Define __STDC_IEC_559__ and other similar macros. */ /* Copyright (C) 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ /* We do support the IEC 559 math functionality, real and complex. */ /* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) / Unicode 6.0. */ /* We do not support C11 . */
dan (23 rep)
Apr 22, 2015, 01:43 PM • Last activity: Jun 28, 2019, 01:26 PM
0 votes
1 answers
678 views
Getting error while making dash wallet
I just run successfully run the commands ./autogen.sh ./configure Then I get some error while running make The errors is followings Making all in src make[1]: Entering directory '/home/myname/Documents/dash-master/src' make[2]: Entering directory '/home/myname/Documents/dash-master/src' make[3]: Ent...
I just run successfully run the commands ./autogen.sh ./configure Then I get some error while running make The errors is followings Making all in src make: Entering directory '/home/myname/Documents/dash-master/src' make: Entering directory '/home/myname/Documents/dash-master/src' make: Entering directory '/home/myname/Documents/dash-master' make: Leaving directory '/home/myname/Documents/dash-master' CXX bls/libdashconsensus_la-bls.lo In file included from bls/bls.cpp:5:0: bls/bls.h:14:27: fatal error: chiabls/bls.hpp: No such file or directory compilation terminated. Makefile:9319: recipe for target 'bls/libdashconsensus_la-bls.lo' failed make: *** [bls/libdashconsensus_la-bls.lo] Error 1 make: Leaving directory '/home/myname/Documents/dash-master/src' Makefile:10949: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1 make: Leaving directory '/home/myname/Documents/dash-master/src' Makefile:688: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1 Ubuntu 16.04
salman faris (3 rep)
Jan 21, 2019, 10:19 AM • Last activity: Jan 21, 2019, 01:53 PM
0 votes
2 answers
1418 views
header not found even though `PKG_CONFIG_PATH` is set correctly
I've installed a library to `~/.local`. The environment variables are set as shown below: $ echo $LD_LIBRARY_PATH /home/saga//.local/lib $ echo $PKG_CONFIG_PATH /home/saga//.local/lib/pkgconfig There's an re2.pc file in `/home/saga//.local/lib/pkgconfig` whose contents are: prefix=/home/saga//.local...
I've installed a library to ~/.local. The environment variables are set as shown below: $ echo $LD_LIBRARY_PATH /home/saga//.local/lib $ echo $PKG_CONFIG_PATH /home/saga//.local/lib/pkgconfig There's an re2.pc file in /home/saga//.local/lib/pkgconfig whose contents are: prefix=/home/saga//.local exec_prefix=/home/saga//.local includedir=/home/saga//.local/include libdir=/home/saga//.local/lib Name: re2 Description: RE2 is a fast, safe, thread-friendly regular expression engine. Version: 0.0.0 Cflags: -std=c++11 -pthread -I${includedir} Libs: -pthread -L${libdir} -lre2 There's an re2 directory in /home/saga//.local/include which contains re2.h. But when I try to compile a program which includes re2.h, I get the following error: $ g++ tst.cpp tst.cpp:1:9: fatal error: re2/re2.h: No such file or directory #include ^~~~~~~~~~~ compilation terminated. and $ g++ tst2.cpp tst.cpp:1:9: fatal error: re2.h: No such file or directory #include ^~~~~~~ compilation terminated. The output of pkg-config --libs re2 is -L/home/saga//.local/lib -pthread -lre2 How can I fix this?
saga (1411 rep)
Nov 10, 2017, 05:31 PM • Last activity: Nov 11, 2017, 09:02 AM
1 votes
1 answers
1874 views
HDIO_GETGEO and HDIO_GET_IDENTITY in Linux using C++
Can anyone explain the core difference between `HDIO_GETGEO` and `HDIO_GET_IDENTITY`? From the Linux documentation and this document titled: [Summary of HDIO_ ioctl calls.][1], I know that the former is for "getting device geometries" and the latter for "getting IDE identification info". In the HDIO...
Can anyone explain the core difference between HDIO_GETGEO and HDIO_GET_IDENTITY? From the Linux documentation and this document titled: Summary of HDIO_ ioctl calls. , I know that the former is for "getting device geometries" and the latter for "getting IDE identification info". In the HDIO summary document, it is said that the object of "struct hd_geometry" is passed as an argument to a "ioctl" call and it will contain the "number of sectors". However, HDIO_GET_IDENTITY returns an unsigned char array. But from this SO question , I hope that struct hd_driveid contains the bytes per sector and other info. And I read somewhere that hd_driveid can be passed as an argument to ioctl if HDIO_GET_IDNTITY is used in the call. I need a clarification for all these doubts.. Also which HDIO_ ioctl call should I use to get the number of sectors and bytes per sector of my hard disk in Linux?
Jackzz (1543 rep)
Jul 2, 2015, 05:52 AM • Last activity: Jul 4, 2015, 03:21 AM
Showing page 1 of 14 total questions