symbol lookup error: /var/www/myapp/smart/lib/libsamplesize.so: undefined symbol: _gfortran_date_and_time

19 views
Skip to first unread message

Liying Huang

unread,
Dec 9, 2015, 5:03:26 PM12/9/15
to GNU Fortran


Hi, 

I tried to use gfortran and gcc to create a dynamic library in Linux (redhat) from fortran and c codes,
everything works until I used the instrinsic date_and_time function in fortran.

I compiled fortran function using:

gfortran -c -shared -fPIC samplesize4.f90

Compiled c function using:

gcc -c -shared -fPIC smartWrapper.c

then create dynamic library:

gcc -shared -fPIC *.o -o libsamplesize.so

No compiling error, but when I used libsamplesize.so, I got error:

symbol lookup error: /var/www/myapp/smart/lib/libsamplesize.so: undefined symbol: _gfortran_date_and_time,
what option do I need to use so I can include  _gfortran_date_and_time in libsamplesize.so?

Thanks!
Liz

Tobias Burnus

unread,
Dec 9, 2015, 5:10:07 PM12/9/15
to gnu-f...@googlegroups.com, Liying Huang
Hi,

Liying Huang wrote:
I tried to use gfortran and gcc to create a dynamic library in Linux (redhat) from fortran and c codes, everything works until I used the instrinsic date_and_time function in fortran. [...]
When I used libsamplesize.so, I got error: symbol lookup error: _gfortran_date_and_time,

Instead of using

    gcc -shared -fPIC *.o -o libsamplesize.so

to link the file, either link is with "gfortran" instead of "gcc" or add explicitly a "-lgfortran" to link gfortran's run-time library to the library.

If you then run "ldd libsamplesize.so", it will show on which libraries the created libsamplesize.so depends on (which should be among others "libgfortran.so"). You can also statically link libgfortran to libsample size by specifying "-static-libgfortran" when linking with "gfortran".


Cheers,

Tobias

Liying Huang

unread,
Dec 10, 2015, 10:27:46 AM12/10/15
to GNU Fortran, liyhu...@gmail.com


Thanks! It works now.

Liz
Reply all
Reply to author
Forward
0 new messages