Re: semi-newbie | static compilation/linking gfortran

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 20/01/16 14:26, Evan Cooch wrote:
However, my initial attempts haven't met with much success -- I suspect I'm
missing something obvious, so I'm hoping someone can point out my obvious
mistakes.

It is difficult to tell without a small self-contained testcase but...

Now,to compile a statically linked version, my attempts (so far) have basically
involved tweaking the makefile, adding -static as compiler option, and changing
all the references to *.o in the makefile to *.a. My attempt is copied@the
bottom of this note.

This should not be necessary (and I'm surprised gcc doesn't complain).

gfortran -fopenmp *.a Linpack.a -static-libgfortran -o solver.64.static
/usr/lib/../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status

which file contains the main program? is there an .o file for it? does it appear in the command-line if you compile manually?

COPTIONS =  -static -c  -fimplicit-none -fbounds-check -m64 -funroll-loops
-ftree-vectorize  -O2
     $(LINKER) -fopenmp *.a Linpack.a -static-libgfortran -o solver.64.static

-static is a linker option not a compile option. It should appear in the linker command-line.

Why not try first with? This compiles and links in one step.

gfortran -fimplicit-none -fbounds-check -m64 -funroll-loops -ftree-vectorize -O2 -fopenmp -static -static-libgfortran -o solver.64.static *.f90 *.mod Linpack.a

If you use other libraries, you need to have their .a files and gfortran needs to be able to find them.

Good luck!

Manuel.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux