I'm writing a small MySQL program in C (Well, I'm writing it in C++ at the same time as well).
In both apps, I am linking the libmysql libraries.
If I wanted to load them and call them at runtime instead, how is that done?
Thanks.
I'm writing a small MySQL program in C (Well, I'm writing it in C++ at the same time as well).
In both apps, I am linking the libmysql libraries.
If I wanted to load them and call them at runtime instead, how is that done?
Thanks.
Mainframe assembler programmer by trade. C coder when I can.
I assume you are referring to loading the library at runtime?
Depends on the platform. For windows, you'll need to use LoadLibrary and then GetProcAddress to retrieve the addresses of the functions, as far as I know. I'm not sure if there's an easier way to do it.
On Linux, you use shared objects and the accompanying functions to load it(dlopen and others mentioned in the man page for dlopen).
"What's up, Doc?"
"'Up' is a relative concept. It has no intrinsic value."
I'm on a Mac.
Mainframe assembler programmer by trade. C coder when I can.
Typing man ld on my Mac got me this:
I haven't tried it out, though.A dynamic library (aka dylib or framework) is a final linked image.
Putting a dynamic library on the command line causes two things: 1) The
generated final linked image will have encoded that it depends on that
dynamic library. 2) Exported symbols from the dynamic library are used to
resolve references.
Yes, looks like dlopen() (et al) are the functions to call. Found this on apple's web site: Mac Dev Center: Dynamic Library Programming Topics: Introduction
I'm coding up a test program and dynamic lib this afternoon to see how they work. Thanks. I'll post here when I'm done.
Mainframe assembler programmer by trade. C coder when I can.