Topic: Linking program with several static lib's and modules

Problem while building main program and linking several libraries

The project of the program under consideration contains three libraries. All used modules are copied  to the sub-directory of the main program. Following happens while building the main program:

One library, named “structure_concept.a”, gives no trouble

A second lib, named “ASC12lib.a” contains a  procedure which is also used in
“structure_concept.a” but where not recognized. Preliminary I fixed that problem by adding the procedure to a file contained in  “structure_concept.a”

A procedure of a third lib, named “edit-sheet-library.a”, is also called  from “structure_concept.a”. Building of the main program failed by some error messages “undefined reference to …..”  as follows:
=======================================================================
Generating Makefile... Okay
=======================================================================
Generating CASTOR12lt.exe
E:\ASC_prog_files\CASTOR12\StructureConcept\structure_concept.a(dim_edit_sheet.o): In function `dim_edit_sheet_':
E:\ASC_prog_files\CASTOR12\StructureConcept/./dim_edit_sheet.f90:62: undefined reference to `edit_sheet_'
E:\ASC_prog_files\CASTOR12\StructureConcept\structure_concept.a(dim_edit_sheet.o):dim_edit_sheet.f90:(.rdata$.refptr.__edit_sheet_ctr_MOD_exitcode[.refptr.__edit_sheet_ctr_MOD_exitcode]+0x0): undefined reference to `__edit_sheet_ctr_MOD_exitcode'

…..........

collect2.exe: error: ld returned 1 exit status
Error(E42): Last command making (CASTOR12lt.exe) returned a bad status
Error(E02): Make execution terminated
Failed *

Libraries are only added to the main program, because I suppose linking of all is done while building the main program. All libraries are static. What means “shared” in the option window of the lib's?
All projects are using 64 Bit architecture
In the file option of the main program no reference is made to the libraries and other modules outside the project of the main program.
I also tried to define in "Option, file location, modules" to refer to the original modules of  the edit sheet lib
but got no other other result

Please can you give me a hint about linking an project options?

Best Regards Klaus

Re: Linking program with several static lib's and modules

Klaus,

I'll assume you're linking the libraries by including them in the Project Outline.  Is that correct?  The problem you're experiencing is because (unfortunately) the libraries must be linked in a certain order.   The most "correct" way of fixing your situation is:

1.  Rename your libraries to fit what our compiler expects with a "lib" prefix: libASC12.a and libstructure_concept.a for example.

2.  In Project Options, proceed to the File Locations tab, click the Search Directories tab, and ensure that the directory/directories where your library files with the new names exist are listed in the box.

3.  Again, in Project Options, proceed to the Compiler Flags tab and add the following flags (based on the names I suggested):

-lASC12 -lstructure_concept

Now your libraries should be linked explicitly in the correct order.  You'll also need to make sure the libraries are not explicitly included in the Project Outline.  The compiler flags are sufficient to link them properly.

It's not the simplest process, but  it is the most reliable.

Jeff Armstrong
Approximatrix, LLC

Re: Linking program with several static lib's and modules

Thanks Jeff,
Linking is ok
Klaus