By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,187 Members | 1,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,187 IT Pros & Developers. It's quick & easy.

calling NAG from C

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
b.***********@wbmt.tudelft.nl (Gunasekaran) wrote in
news:82*************************@posting.google.co m:
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?

--
- Mark ->
--
Nov 13 '05 #2

P: n/a
Gunasekaran wrote:
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.

Nov 13 '05 #3

P: n/a
b.***********@wbmt.tudelft.nl (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.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
We found a loophole; they can't keep us out anymore.
Nov 13 '05 #4

P: n/a
On Thu, 28 Aug 2003 16:52:27 -0000, Derk Gwen <de******@HotPOP.com>
wrote:
b.***********@wbmt.tudelft.nl (Gunasekaran) wrote:
# Dear all,
#
# I wrote a c program and tried to call NAG(desinged for FORTRAN)subroutine. <snip> # 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
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.