This is the mail archive of the libstdc++@sources.redhat.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: dlopen ? is it possible to use with stdc++


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]