From: Alan W. I. <ir...@be...> - 2002-01-29 18:31:52
|
I am now discovering more than I want to about atexit. I was wrong below, atexit is not obscure at all, but that leads to new questions. It appears in tek.c (and commented out in gnome.c). Here are the tek.c lines found by grep. tek.c:static void tty_atexit (void); tek.c:static void tty_atexit (void) {} tek.c: if (atexit(tty_atexit)) tek.c: fprintf(stderr, "Unable to set up atexit handler.\n"); tek.c:tty_atexit(void) /* exit handler */ atexit (which I am sure you knew, but I didn't) is a standard K&R function (see p. 253 of the K&R book) defined like int atexit(void (*fcn)(void)) from p. 119 the & operator is not needed on the function name in argument lists so if (atexit(tty_atexit)) above seems fine to me. Also, a simple test programme consisting of #include <stdio.h> main() { printf("Hello, World!\n"); atexit(); } compiles and links fine with the command gcc test.c on both my Debian ***and RH 7.1 systems***. (Of course it segfaults upon execution after printing out the Hello World! message since the argument is incorrect on atexit.) So as expected from the K&R book, atexit is just part of the standard library on both systems, and nothing special has to be done to link against it. So I am completely stumped why I am getting a linking error concerning atexit when I attempt to link either our C or tk examples, but not when I link our C++ or fortran examples. Alan email: ir...@be... phone: 250-727-2902 FAX: 250-721-7715 snail-mail: Dr. Alan W. Irwin Department of Physics and Astronomy, University of Victoria, P.O. Box 3055, Victoria, British Columbia, Canada, V8W 3P6 __________________________ Linux-powered astrophysics __________________________ On Tue, 29 Jan 2002, Alan W. Irwin wrote: > On my RedHat 7.1 system I cannot get either the C or tk examples to build > > a typical error message is > > gcc -c -O -I/usr/include/plplot/.. -I. -I/usr/include/gtk-1.2 > -I/us > r/include/glib-1.2 -I/usr/lib/glib/include -I/usr/X11R6/include > -I/usr/include - > I/usr/lib/gnome-libs/include xtk01.c > gcc xtk01.o \ > -L/usr/lib -lplplotd -o xtk01 -litk3.1 -ltk8.3 -litcl3.1 -ltcl8.3 > -L/usr/ > X11R6/lib -lX11 -ldl -lm -lg2c -Wl,-rpath,/usr/lib > /usr/lib/libtclmatrixd.so.5: undefined reference to atexit' > collect2: ld returned 1 exit status > make: *** [xtk01] Error 1 > > Interestingly, the fortran and c++ examples build and execute fine. > > I tried replacing gcc with g77 in the above, but it made no difference. > > I suspect there is some obscure library containing atexit that I am missing > on the RH 7.1 system, but which library is it? Once that is identified, I > can install the library and proceed. Another possibility is that > libtclmatrixd is not linked properly, but again I need to know the > name of the library which contains atexit. > > Any help in identifying the library containing atexit would be much > appreciated. > > Alan > > > > email: ir...@be... > phone: 250-727-2902 FAX: 250-721-7715 > snail-mail: > Dr. Alan W. Irwin > Department of Physics and Astronomy, > University of Victoria, P.O. Box 3055, > Victoria, British Columbia, Canada, V8W 3P6 > __________________________ > > Linux-powered astrophysics > __________________________ > > > _______________________________________________ > Plplot-devel mailing list > Plp...@li... > https://lists.sourceforge.net/lists/listinfo/plplot-devel > |