Fix “error while loading shared libraries: libalpm.so.10” on ArchLinux

Today, when I tried to use yaourt to install some software, the following error happened:

......
package-query: error while loading shared libraries: libalpm.so.10: cannot open shared object file: No such file or directory

The root cause is the libalpm in system is already libalpm.so.11:

$ ls -lt /usr/lib/libalpm.so*
lrwxrwxrwx 1 root root     17 Jun  1 00:32 /usr/lib/libalpm.so -> libalpm.so.11.0.0
lrwxrwxrwx 1 root root     17 Jun  1 00:32 /usr/lib/libalpm.so.11 -> libalpm.so.11.0.0
-rwxr-xr-x 1 root root 223616 Jun  1 00:32 /usr/lib/libalpm.so.11.0.0

But the package-query is still searching libalpm.so.10:

$ ldd /usr/bin/package-query
        linux-vdso.so.1 (0x00007fffb1d8d000)
        libcurl.so.4 => /usr/lib/libcurl.so.4 (0x00007f4baee32000)
        libyajl.so.2 => /usr/lib/libyajl.so.2 (0x00007f4baec28000)
        libalpm.so.10 => not found
        libc.so.6 => /usr/lib/libc.so.6 (0x00007f4bae86c000)
        libnghttp2.so.14 => /usr/lib/libnghttp2.so.14 (0x00007f4bae647000)
......

The solution is removing yaourt and package-query, and re-intall them:

$ sudo pacman -Rn yaourt package-query
$ sudo pacman -S fakeroot
$ git clone https://aur.archlinux.org/package-query.git
$ cd package-query
$ makepkg -si
$ git clone https://aur.archlinux.org/yaourt.git
$ cd yaourt
$ makepkg -si

That’s it!

Why do I recommend learning C++?

This post is just my ramblings about why I recommend you learn C++ even in 2018:

(1) C++ is a system programming language, and the program implemented in C++ is compiled into machine instructions. IMHO, every genuine software engineer should be acquainted with Operating System, hardware architecture, etc, and learning C++ can give you the opportunity to dive into these stuff. E.g., when you come across the “memory order”, you need to google a lot to really understand it, but it is indeed rewarding.

(2) C++ is actively evolving (C++03, C++11, C++14, C++17 …). Before C++ 11, i.e., modern C++, the main selling point of C++ is object-oriented and powerful template. But after that, C++introduces a lot features, and it becomes more and more complicated. E.g., the code may has different behaviors between C++14 and C++17 (please refer here) . Why do we bother to learn it since it is so intricate? Personally, I think it will give us a huge confidence: if you can harness C++ proficiently, is there any other language you can’t master?

(3) Because C++ is an old but popular language, there are fruitful resource which others can’t compete. From Open Source code to classical books, you can have so many references to help polishing your code skills. BTW, reading some works is a really enjoyment, not only assist you improve programming, but also teach how to write a good essay.

Hope this small article can let you take into learning C++ when you are free!

First taste of newLISP

Occasionally, I bumped into newLISP through the following twitter:

Capture

What attracted me is the newLISP‘s small size and fruitful APIs. Because I am fascinated with functional programming now, I decide to stop to peek at newLISP.

I never get my feet wet on Lisp/Scheme before, so I can’t compare the difference between them and newLISP. As an absolute novice, the key point to master newLISP I think is to be accustomed to parentheses. By default, the first element in parentheses should be a function, like this:

> (println "Hello" " World!")
Hello World!

Or this:

> (+ 4 8)
12

So if you just want a literal, remember to use ':

> '(println "Hello" " World!")
(println "Hello" " World!")

Once you remember this rule, you can understand the newLISP‘s program structure easily. Then the next thing is make your hands dirty, leverage the APIS, lego bricks provided by newLISP to practice writing small programs. For example, it cost me only a quarter to write abase64 encoder/decoder.

Happy hacking newLISP!

Add CC&CXX environment variables in your OpenBSD profile

From OpenBSD 6.2, clang has become the default compiler. So maybe you need to add CC&CXX environment variables in your personal.profile:

export CC=clang
export CXX=clang++

That’s because some software will select gcc as the compiler if you don’t specify these environment variables. The gcc is too old (4.2.1) and not maintained on OpenBSD anymore.

Beware “No such file or directory” error in using ksh

Check following simple script:

#!/usr/bbin/python
print("hello world!")

I misspelled python path intentionally. On Linux Bash, it reported following error:

$ ./hello.py
-bash: ./hello.py: /usr/bbin/python: bad interpreter: No such file or directory

It prompted me that “/usr/bbin/python” couldn’t be found. While on OpenBSD ksh:

$ ./hello.py
ksh: ./hello.py: No such file or directory

It gave an illusion that hello.py didn’t exist. So be careful about this error information if you use ksh.