Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

How do use dlopen ?

mkhwang9
Beginner
1,732 Views
I found 'dlopen' in Linuxis basically same as 'Loadlibrary' in MS Windows.
The function would be dynamically load a library during the program run, not necessary during startup. Now how do use this ? At link stage I got following message.
: undefined reference to 'dlopen_'
Please help!
0 Kudos
2 Replies
TimP
Honored Contributor III
1,732 Views
As you haven't provided sufficient information, I'll ask you to make sure that your compiler is recent enough to include -ldl in the link options. If you have a mis-match between compiler version and linux distro, and don't want to upgrade, you could eliminate that problem by adding -ldl yourself.
0 Kudos
mkhwang9
Beginner
1,732 Views

My compiler version 8.1, and I have used ldl option for ifort command.

The calling program has basically following lines:

pointer (addrFunc, subdll)

handle = dlopen (my_lib.so, RTLD_LAZY)

addrFunc = dlsym(handle, square)

call subdll(i, rvalue)

The shared library my_lib.so contains subroutine subdll. I wish I could see sample fortran source which use dlopen, and also build procedure. Actually the C sample source I encountered included dlfcn.h in it. I wonder if I would need similar thing in my Fortran source. Thank you for your attention.

0 Kudos
Reply