Topic: Order of library search

I have noticed that the order in which libraries are listed seems to be critically important.

I am referring to when this is done by naming "libxxxxxx.a" libraries in the 'Linker' field, under Project Options>Project Flags.   
I have not investigated whether it makes any difference what order they are entered when invoked by the alternative method, of adding the "xxxxxx.a" files (the "lib..." filename prefix being permissible but unnecessary), in the Project Options panel.

The example I am using, from which I have discovered this, is as follows.

When I enter the following in the Linker field, the BUILD fails with a long list of not-found subroutines:
[ -luser32 -lgdi32 -lopengl32 -liowin -ldis  ]

When I enter the following in the Linker field, the BUILD succeeds:
[ -liowin -ldis -luser32 -lgdi32 -lopengl32  ]

I have not checked whether this behaviour is covered by the SF2.1 help files.  Someone please tell me to RTFM if necessary!
If it is not in the manual, then any guidance on how best to select the library entry sequence would be helpful.  Also, Jeff, is this behaviour as intended?

Could anyone who knows also please also tell us whether it matters in which order we add library "xxxxx.a" files to the project outline, when using this method of having SF2.1 search them.
---
John

Re: Order of library search

John,

Welcome to the wonderful world of library dependencies!  In your example, the flags have to be listed as:

-ldis -luser32 -lgdi32 -lopengl32

because DISLIN relies on Windows' user32, gdi32, and opengl32 libraries.  So the order just has to be in that order. 

Simply Fortran does not automatically determine library dependencies because it would extremely difficult the way things are set up.  GNU/Linux has a way to do it: each library can right a pkgconfig file that explains what other libraries it depends on.

When libraries are included in the project panel, they are passed to the linker in alphabetical order, but always before the library entries in the Linker Flags under Project Options.

I'm not sure the manual explicitly outlines how libraries work.  It is lacking in this respect.

Jeff Armstrong
Approximatrix, LLC

Re: Order of library search

That's weird. There are dependencies for sure, but the order they are supplied shouldn't make any difference.

The fact that your sorting them alphabetically before passing them to the linker shows that.

By the way, I "upgraded" to the 2.x licence wink . I am going to do a lot of work with Simply Fortran over the weekend.

--
David