Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make: linking openblas fails on standard linux setup #1

Open
ahbarnett opened this issue Feb 9, 2024 · 0 comments
Open

make: linking openblas fails on standard linux setup #1

ahbarnett opened this issue Feb 9, 2024 · 0 comments

Comments

@ahbarnett
Copy link

make fails at link stage on standard linux machine:
ubuntu 22.04 on amd64.
GNU Fortran (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
libopenblas-base:amd64 0.3.20+ds-1

Error:

gfortran -g -w -fdefault-integer-8 -finteger-4-integer-8 -std=legacy -o int2 -lopenblas examples/test_surfsmooth.o src/koornexps.o src/ortho2eva.o src/ortho2eva_new.o src/ortho2exps.o src/orthom.o src/cisurf_loadmsh.o src/cisurf_skeleton.o src/cisurf_plottools.o src/cisurf_tritools.o src/lapack_wrap.o src/pplot2.o lib/tfmm3dlr/tfmm3dlr_expout.o lib/tfmm3dlr/tfmm3dlrwrap_expout.o lib/tfmm3dlr/l3dzero.o lib/tfmm3dlr/treeplot.o lib/tfmm3dlr/prini.o lib/tfmm3dlr/l3dterms.o lib/tfmm3dlr/laprouts3d.o lib/tfmm3dlr/nearfield.o lib/tfmm3dlr/l3dmpmpfinal4.o lib/tfmm3dlr/l3dloclocfinal4.o lib/tfmm3dlr/l3dmplocfinal4.o lib/tfmm3dlr/prinm.o lib/tfmm3dlr/yrecursion.o lib/tfmm3dlr/ftophys.o lib/tfmm3dlr/phystof2.o lib/tfmm3dlr/legeexps.o lib/tfmm3dlr/tree_lr_3d.o lib/tfmm3dlr/rotgen.o lib/tfmm3dlr/numthetafour.o lib/tfmm3dlr/numthetahalf2.o lib/tfmm3dlr/lapweights.o lib/tfmm3dlr/pwrouts2.o lib/tfmm3dlr/hkrand.o lib/tfmm3dlr/dlaran.o lib/tfmm3dlr/rotviarecur3.o lib/tfmm3dlr/rotgen2.o lib/tfmm3dlr/l3dgqbxauxrouts2.o lib/tfmm3dlr/lwtsexp_sep2.o lib/tfmm3dlr/chebexps.o src/Mod_TreeLRD.o src/ModType_Smooth_Surface.o src/Mod_Fast_Sigma.o src/chebtarggridrouts.o src/Mod_Plot_Tools_sigma.o src/Mod_Feval.o src/Mod_Smooth_Surface.o
/bin/ld: src/cisurf_tritools.o: in function `fast_matvec_':
/home/alex/numerics/smooth-surface/src/cisurf_tritools.f90:458: undefined reference to `dgemv_'
ETC...

Cuprit is the link order:

$(FLINK) $(OBJECTS) $(MOD_OBJECTS)

Since -lopenblas is part of FLINK it appears before the object files. But the correct link order is at the end, since it is a dependency of the object files.

Moving -lopenblas to the end fixes it.

Here's a URL on link order:
https://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking

Take-home message:
If object or library AA needs a symbol from library BB, then AA should come before library BB in the command-line invocation of the linker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant