Giura Gauss wrote: > > Hi, > > can anybody point me to a package with C++ code that call Fortran > subroutines? > > I am trying to do the same thing but we scarce success. > > Error in dyn.load("utils.so") : > unable to load shared library 'utils.so': > dlopen(utils.so, 6): Symbol not found: _robcovf > Referenced from: utils.so > Expected in: dynamic lookup > > >
It seems like you have a problem with function names which is a common obstacle when interfacing C and Fortran. What usually happens is that a trailing underscore gets added to fortran function names when they are compiled. For example, consider a fortran subroutine declared as: subroutine gaussQuad ( a, b, f1, f2 ) Since an underscore usually gets added and Fortran passes variables by reference, the above subroutine would be seen by C as: void gaussQuad_( a&, b&, f1&, f2& ); Furthermore, in C++ I think you h$ave to wrap the prototype in an extern statement: extern "C" { void gaussQuad_(a&, b&, f1&, f2& ); } If you are running a unix system, you can check if your fortran function names are receiving trailing underscores by running the nm utility on your shared library. Ignore the leading underscores as they are expected by the C compiler. -Charlie ----- Charlie Sharpsteen Undergraduate Environmental Resources Engineering Humboldt State University -- View this message in context: http://www.nabble.com/Calling-Fortran-from-C%2B%2B-tp23812140p23817336.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.