When trying to link my application using the mpicc wrapper of Intel MPI 2018.4, it prepends several paths to my LIBRARY_PATH. I set this variable to use a custom library instead of the one installed on my system. However, since the path of the system's library is also pre-pended my program is silently linked against the wrong library. There is nothing I can do about this but specifying the library path explicitly via an -L option during linking, but I don't want to do this!
In my opinion, all wrapper scripts should only POST-pend their paths to the environment variables! The user-specified paths must always win!
mpicc and other wrapper scripts are used to build MPI applications with the particular installation of Intel MPI Library. We do not add any extra paths (not related to the Intel MPI installation).
mpicc uses the installed gcc. Could it be that your request is related to the libraries which are linked by gcc by default? Then I assume there is no other solution as to overwrite the default with an explicit -L flag.
Please find attached a small test script plus the output on my test system.
It turned out that my custom gcc installation prepends the LIBRARY_PATH. I didn't realize that the -v option is also forwarded to the compiler such that the screen output was not due to mpicc but gcc, so I blamed Intel MPI for this. However, having the compiler prepending my path is even worse.
I think I have to address this problem somewhere else, but probably somebody else here has an idea how to solve it.