dlopen ? is it possible to use with stdc++
Gabriel Dos Reis
Gabriel.Dos-Reis@cmla.ens-cachan.fr
Tue Oct 17 09:31:00 GMT 2000
Levente Farkas <lfarkas@mindmaker.hu> writes:
| hi,
| I'm try to use a simple shared library:
| ---------------------------
| #include <iostream>
|
| void test1()
| {
| cout << "test1";
| }
| ---------------------------
| compile it with :
| g++ -c -fPIC -fhonor-std test.cpp -o test.o
| create a shared lib with:
| export LD_LIBRARY_PATH=/home/lfarkas
| g++ test1.o -L/home/lfarkas/ -shared -Wl,-soname,libtest.so.1 -o
| /home/lfarkas/libtest.so.1.0
| than compile the following test:
| ---------------------------
| #include <stdio.h>
| #include <dlfcn.h>
|
| int main(int /*argc*/, char** /*args*/)
| {
| void* handle;
| handle = dlopen("libtest.so", RTLD_LAZY);
| if (!handle)
| {
| fputs(dlerror(), stderr);
| return 1;
| }
| fputs("betoltve", stdout);
| typedef void (*type)();
| type func = (type)dlsym(handle, "test1");
Please note that test1 has C++ linkage and is likely to be decorated.
This is not an issue specific to v3. It is an issue about how to
dlsym C++ names, and as such has nothing to do with v3.
-- Gaby
More information about the Libstdc++
mailing list