I would like to make my own program who will be work as which command in linux. Original which command works that (example for pwd): $ which pwd /bin/pwd but my program works that: $ ./prog1 pwd /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games pwd Can You correct my program? Source code: Answer You find the candidate directory using strsep, storing it in path. But then
Tag: c++
How to get name (path) of uinput created device
I have successfully set up a small program to create a uinput device which I plan to use to automate testing of an application receiving keyboard input events. I have followed both tutorials as found in this very nice answer. When my program creates the uinput device by calling ioctl(fd, UI_DEV_CREATE) a new device appears in the file system so
Cmake Error: The following variables are used in the project, but they are set to NOTFOUND trying to compile Rigs of Rods in archlinux
I’ve been trying to compile Rigs of Rods under archlinux with 4.2.6 Kernel. I’ve followed the official compiling instructions presented in http://www.rigsofrods.com/wiki/pages/Compiling_Sources_under_Linux I have succesfully compiled ogredeps and CMake gave me no error, I even enabled multithreading for it (while using make, after running CMake .), but when I try to compile Ogre (Mentioned under the “Ogre Itself” section in
Linux Qt QSystemTrayIcon in console application
I have a working qt application. It is not a MainWindow application and has no GUI elements at all so far. It runs on startup of the linux box (as a background service). However, it has to wait for ~40-60 seconds until it can start while the IP/DHCP sorts its self out. So I wanted to give the user some
/usr/bin/ld cannot find -l
I have written a few programs and while trying to compile them using g++,as thus, I keep getting the following error: fwlib32.h is the library I am trying to include. The shared object file libfwlib32.so is present in /usr/local/lib as well as /usr/lib. But I am unable link to it. I have tried all the solutions offered by similar questions
Linking error “undefined reference” about boost static library during compiling
I am trying to compile my C++ project on Linux x64 with boost libraries 1.57. This project is compiled with scons and I successfully compiled it on my Arch Linux, but this time failed on a Ubuntu machine. I added -lboost_coroutine flag for linking but the error “undefined reference” still existed. I noticed that the attributes.hpp is exactly one of
Recreate and send packet captured by nfqueue
I capture all the packets in one side with help of nfqueue, “record” them (all the data: ip info, next protocol info etc) with nfq_get_payload and deliver them into another side with help of udp. How can I restore this packet on another side and then send to myself(2 side) like there is no udp-encapsulation between? Should I use some
Speeding up gcc compile of a single file
Running RedHat7 w/g++ version 4.8.3 w/j5 arg and o3 optimization. We currently have a file that is approx 90,000 lines long (a whole bunch of wrapper functions). The compile of this file currently takes between 30 and 40 mins. What is the best strategy to speed this build time? Would build time increase if it was split between multiple files?
MinGW DLL project compatability with linux
I’ve recently created a DLL project using the MinGW (4.8.1) compiler through the CodeBlocks IDE, and in the debugging output folder I have: my “.dll” (“AttribRdr.dll” in this case) file with an Export Definition File and finally a “.a” file (“libAttribRdr.a” in this case). According to my knowledge, the programs built for Linux/Unix based operating systems use libraries in the
c program works on windows take segmantation fault on linux
I wrote some c code on codeblocks. It works perfectly fine on Windows but gave segmantation fault on Linux. Why ? This is main. I used 3 libraries and opencells method calls a recursive method. Answer Change: (int) to (int*) Because sizeof(int) and sizeof(int*) maybe different, so your program maybe crashed when access the not allocated memory.