Building a executable but shared library appear instead
I am new and not familiar with Linux OS. The current OS I use is Ubuntu 19.10.
I was trying to build a SPPARKS (a software ) executable by “make mpi”. The process got no error but a “shared library” file of spk_mpi instead of an “executable” file was produced.
I would appreciate any help from you. Thank you very much.
41 Answer
This is really the same issue as discussed in these previous questions:
and the solution is essentially as mentioned in
The challenge for your particular situation is how to pass the appropriate compiler/linker options through the MPI compiler wrappers.
On my 18.04 system, with OpenMPI version indicated by
$ mpicc --showme:version
mpicc: Open MPI 2.1.1 (Language: C)and explicitly selecting gcc/g++ version 5, I was able to get a traditional non-PIE executable using the following command line (broken up with \ line continuations for readibility):
OMPI_CC=gcc-5 OMPI_CXX=g++-5 \
OMPI_CFLAGS=-fno-pic OMPI_CXXFLAGS=-fno-pic OMPI_LDFLAGS=-no-pie \
make mpias confirmed using the file command:
$ file spk_mpi
spk_mpi: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=284d76d1ca642cca833b31dfa028a7910e935600, not strippedIf you are using some other MPI implementation, you will need to figure out how to pass the appropriate flags for that.
NB you will probably need to run make clean-all first in order to remove any objects that were previously compiled without the -fno-pic flag.