c++compilationlibsndfileenvironment-modules

libsnd file on hpc cluster


I have requested that we have libsnd file installed on the hpc cluster. The admin said that I can test this via the following link:

https://raw.githubusercontent.com/erikd/libsndfile/master/examples/sndfile-to-text.c

$ module load libsndfile/1.0.28 $ 
$ gcc -1/gpfs/apps/sw/libsndfile-1.0.28/include -L gpfs/apps/sw/libsndfile-1.0.28/lib, -lsndfile test.c 
$ ./a.out 

However I am not sure how to this yet!! I have a program file.cpp that uses:

#include <sndfile.hh>

I tried the following:

module load -l/gpfs1/apps/sw/libsndfile-1.0.28/include -L/gpfs1/apps/sw/libsndfile-1.0.28/lib -lsndfile file.cpp

but got the following error:

getopt.c(1087):ERROR:45: Invalid option '/'
getopt.c(1087):ERROR:45: Invalid option 'g'
getopt.c(1087):ERROR:45: Invalid option '1'
getopt.c(1087):ERROR:45: Invalid option '/'
getopt.c(1087):ERROR:45: Invalid option '/'
getopt.c(1087):ERROR:45: Invalid option 'w'
getopt.c(1087):ERROR:45: Invalid option '/'
getopt.c(1087):ERROR:45: Invalid option 'b'
getopt.c(1087):ERROR:45: Invalid option 'n'
getopt.c(1087):ERROR:45: Invalid option 'd'
getopt.c(1087):ERROR:45: Invalid option 'e'
getopt.c(1087):ERROR:45: Invalid option '-'
getopt.c(1087):ERROR:45: Invalid option '1'
getopt.c(1087):ERROR:45: Invalid option '.'
getopt.c(1087):ERROR:45: Invalid option '0'
getopt.c(1087):ERROR:45: Invalid option '.'
getopt.c(1087):ERROR:45: Invalid option '2'
getopt.c(1087):ERROR:45: Invalid option '8'
getopt.c(1087):ERROR:45: Invalid option '/'
getopt.c(1087):ERROR:45: Invalid option 'n'
cmdUlvl.c(206):ERROR:46: Undefined userlevel 'de'
getopt.c(1087):ERROR:45: Invalid option 'L'
getopt.c(1087):ERROR:45: Invalid option '/'
getopt.c(1087):ERROR:45: Invalid option 'g'
getopt.c(1087):ERROR:45: Invalid option '1'
getopt.c(1087):ERROR:45: Invalid option '/'
getopt.c(1087):ERROR:45: Invalid option '/'
getopt.c(1087):ERROR:45: Invalid option 'w'
getopt.c(1087):ERROR:45: Invalid option '/'
getopt.c(1087):ERROR:45: Invalid option 'b'
getopt.c(1087):ERROR:45: Invalid option 'n'
getopt.c(1087):ERROR:45: Invalid option 'd'
getopt.c(1087):ERROR:45: Invalid option 'e'
getopt.c(1087):ERROR:45: Invalid option '-'
getopt.c(1087):ERROR:45: Invalid option '1'
getopt.c(1087):ERROR:45: Invalid option '.'
getopt.c(1087):ERROR:45: Invalid option '0'
getopt.c(1087):ERROR:45: Invalid option '.'
getopt.c(1087):ERROR:45: Invalid option '2'
getopt.c(1087):ERROR:45: Invalid option '8'
getopt.c(1087):ERROR:45: Invalid option '/'
getopt.c(1087):ERROR:45: Invalid option 'b'
getopt.c(1087):ERROR:45: Invalid option 'n'
getopt.c(1087):ERROR:45: Invalid option 'd'
getopt.c(1087):ERROR:45: Invalid option 'e'
ModuleCmd_Load.c(204):ERROR:105: Unable to locate a modulefile for 'spectro.cpp'


Solution

  • The module commands helps to define environment variables. It cannot compile a program, so the module load command you ran ends in error as module does not understand your request.

    The libsndfile/1.0.28 modulefile should define useful variables for compilation, like LD_LIBRARY_PATH. You can check what environment variable the modulefile defines with:

    $ module display libsndfile/1.0.28
    

    If the libsndfile/1.0.28 modulefile defines environment variables to simplify compilation setup (by defining include path and library path), you may just need to type:

    $ module load 
    $ gcc -lsndfile test.c 
    $ ./a.out