Author Topic: How to define sequence of object files for linker?  (Read 2707 times)

Offline BDick

  • Single posting newcomer
  • *
  • Posts: 7
How to define sequence of object files for linker?
« on: August 16, 2020, 10:44:43 pm »
I am trying to bring a FORTRAN project with ca. 350 source files into C::B (the Fortran version for Linux). All files compile correcty with GNU Fortran, but the link step generates a lot of "missing symbol" messages. However, if I give the link command directly from the shell, with a different sequence of object files, the link step finished correctly. It seems that a certain group of 5 object files must be at the beginning of the list. (It sounds strange, a good linker should not behave like that, but this is it: the result depends on whether the 5 object files are at the beginning or not.)

I noticed that the sequence in which the object files are listed in the linker command seems to be random. At least it is not in alphabetical order (in which case I could rename the files to bring the 5 in front). Is there any way to control this sequence?

thanks for any help,
best regards,
Bernhard


Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: How to define sequence of object files for linker?
« Reply #1 on: August 16, 2020, 10:51:41 pm »
You can change linking order in Build options -> Linker settings, the top one will be the first.

Offline gd_on

  • Lives here!
  • ****
  • Posts: 796
Re: How to define sequence of object files for linker?
« Reply #2 on: August 16, 2020, 11:24:10 pm »
You can play with compilation priorities. This is a good solution especially with fortran sources if some of your sources contains modules which must be compiled first.
In the project view, right click on a source file. In Properties... choose the second tab ("Build"), and at the bottom you have a slider to choose the priority : 50 is the standard one. A lower value gives it a higher priority. There, you can tune very precisely the order of compilations.
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.4 (tests with 3.3), Msys2 Compilers 13.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline BDick

  • Single posting newcomer
  • *
  • Posts: 7
Re: How to define sequence of object files for linker?
« Reply #3 on: August 17, 2020, 09:35:19 pm »
response to gd_on:

this is not what I want. I want to re-order the sequence of object files for the linker. Changing compile priorities has no effect on this list. This ordering seems to be completely random.

response to Miguel:
do you mean Project -> Build Options -> Linker settings? The left box allows only for libraries, entries in the right box are APPENDED to the link command.
So please what do you mean by "the top one"?

best regards,
Bernhard

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: How to define sequence of object files for linker?
« Reply #4 on: August 17, 2020, 10:12:17 pm »
The left box has two arrows, just select one library and click on the arrows to move it up or down. They will be linked from top to bottom.