[lustre-discuss] lustreapi not found when compiling sample C program

Apostolis Stamatis el18034 at mail.ntua.gr
Sat Jun 8 07:11:42 PDT 2024


Hello everyone,

I am trying to use the C api for lustre, using Ubuntu 22.04, kernel 
version 5.15.0-107 and lustre client modules version 2.15.4
I am building lustre from source with the following steps (removed some 
junk like git clone and cd) (mainly from the guide 
https://metebalci.com/blog/lustre-2.15.4-on-rhel-8.9-and-ubuntu-22.04/)

```
sudo apt install build-essential libtool pkg-config flex bison 
libpython3-dev libmount-dev libaio-dev libssl-dev libnl-genl-3-dev 
libkeyutils-dev libyaml-dev libreadline-dev module-assistant debhelper 
dpatch libsnmp-dev mpi-default-dev quilt swig
sh autogen.sh
./configure --disable-server
make dkms-debs
sudo dpkg -i debs/lustre-client-modules-dkms_2.15.4-1_amd64.deb
sudo apt --fix-broken install
sudo dpkg -i debs/lustre-client-utils_2.15.4-1_amd64.deb
```

The client works as expected and can mount and modify the filesystem.
However when I try to compile the sample program using gcc v 11.4.0 with 
the command
`gcc -I/usr/src/lustre-client-modules-2.15.4/lustre/include 
-I/usr/src/lustre-client-modules-2.15.4/lustre/include/uapi/ 
-I/usr/src/lustre-client-modules-2.15.4/lustre/include/lustre 
-llustreapi test_file.c -o test`
I get the error `/usr/bin/ld: cannot find -llustreapi: No such file or 
directory`

After trying to find the lustreapi library manually, indeed I can't seem 
to find it anywhere

The program I am trying to compile is

```
#include <stdio.h>
#include <lustre/lustreapi.h>

int main(int argc, char *argv[])
{
     int rc;
     rc = llapi_file_create(argv[1], 1048576, 0, 2, LOV_PATTERN_RAID0);
     if (rc < 0) {
         fprintf(stderr, " file creation failed, %s\n", strerror(-rc));
         return -1;
     }
     printf("%s created\n", argv[1]);
     return 0;
}
```

Is there a step I am missing during the making process of the client 
modules that results in the api library missing? Or is there an issue 
with the way I am trying to compile the sample program?
This is probably a silly error but I have went through all resources I 
could find (including the manual and this mailing list) and couldn't 
figure out a solution.

Will gladly provide any other information necessary.

Best Regards,
Apostolis Stamatis



More information about the lustre-discuss mailing list