I have a code that uses std=c++20. I want to use a C library that was build with old gcc version. Should I recompile the C library using the same compiler ? If no, how could you judge that the 2 ABIs are compatible? Answer There should be no problem using the library as it is. Don’t forget to add
Tag: c++
Protecting against Time-of-check to time-of-use?
I was reading: https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use They showed this code to be buggy and I totally understand why it’s so: But the real question is how to protect against this type of exploits? Answer You can use the O_NOFOLLOW flag. It will cause the open to fail if basename of the path is a symbolic link. That would solve the described attack.
Cannot compile Makefile using make command on Windows
Problem summary I am trying to install an open-source parallel finite-element code called TACS and available at this github repository. To comply with the indicated prerequisites, I followed the instructions at this github repository, which allowed me to install SuiteSparse and METIS on Windows with precompiled BLAS/LAPACK DLLs. For the MPI, I installed both the Intel MPI Library and Open
C++: How to cross-compile from Windows to Linux?
I have a C++ module on windows which I want to compile such that I get a dynamic library for linux *.so. Does a cross-compiler exist that can help me out? Answer Several comments mentioned using Windows Subsystem for Linux. I would personally recommend this as it is far easier than trying to use a cross-compiler. It also comes with
“/usr/bin/ld: cannot find -llibopencv_calib3d” when compiling an opencv project in Ubuntu 20.04
I have installed opencv in Ubuntu 20.04 following the instructions in OpenCV Installation in Linux. As per the instructions, sudo make install copies all the .so files to /usr/local/lib. However, when compiling a program, using the command g++ –std c++17 -g opencv/Basic.cpp -o output -I/usr/local/include/opencv4 -L/usr/local/lib/ -llibopencv_calib3d -llibopencv_core -llibopencv_dnn -llibopencv_features2d -llibopencv_flann -llibopencv_highgui -llibopencv_imgcodecs -llibopencv_imgproc -llibopencv_ml -llibopencv_objdetect -llibopencv_photo -llibopencv_stitching -llibopencv_video -llibopencv_videoio
Question about using #define value in if condition and code generation: debug vs release build
Question is related to release and debug build. Something related to this and this But I have a simple doubt for example if I do following: (file is debug-test.c) So my doubt/question is if I do #define debug 0 will compiler eliminate/optimize out all the code (that if condition) from final binary? Or code will remain in final binary as
Wayland client get compositor name
Is it possible for a c application using libwayland-client.so to get the name of the compositor / display server it opened a connection to (e.g. KWin, Sway, …)? I fail to find it in the docs. For reference, in X11 this is possible using XProps specified by EWMH: _NET_SUPPORTING_WM_CHECK to get the window id of the window manager and then
gnu ld treating assembly output as linker script, how to fix? or am i doing something wrong in my compiling?
i’ve been working on my kernel project and to simulate it (that is to run it on QEMU), i need it as a .iso file. I have an assembly file and to assemble it – as –32 boot.s -o boot.o and for the main code (which is in c++), to compile it – gcc -S kernel.cpp -lstdc++ -o kernel.o gives
Check for specific command line arguments and then assign them to variables
Obligatory total noob here. I am making a simple C program that reads some variables from a file from a simple function. What I’m trying to accomplish, however, is to allow whoever calls the program to override the values read from the file if hey so specify in the command line arguments. I would like to have something like this:
Trying to build C++ exe that uses .so that uses other .so files
I’m trying to build a C++ executable that links with a shared library, libA.so. libA.so was built and linked with another shared library, libB.so. libB.so was built using -rpath to look for a custom build of a system library in my home directory (liblapack.so). If I do a “readelf -d” on libB.so, I see liblapack.so as “NEEDED”, and I also