calling NAG from C

G

Gunasekaran

Dear all,

I wrote a c program and tried to call NAG(desinged for FORTRAN)subroutine.

I called as NAG as below

d02bhf_( &x, &xend, &knor , y, &tol,&irelab, &hmax, &fcn, &g, w, &ifail);

but I am not able to compile.

Compiler gives the following error message
undefined to `__ctype_b'
/usr/local/FFC/lib/libfj9i6.so: undefined reference to `__ctype_tolower'

Please suggest me a solution.

With Kind Regards
Barani Gunasekaran
 
M

Mark A. Odell

(e-mail address removed) (Gunasekaran) wrote in

I wrote a c program and tried to call NAG(desinged for
FORTRAN)subroutine.

I called as NAG as below

d02bhf_( &x, &xend, &knor , y, &tol,&irelab, &hmax, &fcn, &g, w,
&ifail);

but I am not able to compile.

Compiler gives the following error message
undefined to `__ctype_b'
/usr/local/FFC/lib/libfj9i6.so: undefined reference to `__ctype_tolower'

Since C doesn't specify how to interface with other languages, how are we
supposed to answer this question while remaining on-topic?
 
E

E. Robert Tisdale

Gunasekaran said:
I wrote a C program and tried to call NAG(designed for FORTRAN)subroutine.

I called as NAG as below

d02bhf_( &x, &xend, &knor , y, &tol,&irelab, &hmax, &fcn, &g, w, &ifail);

but I am not able to compile.

Compiler gives the following error message
undefined reference to `__ctype_b'
/usr/local/FFC/lib/libfj9i6.so: undefined reference to `__ctype_tolower'

Your *link editor* couldn't find these two library functions.
You need to find the library that includes these two functions
and include the path to the library as well as the command line option
that will link in the library.

Try asking this question in the comp.lang.fortran newsgroup
and/or a newsgroup for your specific C compiler.
 
D

Derk Gwen

(e-mail address removed) (Gunasekaran) wrote:
# Dear all,
#
# I wrote a c program and tried to call NAG(desinged for FORTRAN)subroutine.
#
# I called as NAG as below
#
# d02bhf_( &x, &xend, &knor , y, &tol,&irelab, &hmax, &fcn, &g, w, &ifail);
#
# but I am not able to compile.
#
# Compiler gives the following error message
# undefined to `__ctype_b'
# /usr/local/FFC/lib/libfj9i6.so: undefined reference to `__ctype_tolower'

<ctype.h> can be macros or functions. Apparently the library expects the function
entry points but for some reason can't find them in libc. You should probably check
the libraries and entry point names. You might have to link libc before this other
library.
 
D

Dave Thompson

(e-mail address removed) (Gunasekaran) wrote:
# Dear all,
#
# I wrote a c program and tried to call NAG(desinged for FORTRAN)subroutine.
# Compiler gives the following error message
# undefined to `__ctype_b'
# /usr/local/FFC/lib/libfj9i6.so: undefined reference to `__ctype_tolower'
This is almost certainly from the linker, not the compiler; you may
not be aware of it because many (most?) compilers will run the linker
automatically for you, often by default. But in a mixed-language
situation you may need to override this behavior -- in particular, you
may need to use the C compiler to just compile (often specified by a
command line flag, conventionally -c) and then the Fortran compiler to
drive the linking.
<ctype.h> can be macros or functions. Apparently the library expects the function
entry points but for some reason can't find them in libc. You should probably check
the libraries and entry point names.

Or macros using 'hidden' data, which looks to be the case here.
You might have to link libc before this other library.

That's unlikely to help; the most common linker behavior is to search
a library only for currently unresolved symbols, so you need to
specify a library that provides a symbol *after* whatever uses it.
But the linking done automatically by the C compiler almost certainly
specifies the C library (maybe libc, maybe something else) last, so
this would not be the problem.

I suspect a more likely problem is a mismatch between the C compiler
and/or library the OP is using and that expected by the library s/he
has. Many implementations have different "modes" of various kinds --
static vs dynamic linking, threaded vs not, different memory models --
and on many platforms there are multiple C implementations (compilers
and/or libraries) available, which are not necessarily compatible with
each other. In general, whatever compiler and options were used to
compile the library, you should if possible use the same for your code
and not assume that anything else will work.

To the OP: I suggest, if the appropriate restrictions aren't obvious
in your (NAG) library, like a README or such, or on the source you got
it from, you take this to comp.lang.fortran, and tell them what NAG
you are using (or where you got it) and what C you are using with it
and with what options. The folks there are much more familiar with,
and tolerant of, C/Fortran interfacing issues, and system specifics.
Although they will probably chide you for not just using Fortran -- if
you have a good reason, state it up front to save time.

- David.Thompson1 at worldnet.att.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,078
Messages
2,570,572
Members
47,204
Latest member
MalorieSte

Latest Threads

Top