2

There is a LIBS environment variable for mpicxx. But the man page only says

Libraries added when invoking the linker

I wish to know detailed syntax for this variable, for example, should we prefix -L before directory, should we just write the directory name or the lib filename, should we separate multiple libraries by space or comma or something else, etc.? I tried to google the syntax but could find no information about it. So I ask here. Thanks for your help.

zzzhhh
  • 291
  • 3
  • 10
  • What version of mpi are you asking about? They are not all the same and that variable is not a standard feature of mpi – talonmies Nov 04 '21 at 03:54
  • @Nate T: Sorry I can't understand you. Specifically, I can't relate your comment to my question whatsoever. – zzzhhh Nov 04 '21 at 04:04
  • @talonmies: MPI version: 4.0.3, mpicxx version: g++ (Ubuntu 10.2.0-13ubuntu1) 10.2.0 – zzzhhh Nov 04 '21 at 04:06
  • I mean OpenMPI, mpich, some vendor specific version? – talonmies Nov 04 '21 at 04:08
  • @talonmies: the deb file is `libopenmpi-dev_4.0.3-6ubuntu2_amd64.deb`. This is all I can probe about the vendor of the mpi I use. – zzzhhh Nov 04 '21 at 04:30
  • I don't understand. You said you read the man page. It will say right on that man page what implementation you are using (I guess it is OpenMPI from the library name, but that may not contain the compiler you are actually using) – talonmies Nov 04 '21 at 08:03
  • @talonmies: I don't understand either. That's all I see in the man page. Free online image hosting sites are down one after another so I can't find a place to upload the screenshot. But I promise I'm not lying. – zzzhhh Nov 04 '21 at 09:59
  • https://pastebin.com/w41jBJxM -- this is what my man page looks like with the exact version of OpenMPI you believe you are using on the same OS you have. You can see it says OpenMPI very clearly at the top. I would also recommend testing the `--showme:incdirs` and `--showme:libdirs` options. The output will go a very long way to answering all the questions you have been posting recently about MPI and dispel a few of the misunderstandings you seem to have about what is going on in your quest to compile this CUDA MPI example you appear very interested in – talonmies Nov 05 '21 at 02:45

1 Answers1

2

I wish to know detailed syntax for this variable

The LIBS variable recognized by MPI compiler wrappers is not specific to those programs, and it does not have a syntax of its own. The variable is just expanded (unquoted) to form part of the link command line, at a position among the arguments appropriate for the designation of libraries to include in the link. The general syntax is a subset of the syntax of shell commands, and the specific significance of the contents is governed by linker.

Do note that to the extent that it matters, "the linker" is probably not ld directly, but rather (for mpicxx) a C++ compiler front-end such as g++. You specify libraries and library search path entries in the same form that you would do when linking your program with a non-MPI C++ compiler.

should we prefix -L before directory

If you want to add directories to the library search path then yes, you would use -L options.

should we just write [...] the lib filename

Most conventional would be to use -l options, so to link libfoo.so, you would use -lfoo. Alternatively, you should also be able to specify a relative or absolute path to the library file (without -l), in which case the search path is irrelevant. Specifying libraries via a specific path is normally used only for libraries built as part of the same project.

should we separate multiple libraries by space or comma or something else

You are specifying options and arguments that are expanded to be part of a shell command. Multiple arguments must be separated by whitespace.

etc.

The details all follow from the manner in which the variable is used, as already described. Some available features (but not usually anything described above) may vary from system to system, depending on the options recognized by the underlying linker.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157
  • I've tried everything I could imagine, but linker just couldn't find the mpi libraries. I tried `-L`, `-l`, `LIBRARY_PATH`, `LDFLAGS`. None of them works. – zzzhhh Nov 04 '21 at 09:31
  • 2
    I'm sorry, @zzzhhh, but I cannot speak to the specifics of how your machine is presently configured. However, I would expect that the MPI libraries themselves are one thing that you would not need to specifically ask for. I would expect `mpicxx`to know where to find them and probably to include them in the link automatically. Perhaps you have posed an XY question here. – John Bollinger Nov 04 '21 at 10:43