linking c/c++ code against fortran libraries

Mark Moll mmoll at macports.org
Thu May 29 17:14:24 PDT 2008


There are number of ports that have variants for choosing one the  
fortran compilers: gcc42, gcc43, and g95. Suppose now that I have port  
A that includes a library libfoo.a of fortran code. I would like to  
create a port B that contains C code and depends on this library in  
port A. However, to properly link against libfoo.a I also need to  
include "-lgfortran". There are then two issues:

1. How do I determine which variant was used for port A, so that I  
know where I can find libgfortran.dylib?

2. By default, MacPorts will use /usr/bin/gcc-4.0. It sounds like a  
bad idea to mix and match compiler versions. In the case of the gcc42  
and gcc43 variants of port A, I could use the corresponding gcc  
compiler for port B. Is this acceptable? What is the right C compiler  
to link against code compiled with g95?

-- 
Mark



More information about the macports-dev mailing list