building shared libraries with -mcmodel=medium

I have a collection of object files which are built with -mcmodel=medium which I want to link into a shared library. The objects are compiled as:

praesepe(152)$ pgcc -c *.c -I…/…/include/base -mcmodel=medium
eigenval.c:
errhandl.c:
factor.c:
itersolv.c:
matrix.c:
mlsolv.c:
operats.c:
precond.c:
qmatrix.c:
qvector.c:
rtc.c:

(no problem. I get the desired .o’s)

Now, I am trying to link them into a shared library:

praesepe(153)$ pgcc -mcmodel=medium -o liblaspack.so *.o
/usr/lib64/crt1.o: In function _start': (.text+0x20): undefined reference to main’

praesepe(154)$ pgcc -shared -mcmodel=medium -o liblaspack.so *.o
pgcc-Error-Switches -shared and -mcmodel=medium are not supported together

praesepe(155)$ pgcc -shared -o liblaspack.so *.o
/usr/bin/ld: errhandl.o: relocation R_X86_64_32S against `a local symbol’ can not be used when making a shared object; recompile with -fPIC
errhandl.o: could not read symbols: Bad value


What is going on?

Hello,

-mcmodel=medium and -fpic cannot be used together. They clash. To build shared library, please compile with -fPIC , without -mcmodel=medium.

Hongyon