The correct way to 'build' github packages
Posted: Thu Jun 25, 2020 10:19 pm
You can consider me a Linux newbie here. I use Manjaro Linux, and `uname -r` gives me `5.4.44-1-MANJARO`
To install new packages, I use `pacman`, and it's extremely hassle-free and seems well abstracted, and almost seems like using `setup.exe` in windows. So far so good.
However, I've come to realize that 'the best way (often)' to install packages is via compilation from source, where the source is present in someplace like github.
In my case, I wanted to install `libcpuid` from source. A search gives me two links: https://github.com/anrieff/libcpuid and http://libcpuid.sourceforge.net/index.html.
I follow the instructions on the repo:
This is successful, but I still can't use the headers and the library. So I try `make install`. This installs the library (both libcpuid.so and libcpuid.a) in `/usr/local/lib` and also installs the headers in `/usr/local/include/libcpuid`. I've read that `/usr/local` is the default PREFIX for packages that are built and installed from source... So far so good.
I want to try out a simple program: http://libcpuid.sourceforge.net/documentation.html. I compile as they suggest: `gcc -o example example.c $(pkg-config libcpuid --cflags --libs)`. This gives me my first error:
I find a `libcpuid.pc` in the source directory (I'm sure this isn't the 'right' way at all - Adding the git cloned directory to the environment variable? I don't think so) and add the source directory to PKG_CONFIG_PATH, and compile again. It compiles (`pkg-config libcpuid --cflags --libs` gives me `-I/usr/local/include/libcpuid -L/usr/local/lib -lcpuid`)
, but when I execute, I get this error:
I'm not sure how to proceed. I am also sure that compilation from source isn't meant to be this difficult, and perhaps I'm complicating things too much. What is the right way to compile packages from source? Moreover, Why is it right that the final compilation commands looks like `gcc -o example example.c -I/usr/local/include/libcpuid -L/usr/local/lib -lcpuid`? I thought that since we install the header and library in a standard system library, we don't need to specify the full path of the header?
To install new packages, I use `pacman`, and it's extremely hassle-free and seems well abstracted, and almost seems like using `setup.exe` in windows. So far so good.
However, I've come to realize that 'the best way (often)' to install packages is via compilation from source, where the source is present in someplace like github.
In my case, I wanted to install `libcpuid` from source. A search gives me two links: https://github.com/anrieff/libcpuid and http://libcpuid.sourceforge.net/index.html.
I follow the instructions on the repo:
Code: Select all
libtoolize
autoreconf --install
./configure
make
I want to try out a simple program: http://libcpuid.sourceforge.net/documentation.html. I compile as they suggest: `gcc -o example example.c $(pkg-config libcpuid --cflags --libs)`. This gives me my first error:
Code: Select all
Package libcpuid was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcpuid.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libcpuid', required by 'virtual:world', not found
, but when I execute, I get this error:
Code: Select all
error while loading shared libraries: libcpuid.so.15: cannot open shared object file: No such file or directory