|
From: jlar on 23 Apr 2008 09:49 Hi Fortran experts, I hope someone can help with this. I am trying to link my application to the ngmath library. For some reason it does not work. I have therefore written a small test program which calls some subroutines in libngmath: > cat test.f90 program test real, dimension(2) :: xin, yin real, dimension(2) :: vin, xout, yout, vout integer :: ierr xin = (/1, 2/) yin = (/1, 2/) vin = (/1, -1/) xout = (1.5) yout = (1.5) call nnseti('EXT - extrapolation control',1) call nnsetr('NUL - function value when extrapolation not allowed',-1.) call natgrids(2,xin,yin,vin,1,1,xout,yout,vout,ierr) write(0,*) vout end I have placed the ngmath library file in the current working directory: > pgf90 -L. -lngmath -o test test.o test.o: In function `MAIN_': test.f90:(.text+0xdd): undefined reference to `nnseti_' test.f90:(.text+0xf1): undefined reference to `nnsetr_' test.f90:(.text+0x13d): undefined reference to `natgrids_' If I use nm on the library file the subroutines seem to exist: > nm libngmath.a |grep nnseti_ 0000000000000357 T nnseti_ > nm libngmath.a |grep nnsetr_ 000000000000063c T nnsetr_ > nm libngmath.a |grep natgrids_ 00000000000001f5 T natgrids_ I have tried using ar to extract the .o files from the library and link to them directly. That works but is really not an option. Regards, Jesper
From: Richard Maine on 23 Apr 2008 10:18 jlar <jesper.webmail(a)gmail.com> wrote: > I am trying to link my application to the ngmath library.... > > pgf90 -L. -lngmath -o test test.o Looks to me like the usual ordering problem with the command line. The command line is *VERY* sensitive to ordering. Try reordering it as pgf90 test.o -L. -lngmath -o test The way you have it, the *First* thing that happens is that the linker looks to see what is needed in ngmath. Nothing is needed yet, so then the linker adds in test.o. After test.o is aded, stuff from nglib will be needed, but the linker doesn't go back and check again. This "feature" is common to most linkers today; it isn't just a Fortran matter. I find it pretty crude compared to some linkers I've worked with in the past. It is also a FAQ. P.S. I recommend that you *NOT* use the name test for your test file. That particular (and common) choice happens to result in a lot of confusions because there is already a system command named test. Unless you are sophisticated enough to know that and how to deal with it, you are likely to end up getting the system command when trying to run your program. The resulting confusion generates another FAQ. Use just about any other name. Heck, use test1 if you want - just anything except test. -- Richard Maine | Good judgement comes from experience; email: last name at domain . net | experience comes from bad judgement. domain: summertriangle | -- Mark Twain
From: jlar on 23 Apr 2008 23:45 Hi Richard, On Apr 23, 4:18 pm, nos...(a)see.signature (Richard Maine) wrote: > Looks to me like the usual ordering problem with the command line. The > command line is *VERY* sensitive to ordering. Try reordering it as > > pgf90 test.o -L. -lngmath -o test Thanks, that solved my problems. Regards, Jesper
|
Pages: 1 Prev: modify data at a specific line and columns Next: RTL "bloat" -- Re: A digression |