When do I need the headers for lib files?
You need them during compilation if you build against libraries. You don’t need them for the execution afterwards.
Why is ‘int std::system(const char * command)’ so slow?
It first opens the command-line interpreter of the system (e.g. cmd.exe, /bin/sh) and then let’s it execute the command.
For linux it first calls “fork();” and then “execl(‘/bin/sh’, ‘sh’, ‘-c’, <command>, (char *) NULL);”.
Example:
Variant | Instruction | Performance |
---|---|---|
Via bash | std::system(‘mount /dev/sdb1 /mnt/usbdrive’); | slow |
Via glibc | mount(‘/dev/sdb1’, ‘/mnt/usbdrive’, ”, 0, ”); | fast |