- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since nobody replied yet, maybe my uninformed answer is better than nothing:
For OS X, ifort has an option "ifort -staticlib" which can be used instead of the ar tool (1)
(which I only know about because I just learned about static linking on linux, so I am anything but an expert...)
Maybe this approach avoids some of the difficulties creating staic libraries with the mac OS X version of ar (2)
2) http://lists.apple.com/archives/fortran-dev/2006/May/msg00027.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using "ifort -staticlib" does fix things. Also using "ranlib -c". Another thing that fixes it is initializing the variable so changing test_mod.f90 to this works:
module test_mod
integer, save :: k2_4_row = 0
end module
So this definitely looks like a compiler bug but there are some simple fixes.
Much thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
cu_lepp wrote:
So this definitely looks like a compiler bug but there are some simple fixes.
I dont think you should blame the compiler here. The culprit is definitely your (apples) archiver, which does not include common symbols from your object files (e.g. uninitialized global variables in the modules) into the libraries table of content
Hence, in your original library, the linker cannot find the global "k2_4_row" any more. This is just apples idea about static libraries.
However, with ranlib and the -c option you can manually add all "common" symbols to the libraries TOC. Or, of course, initialize your global variable, so it appears in your object file as a symbol of type "initialized data", which now "ar" lists in the libraries TOC. Both approaches finally make "k2_4_row" accessible to the linker.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not a compiler guru so let me ask this question: Why is ifort, when it makes the .o file, marking the symbol as common? When I use gfortran it marks the symbol as "S" (when using the "nm" command) and there are no problems. When an initial value is given, ifort marks the symbol as "B" (bss section symbol). Seems to me that the symbol should not be marked differently if it is initialized and if it is not. Fortran is not C/C++ and you cannot declare a global variable in multiple places.
Note: I do think you are correct that ar should be putting common symbols in the symbol table so I'm not blameing ifort entirely.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page