Hi,
Am Mittwoch, November 28, 2018 14:03 CET, David Chisnall
<[email protected]> schrieb:
> On 28/11/2018 12:55, Sebastian Reitenbach wrote:
> > since both work, don't know how helpful the objdump will be.
>
> Not very. Can you try making lib.c into a lib.m that implements a class
> with a +load method (and add -lobjc to the compile command for loadlib.c)?
>
> David
so I used this as the lib.m:
#include <stdio.h>
#import <Foundation/Foundation.h>
@interface testlib: NSObject
{
}
@end
@implementation testlib
+ (void) load {
puts("Library loaded");
}
@end
And this command to compile it:
clang -shared -fPIC -Wl,-E -Wl,-R/usr/local/lib -L/usr/local/lib
-Wl,-R/usr/local/lib -L/usr/local/lib -pthread -fexceptions -o lib.so
-L/usr/local/lib -lstdc++ -lm -lgnustep-base -lpthread -lobjc2
-fobjc-nonfragile-abi -lm -lc++abi
and your loadlib.c:
#include <dlfcn.h>
#include <stdio.h>
int main(void)
{
puts("Program started");
dlopen("./lib.so", RTLD_LAZY | RTLD_GLOBAL);
return 0;
}
and then clang loadlib.c
then it only prints:
Program started
in both cases.
I guess I miss something, since its not working for both cases.
When not using the -fuse-ld flag, I also had gnustep-base compiled without that
flag, using lld.
When compiling lib.m with -fuse-ld=bfd, I had rebuilt gnustep-base compiled
with that flag as well.
Sebastian
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep