Let us begin.

Copy 'my' c++ code and save it to a text file, say liblogin0.cpp. The code is pasted here:
Once that you have the c++ file, open a terminal and issue the commands:
- Code: Select all
g++ -c -fPIC login0.cpp -o library.o
This creates an object file which contains the compiled functions but not in the format of an exporting library.
To create the library, issue this command:
- Code: Select all
g++ -shared -o liblogin.so library.o
If you belong to the curious type, and want to have a glimpse at what functions we are exporting, issue this command:
- Code: Select all
nm -C liblogin.so | grep " T "
Now, as root copy the freshly compiled library to the directory: /lib/x86_64-linux-gnu
- Code: Select all
cp -n liblogin.so /lib/x86_64-linux-gnu
If you have a different architecture, you will need to search where libsystemd-login0.so is in your directory tree.
Change directory to x86_64-linux-gnu:
- Code: Select all
cd /lib/x86_64-linux-gnu
Search for:
- Code: Select all
lrwxrwxrwx 1 root root 25 Oct 9 2013 libsystemd-login.so.0 -> libsystemd-login.so.0.2.1
-rw-r--r-- 1 root root 43496 Oct 9 2013 libsystemd-login.so.0.2.1
Rename these two files so that the system does not find them. You can delete them but be warned that you will be deleting two system files. Reinstalling libsystemd-login0 restores them.
The renaming:
- Code: Select all
mv libsystemd-login.so.0 disable_libsystemd-login0.so.0
mv libsystemd-login.so.0.2.1 disable_libsystemd-login0.so.0.2.1
The actual installation of the library besides copying it.
- Code: Select all
ln --symbolic liblogin.so libsystemd-login.so.0
ln --symbolic liblogin.so libsystemd-login0.so.0.2.1
List the files for a final scrutiny. You should have two symbolic links pointing to liblogin.so and the names of the links must be the original names of the two renamed files, otherwise the the system wouldn't be able to find them.
Hopefully, this helps those who want to try the library although it is not much.
Thanks.