Your link order is incorrect. Link libraries after the code that requires them, not before. Like this:
gcc -o eigen eigen.c -llapack gcc -static -o eigen eigen.c -llapack
This should solve the binding problems.
To answer the following question why this works, the GNU ld documentation says the following:
It matters when you write this option in a command; the linker searches and processes libraries and object files in the order they are specified. So foo.o -lz bar.o' searches library z' after the file foo.o, but before bar.o. If bar.o refers to functions in `z ', these functions may not load.
........
Typically, files found this way are library files β archive files of which the object files are members. The compiler processes the archive file and scans through it for members that identify characters that have so far been specified but not defined. But if the found file is a regular object file, it is linked in the usual way.
That is, the linker is about to make one pass through the file looking for unresolved characters, and it follows the files in the order in which you provide them (ie, "from left to right"). If you have not yet specified the dependency when reading the file, the linker will not be able to satisfy the dependency. Each object in the list of links is analyzed only once.
Note also that GNU ld can perform reordering in cases where cyclic dependencies are detected when linking shared libraries or object files. But static libraries are only parsed for unknown characters only.
source share