FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help for gtkd as shared object file.

 
Post new topic   Reply to topic     Forum Index -> gtkD
View previous topic :: View next topic  
Author Message
sclytrack



Joined: 14 Jul 2006
Posts: 14

PostPosted: Fri Sep 22, 2006 2:04 am    Post subject: Need help for gtkd as shared object file. Reply with quote

1. I've checked out revision 196 of dui.
2. I've created my own makefiles to make an libgtkd.so file under Debian Etch. The default makefile in gtkd (dui) creates a static file.
3. When try to compile the actual application (main.d) , a hello world application.I get the following error codes.


dmd -c main.d -I../src
cc -o main main.o -lphobos -lpthread -lm -ldl -lstdc++ -L../src -lgtkd -gthread../src/libgtkd.so: undefined reference to `_d_throw'
../src/libgtkd.so: undefined reference to `_d_assert'
../src/libgtkd.so: undefined reference to `_D9invariant12_d_invariantFC6ObjectZv'
collect2: ld returned 1 exit status
make: *** [all] Error 1

Please note I didn't compile with -gc -profile options. Also dmd v0.167 doesn't list -fPIC, but still seems to work.

Anybody any clue?


Listing of makefile in the source
------------------------------------

DCOMPILER=dmd

OBJECTS_atk:=$(patsubst atk/?.d, atk/?.o, $(wildcard atk/*.d))
OBJECTS_cairoLib:=$(patsubst cairoLib/?.d, cairoLib/?.o, $(wildcard cairoLib/*.d))
OBJECTS_gdk:=$(patsubst gdk/?.d, gdk/?.o, $(wildcard gdk/*.d))
OBJECTS_gdkpixbuf:=$(patsubst gdkpixbuf/?.d, gdkpixbuf/?.o, $(wildcard gdkpixbuf/*.d))
OBJECTS_glib:=$(patsubst glib/?.d, glib/?.o, $(wildcard glib/*.d))
OBJECTS_gobject:=$(patsubst gobject/?.d, gobject/?.o, $(wildcard gobject/*.d))
OBJECTS_gthread:=$(patsubst gthread/?.d, gthread/?.o, $(wildcard gthread/*.d))
OBJECTS_gtk:=$(patsubst gtk/?.d, gtk/?.o, $(wildcard gtk/*.d))
OBJECTS_lib:=$(patsubst lib/?.d, lib/?.o, $(wildcard lib/*.d))
OBJECTS_pango:=$(patsubst pango/?.d, pango/?.o, $(wildcard pango/*.d))


OBJECTS_ALL_gtkd:=$(OBJECTS_atk) $(OBJECTS_cairoLib) $(OBJECTS_gdk) $(OBJECTS_gdkpixbuf) $(OBJECTS_glib) $(OBJECTS_gobject) $(OBJECTS_gthread) $(OBJECTS_gtk) $(OBJECTS_lib) $(OBJECTS_pango)

#libraries must start with lib

TARGET_PROJECT=libgtkd.so
IMPORT_PATH=


all: $(TARGET_PROJECT)

$(TARGET_PROJECT): $(OBJECTS_ALL_gtkd)
cc -shared -o $@ $(OBJECTS_ALL_gtkd)

#?.o: ?.d
# $(DCOMPILER) -c -fPIC $< -I$(IMPORT_PATH)

atk/?.o: atk/?.d
make -C atk

cairoLib/?.o: cairoLib/?.d
make -C cairoLib

gdk/?.o: gdk/?.d
make -C gdk

gdkpixbuf/?.o: gdkpixbuf/?.d
make -C gdkpixbuf

glib/?.o: glib/?.d
make -C glib

gobject/?.o: gobject/?.d
make -C gobject

gthread/?.o: gthread/?.d
make -C gthread

gtk/?.o: gtk/?.d
make -C gtk

lib/?.o: lib/?.d
make -C lib

pango/?.o: pango/?.d
make -C pango


clean:
-make -C atk clean
-make -C cairoLib clean
-make -C gdk clean
-make -C gdkpixbuf clean
-make -C glib clean
-make -C gobject clean
-make -C gthread clean
-make -C gtk clean
-make -C lib clean
-make -C pango clean
@-rm *.o
@-rm *~
@-rm $(TARGET_PROJECT)


Listing of makefile in each directory
example here /src/glib
------------------------------------- It just compiles every .d file into an .o


OBJECTS_glib:=$(patsubst ?.d, ?.o, $(wildcard *.d))

IMPORT_PATH=../

all: $(OBJECTS_glib)

?.o: ?.d
dmd -c -fPIC $< -I$(IMPORT_PATH)

clean:
-rm *.o Very Happy Very Happy
_________________
AMD Athlon 1800+
Debian Etch 4.0 (stable)
Geforce 2 MX
Please no comments about me passing a 4x4 matrix by value.
Back to top
View user's profile Send private message
Carlos



Joined: 19 Mar 2004
Posts: 396
Location: Canyon, TX

PostPosted: Fri Sep 22, 2006 5:49 am    Post subject: Re: Need help for gtkd as shared object file. Reply with quote

sclytrack wrote:

cc -o main main.o -lphobos -lpthread -lm -ldl -lstdc++ -L../src -lgtkd -gthread../src/libgtkd.so: undefined reference to `_d_throw'
../src/libgtkd.so: undefined reference to `_d_assert'
../src/libgtkd.so: undefined reference to `_D9invariant12_d_invariantFC6ObjectZv'
collect2: ld returned 1 exit status
make: *** [all] Error 1

I read your makefile I can't find the place where the change should be made, but in the "cc -o ..." line, make sure "-lphobos -lpthread -lm" appear after all objects/libraries written in D. Maybe you'll need -ldl too, but I'm not sure.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
sclytrack



Joined: 14 Jul 2006
Posts: 14

PostPosted: Fri Sep 22, 2006 10:38 pm    Post subject: gtkd.so Reply with quote

Thanks for the quick response, but the error must be somewhere else. Sad I admit the makefile listings are a bit chaotic.

I've created a file called gtkd.so and I'm wondering if we should reserve that name for the gtk section. That means we can have gdkd atkd cairod and so forth. I don't know if the components of gtkd (duit) can be used independently.
_________________
AMD Athlon 1800+
Debian Etch 4.0 (stable)
Geforce 2 MX
Please no comments about me passing a 4x4 matrix by value.
Back to top
View user's profile Send private message
sclytrack



Joined: 14 Jul 2006
Posts: 14

PostPosted: Sun Sep 24, 2006 3:51 am    Post subject: shared library not gtkd (duit) related Reply with quote

I've tried shared library on a "smaller test library".

Without the class Form in the mylibrary.d it runs perfectly, with it I get the following error.

Code:

:~/temporary/test/sharedobjecttest$ make
dmd -c -fPIC mylibrary.d -I.
cc -shared -o libmyshared.so mylibrary.o -lphobos -lpthread -lm
/usr/bin/ld: libmyshared.so: undefined versioned symbol name _d_throw@4
/usr/bin/ld: failed to set dynamic section sizes: Bad value
collect2: ld returned 1 exit status
make: *** [libmyshared.so] Error 1


I've seen messages dating from 2005 about _d_throw on the digitalmars forum.
So this isn't gtkd(duit) related thing.

Listing of
mylibrary.d-->myshared.so
main.d-->test




This is the file mylibrary.d

Code:

module mylibrary;

/*
class Form
{
private:
        char [] _caption;
public:
        this(char [] caption)
        {
                _caption = caption;
        }
}
*/


int boe()
{
        return 11;
}




and the file main.d
Code:


module myapplication;

import mylibrary;
import std.stdio;


int main()
{
        writefln("Shared Library Test");
//      Form m = new Form("test");
        writefln(boe());
        return 0;
}



and the makefile
Code:


all: test

test: main.d libmyshared.so
        dmd -c main.d -I.
        cc -o test main.o -lphobos -lpthread -lm -ldl -L. -lmyshared
run:
        ./test

libmyshared.so: mylibrary.d
        dmd -c -fPIC mylibrary.d -I.
#       gcc -c -fPIC mylibrary.c
        cc -shared -o $@ mylibrary.o -lphobos -lpthread -lm

clean:
        -rm *.o
        -rm test
        -rm *.so
        clear

_________________
AMD Athlon 1800+
Debian Etch 4.0 (stable)
Geforce 2 MX
Please no comments about me passing a 4x4 matrix by value.
Back to top
View user's profile Send private message
Carlos



Joined: 19 Mar 2004
Posts: 396
Location: Canyon, TX

PostPosted: Sun Sep 24, 2006 7:14 am    Post subject: Reply with quote

I don't know whether DMD already supports creating .so. Could you try with gdc to see how it goes?
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
sclytrack



Joined: 14 Jul 2006
Posts: 14

PostPosted: Mon Sep 25, 2006 12:45 am    Post subject: dmd .so Reply with quote

Yeah its probably that.
I'll give gdc a try when I'm ... ehm. hmm, yeah I can say it. When I'm not so "lazy". Wink
Thanks for your input Carlos.


Sclytrack.
_________________
AMD Athlon 1800+
Debian Etch 4.0 (stable)
Geforce 2 MX
Please no comments about me passing a 4x4 matrix by value.
Back to top
View user's profile Send private message
sclytrack



Joined: 14 Jul 2006
Posts: 14

PostPosted: Fri Feb 09, 2007 2:52 am    Post subject: linking sequence Reply with quote

I just wanted to point out that in my above examples I did not take into account the linking sequence.
according to documentation phobos should be linked last.

dmd myprog.d -c
gcc myprog.o -o myprog -lm -lpthread -ldl -lduit -lphobos


Don't know what depends on what but here is the rule.

if B depends on A, B should be linked first.
_________________
AMD Athlon 1800+
Debian Etch 4.0 (stable)
Geforce 2 MX
Please no comments about me passing a 4x4 matrix by value.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> gtkD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group