User forums > Using Code::Blocks

Building a Fortran project using .o module files

(1/3) > >>

COQ:
 Hi everybody,

Sorry for my english but Im french and I'm not accustomed to English writing.
I'm a new user with codeblocks. I would like to build a Fortran Project in which some of the module used are only on the form of .o module files (I don't have the source files of these modules)
My project contain several .f90 files in which the main program and subroutines are defined. I manage to compile all these Fortran files individually but when I try to build, I receive error messages indicating, for example, "undefined reference to __tpflash_MOD_tpflash_gm" refering to the instruction CALL TPflash_gm which is defined in the TPflash.o module files.
Yet the corresponding .o module files are actually present in the compilation directory.

Note that I manage to Build the project when I execute the following Dos command in which the .o modules files are listed at the end of the command :

gfortran.exe  -o bin\Debug\TEST-couple_EC2.exe obj\Debug\CALC_DIFF.o obj\Debug\CALC_THERM.o obj\Debug\INITIALISE_PROGEPI.o obj\Debug\MESH_DIFF.o obj\Debug\THERMO.o obj\Debug\VIEIL_PROGEPI.o gm.o minization_gm_lse.o minization_gm_vse.o properties.o thermodynamics.o TPflash.o TPflash_vle.o

Does anyone know how to specify that these modules files should be taken into account by Code::Block dor the Building ?

Thank by advance for your help.

COQ

gd_on:
Right click on your project name in management window. Choose build option then the tab "Linker settings". In the right part, "Other linker options" add your .o files. That should work I think, though I've never do like that.

An other way to obtain this :
in the menu Project / Add files, add simply your .o file. They should appear in "Other" and their options simply indicate linking (not compile).
An other trick with fortran module : if you have to compile them, they create a .mod file which should exist before the compilation of your main (or calling subroutine). To be sure it's the right order of compilation, in the properties of the file, simply adjust the priority to a low level.

COQ:
Dear gd_on,

Thank you very much, it now works.
I manage to Build the project but then when I try to "run" the editor explain that "you must select a host application to run a library". What should I do ?

Moreover, in the Build log file the last lines seems strange :
"collect2.exe: error: ld returned 1 exit status"
"Process terminated with status 1 (0 minute(s), 2 second(s))
0 error(s), 0 warning(s) (0 minute(s), 2 second(s))"

Is there a problem ?

Thank you by advance

COQ


COQ:
Dear,

Actually, it appears that the Build have failed ...
In the "Build messages" : "||=== Build: Debug in CODE-COUPLE (compiler: GNU Fortran Compiler) ===|
||=== Build failed: 0 error(s), 0 warning(s) (0 minute(s), 4 second(s)) ===|"

This might be due to the following error reported in  "Build Log"
"collect2.exe: error: ld returned 1 exit status"

What is the problem ?

Thank by advance for your help.

COQ

COQ:
Dear,

Actually the problem came from the fact that I both Add Files in the menu "Project / Add files" and also in the "Linker settings".
If I just specify them in the "Linker settings",

But I still have the message "you must select a host application to run a library". What should I do ?

Thank by advance for your help.

COQ

Navigation

[0] Message Index

[#] Next page

Go to full version