spamsink: (Default)
[personal profile] spamsink


Пишем main.cc:

#include <dlfcn.h>
#include <stdio.h>

int main() {
        printf("ptr = %p\n", dlopen("./dll.so", RTLD_NOW));
}


Пишем dll.cc:

class Account {
        char * name;
public:
        Account() : name(0) {}
} acct;


Компилируем (gcc 3.4.3):
g++ -g -o main main.cc -ldl
g++ -g -shared -fPIC -o dll.so dll.cc


Запускаем, получаем Segmentation fault. Я знаю, почему (а вы?); но не знаю, какого, собственно, рожна!
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting
Page generated Apr. 30th, 2026 05:59 am
Powered by Dreamwidth Studios