Flag Equivalencies

I’m having trouble finding the equivalent flags from gcc and pgcc,

I’m trying to build a dynamic library with PGI 10.9 on Mac OS X 10.6

The flags I would like to match are:
-dynamiclib -single_module -flat_namespace -undefined suppress

Can anyone tell me what the PGI equivalent flags are?

Page 124 of the PGI user guide says PGI supports the -dynamiclib flag, but that’s incompatible with my experience.
pgfortran-Error-Unknown switch: -dynamiclib
pgfortran-Error-Unknown switch: -single_module
pgfortran-Error-Unknown switch: -flat_namespace

Help?

Hello,

Thanks for the inquiry. All but ‘-dynamiclib’ are strictly linker switches,
and can be passed to the linker with -Wl,‘switch’. So use

-Wl,-single_module ! this is default behavior, so switch is redundant

-Wl,-flat_namespace
-Wl,-undefined_suppress


-dynamiclib works with 32-bit PGI MAC compilers only.
For 64-bit -dynamiclib, use gcc. For example
pgcc -c foo.c; gcc -dynamiclib foo.o -o mylib.dylib

regards,
dave

Thanks for the response.

I’ll try that out right away.

About the final comment, I’m not too experienced with library building, so I wasn’t sure if I could use gcc after pgcc and have everything be compatible. This clears up a lot. Thank you.

Just to confirm (sorry, I’m very new to making dynamic libs, and I have mpich configure scripts failing on me), would it be the same for the -fpic flag?

-fpic (or -Kpic, -fPIC, -KPIC) doesn’t seem to be supported on OS X 10.6 86x64.

Should I also first build an object file with pgi, then use gcc -fpic?

e.g,
Instead of:
pgcc -fPIC … -DpgiFortran -c ./dll_mpich2.c -o _sdll_mpich2.o

do,
pgcc … -c ./dll_mpich2.c -o _sdll_mpich2.o
gcc -fpic _sdll_mpich2.o