* linking C++ code against library from fortran sources
@ 2001-12-08 17:27 Hans Horn
2001-12-08 18:35 ` Danny Smith
0 siblings, 1 reply; 2+ messages in thread
From: Hans Horn @ 2001-12-08 17:27 UTC (permalink / raw)
To: cygwin
Hi everybody,
I have a bunch of old numerical fortran77 sources, which I compiled with g77
and archived into, say libMyF77.a.
I want those f77 functions to be called from w/i a c++ program.
Here are my two questions:
1. to satisfy the compiler, I have to declare the functions used as
'extern'. Which language string should I be using?
"FORTRAN" as language string (as I had used on other platforms, such as AIX)
is not recognized by gcc/g++
gcc/g++ accepts only either "C" or nothing (or ????). Which is the right
one here?
2. the linker complains about the functions used as undefined references. I
think I've told the linker properly, where to look for archives (-L<path to
libMyF77.a> -lMyF77). What am I doing wrong? Do I have to do something
special when archiving? Do I have to raise another magic flag for the
linker????
Any light shed onto the subject is severely appreciated!
Hans
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: linking C++ code against library from fortran sources
2001-12-08 17:27 linking C++ code against library from fortran sources Hans Horn
@ 2001-12-08 18:35 ` Danny Smith
0 siblings, 0 replies; 2+ messages in thread
From: Danny Smith @ 2001-12-08 18:35 UTC (permalink / raw)
To: Hans Horn, cygwin
--- Hans Horn <hannes@2horns.com> wrote: > Hi everybody,
>
> I have a bunch of old numerical fortran77 sources, which I compiled with
> g77
> and archived into, say libMyF77.a.
>
> I want those f77 functions to be called from w/i a c++ program.
>
> Here are my two questions:
>
> 1. to satisfy the compiler, I have to declare the functions used as
> 'extern'. Which language string should I be using?
> "FORTRAN" as language string (as I had used on other platforms, such as
> AIX)
> is not recognized by gcc/g++
> gcc/g++ accepts only either "C" or nothing (or ????). Which is the right
> one here?
>
As you say, extern "FORTRAN" doesn't work. It should be extern "C". Note
that g77 uses C calling convention (__cdecl) by default for Fortran. Other
compilers use PASCAL (__stdcall)
2. the linker complains about the functions used as undefined references.
> I
> think I've told the linker properly, where to look for archives (-L<path
> to
> libMyF77.a> -lMyF77). What am I doing wrong? Do I have to do something
> special when archiving? Do I have to raise another magic flag for the
> linker????
>
By default, g77 appends an underscore to Fortan names, so you will need to
do same in your C/C++ code. If you can rebuild the libs, you may add
-fno-underscore option to override this decoration.
Have a look at either the netlib Lapack++ package (C++ wrappers for Fortran
blas and lapack) or Roldan Pozo's TNT package (a start a templated version
of Lapack++) here:
http://math.nist.gov/tnt/index.html
Danny
> Any light shed onto the subject is severely appreciated!
> Hans
>
>
> --
> Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting: http://cygwin.com/bugs.html
> Documentation: http://cygwin.com/docs.html
> FAQ: http://cygwin.com/faq/
>
http://shopping.yahoo.com.au - Yahoo! Shopping
- Free CDs for thousands of Priority Shoppers!
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-12-09 2:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-08 17:27 linking C++ code against library from fortran sources Hans Horn
2001-12-08 18:35 ` Danny Smith
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).