undefined references
Posted
by Brandon
on Stack Overflow
See other posts from Stack Overflow
or by Brandon
Published on 2010-04-01T20:22:58Z
Indexed on
2010/04/01
20:43 UTC
Read the original article
Hit count: 372
fortran
|static-linking
Hello,
I'm trying to compile some fortran code and I'm running into some confusing linking errors. I have some code that I compile and place into a static library:
>gfortran -c -I../../inc -o bdout.o bdout.F
>ar rv libgeo.a bdout.o
I then try to compile against that library with some simple test code and get the following:
>gfortran -o mytest -L -lgeo mytest.F
/tmp/cc4uvcsj.o: In function `MAIN__':
mytest.F:(.text+0xb0): undefined reference to `ncwrite1_'
collect2: ld returned 1 exit status
It's not in the object naming because everything looks fine:
>nm -u libgeo.a
bdout.o:
U _gfortran_exit_i4
U _gfortran_st_write
U _gfortran_st_write_done
U _gfortran_transfer_character
U _gfortran_transfer_integer
U ncobjcl_
U ncobjwrp_
U ncopencr_
U ncopenshcr_
U ncopenwr_
U ncwrite1_
U ncwrite2_
U ncwrite3_
U ncwrite4_
U ncwritev_
I can check the original object file too:
>nm -u bdout.o
U _gfortran_exit_i4
U _gfortran_st_write
U _gfortran_st_write_done
U _gfortran_transfer_character
U _gfortran_transfer_integer
U ncobjcl_
U ncobjwrp_
U ncopencr_
U ncopenshcr_
U ncopenwr_
U ncwrite1_
U ncwrite2_
U ncwrite3_
U ncwrite4_
U ncwritev_
The test code simply contains a single call to a function defined in bdout.o:
program hello
print *,"Hello World!"
call ncwrite1( istat, f, ix2, ix3, ix4, ix5, ih )
end program hello
I can't figure out what the problem is. Does anyone have any suggestions? Maybe even just a way to track the problem down?
Cheers.
© Stack Overflow or respective owner