[Issue 10711] shared phobos library should not depend on _Dmain
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Aug 8 00:23:25 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10711
Walter Bright <bugzilla at digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bugzilla at digitalmars.com
--- Comment #1 from Walter Bright <bugzilla at digitalmars.com> 2013-08-08 00:23:21 PDT ---
To reproduce:
main.c:
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
int main()
{
printf("+main()\n");
void *lh = dlopen("/home/walter/tmp/libdll.so", RTLD_LAZY);
if (!lh)
{
fprintf(stderr, "dlopen error: %s\n", dlerror());
exit(1);
}
printf("libdll.so is loaded\n");
int (*fn)() = dlsym(lh, "dll");
char *error = dlerror();
if (error)
{
fprintf(stderr, "dlsym error: %s\n", error);
exit(1);
}
printf("dll() function is found\n");
(*fn)();
printf("unloading libdll.so\n");
dlclose(lh);
printf("-main()\n");
return 0;
}
dll.d:
import core.stdc.stdio;
extern (C) int dll()
{
printf("dll()\n");
return 0;
}
static this()
{
printf("libdll.so construction\n");
}
static ~this()
{
printf("libdll.so destruction\n");
}
Build:
dmd -c dll.d -fPIC
dmd -oflibdll.so dll.o -shared -defaultlib=libphobos2.so
-L-rpath=/home/walter/cbx/mars/phobos/generated/linux/release/64
gcc -c main.c
gcc -rdynamic main.o -o main -ldl
./main
Results:
+main()
dlopen error:
/home/walter/cbx/mars/phobos/generated/linux/release/64/libphobos2.so.0.64:
undefined symbol: _Dmain
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list