Can't link libguile header with gcc in guix shell

I am following the GNU guile tutorial and trying to write a c program that links guile.
I want to compile it with gcc using guix shell. When running eg:

guix shell guile -- gcc -o simple-guile simple-guile.c \
`pkg-config --cflags --libs guile-3.0`

I get a no such file for libguile.h.

The beginning of the tutorial suggests that guile should be installed in /usr/local/ but my (mis)understanding of guix is that rather than installing in /usr/local/ it should be added gnu/store automatically (using eg guix install) and added to the include path automatically. Is this wrong?

If I check the $C_INCLUDE_PATH inside the guix shell has /gnu/store/<hash>-profile/include/ which does not have the libguile.h inside. It also has the .guix-home/profile/include which also doesn’t have the header.

Outside the guix shell, I can find the header file at:

gnu/store/<different-hash>-guile-3.0.9/include/guile/3.0/libguile.h

How do I ensure gcc can access this header within a guix shell? (short of pointing it directly at the path above, which feels like I’m doing guix wrong)

I’m not 100% sure but I think that you need to include some compiler in the guix shell command , gcc-toolchain for example. And I believe the same is true for info manuals, info-reader seems to be required.

1 Like

Thanks for the response. I asked on the #guix IRC and got things working as a result. Updating here in case it helps someone else:

The mistake in the guix shell command above is that the pkg-config call is happening outside the guix shell (of course, because in bash the `code in backticks` is executed and replaced with its result).

Instead start a guix shell with the required packages:

guix shell guile gcc-toolchain pkg-config

and then, inside the shell, call gcc with the nested call to pkg-config

gcc -o simple-guile simple-guile.c `pkg-config --cflags --libs guile-3.0`
1 Like