I want to get from any Unix-like system (if this is possible) a unique id that will be persistent every time my application runs in the same machine. If it is possible, I wa
Sounds like you are looking for UUID. This is a common universally unique id (really, the same thing as a GUID)
There are many C++ implementations of this in diffrent libs, or you could use the uuidgen command and capture the output.
You have to consider that a lot of setups may have created a filesystem image and cloned to many machines, rather than setting them up individually. In other cases, a machine could get re-setup many times. In other words, anything the OS provided can't be trusted.
However, the CPU does keep a unique serial number, but access to it should be different on different systems.
The best way is, as usual, to see how other people already solved the same problem.
FLEXlm also uses a host identifier for its node-locked licenses. The most common host identifier it uses is the ethernet MAC address for one of your network interfaces, smashed together without any separator.
It can also use (on Windows) the volume serial number of the C: drive (again smashed together without any separators), and on Solaris the output of the hostid
command (IIRC, on Sun computers, this number is actually unique, and located on a small removable EEPROM on the system board).
While the MAC address is extremly easy to fake, it is a nearly universal identifer nowadays (almost all new computers have at least one ethernet port, and it is very common for them to be onboard), and actually intended to be globally unique (in fact, the Ethernet protocols depend on this uniqueness). The main problems you would have with this approach: