cannot build a static library

Hi all,

this might be a trivial question but …

I’ve got several fortran files that I used to link into a static library with an other compiler.

With pgf90 when I try to link these objects into a lib.a file I always have this error message :
/usr/local/pgi/linux86-64/6.1/lib/f90main.o: In function main': f90main.c:(.text+0x42): undefined reference to MAIN_’

I tried to pass -Mnomain but I stil have an error message :
/usr/lib64/crt1.o: In function _start': ../sysdeps/x86_64/elf/start.S:109: undefined reference to main’

I succeeded in building a shared library using -fPIC during compilation and -shared during linking, but I need a static one.

There’s certainly a switch I’m missing … any ideas?


Hi Will,

To build static libraries, use the “ar” utility. For example:

% pgf90 -c [optimization flags] -o foo.o foo.c
% pgf90 -c [optimization flags] -o bar.o bar.c
% ar rcu libmylib.a foo.o bar.o

Hope this helps,

it helps!

thanks a lot.