Code::Blocks Forums
User forums => Help => Topic started by: FCM on July 03, 2010, 01:49:08 pm
-
CB_10.05 + tdm_gcc_4.5.0 (WinXP, Win7)
There are two projects in one workspace:
1) console with cpp-file containing main function
2) static lib with f90-file containing fortran function
This works properly unless in fortran function some standard fortran functions ( MATMUL, WRITE ) are used. Building of fortran static lib is still ok, but building of the workspace results in errors like "undefined reference to _gfortran_matmul_r8_".
I suppose that all refs to standard fortran functions must be resolved within fortran project, isn't that so?
There is no such problem if both projects are fortran projects.
There is no such problem under Visual Studio with mixing Visual C++ console project and Visual Fortran static lib project.
???
-
Probably you need to explicitly link to the fortran's standard libraries in your console project,
because the c/c++ don't know anything about the fortran's libs.
Also keep in mind that static libs (.a files) are just an archive with object (.o) files.
There is no linking/dependency info in them.
Visual studio handles this automatically, because it adds libraries to the linker's options behind the scenes.
C::B doesn't do it at the moment.
-
Thanks for response.
I tried to link manually some libs from mingw (containing word "fortran"), but (having no enough experience in GCC) without success.
-
I've successed after adding link to libgfortran.a in main CPP console project building options.
Previouly I tried adding this link to fortran (static lib) project building options.
But it looks amazing that this additional step is needed for MATMUL, WRITE (and perhaps some other) gfortran procedures and statements, but is not nessesary for many other gfortran procedures and statements.