flat assembler
Message board for the users of flat assembler.

flat assembler > Linux > Fasm and gtk+-2.0 with g_signal_connect

Author
Thread Post new topic Reply to topic
cookj



Joined: 18 Dec 2003
Posts: 1
I am assembling the gtk-examples that was posted by Bazik on the fasm site.

Bazik evidently used an earlier version of gtk. I can not get the source code that uses gtk_signal_connect to assemble. I have made the appropriate changes because I believe now it is called g_signal connect.

I understand that glib now has the signal api system that was previously in gtk 1.2.

To my knowledge I am linking glib in but I still get the following:

gcc -Wall -s -O3 button.o -o button `pkg-config --cflags --libs gtk+-2.0`
button.o(.text+0x46): In function `main':
: undefined reference to `g_signal_connect'
button.o(.text+0x5e): In function `main':
: undefined reference to `g_signal_connect'
collect2: ld returned 1 exit status
make: *** [button] Error 1

Obviously some library is not being linked in.


Here is my output from pkg-config:
[cookj@localhost gtk-button]$ pkg-config --libs gtk+-2.0
-Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0

Anyone have any ideas?

Thanks


cookj
Post 18 Dec 2003, 06:19
View user's profile Send private message Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
please post your source (it makes it easier to see what's the error, like maybe youforgot to make some extrn (or somthing like that))

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 18 Dec 2003, 13:54
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Todd



Joined: 05 Oct 2003
Posts: 10
Location: US
I'm having the same exact problem. If it will help, here's the source for my test, and the commands I used to compile it:

Code:
format ELF
include 'cdecl.inc'

public main
extrn gtk_init
extrn gtk_main
extrn gtk_window_new
extrn gtk_widget_show
extrn gtk_main_quit
extrn g_signal_connect
extrn g_print

section '.text' executable
        proc main, argc, argv
               enter
               
            lea eax, [argc]
             lea ebx, [argv]
             ccall gtk_init, eax, ebx
            
            ccall gtk_window_new, 0
             mov [window], eax
           
            ccall g_signal_connect, [window], ev_delete, delete_event
           ccall g_signal_connect, [window], ev_destroy, destroy_event
         
            ccall gtk_widget_show, [window]
             call gtk_main
               return

  proc delete_event, widget, event, data
              enter
               mov eax, 0
          return
              
    proc destroy_event, widget, data
            enter
               call gtk_main_quit
          return          
            
section '.data' writeable
     window dd ?
 ev_delete db 'delete_event', 0
    ev_destroy db 'destroy', 0
    


And for compiling:

Code:
fasm gtktest.asm gtktest.o
gcc gtktest.o -o gtktest `pkg-config --cflags --libs gtk+-2.0`
    


Last edited by Todd on 30 May 2004, 22:09; edited 2 times in total
Post 26 May 2004, 22:14
View user's profile Send private message Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
Aha! I think I found the problem: http://mail.gnome.org/archives/gtk-app-devel-list/2002-November/msg00275.html
(I sort of suspected it when seeind the "#define" in the header file...)
Quote:
g_signal_connect is a macro, so (AFAIK) you cannot import it. You can
import the function it actually calls (g_signal_connect_data), which is
in libgobject.


-- I'll see if I can get it to work with g_signal_connect_data instead - or make a nice fasm macro Smile
Post 30 May 2004, 17:22
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Todd



Joined: 05 Oct 2003
Posts: 10
Location: US
Yes, that was it! Thanks for finding that, it works great now. All you need to do is change the g_signal_connect parts to g_signal_connect_data, and add two parameters onto the end. For example:

This:
Code:
extrn g_signal_connect
ccall g_signal_connect, [widget], signal, function
    


Becomes this:
Code:
extrn g_signal_connect_data
ccall g_signal_connect_data, [widget], signal, function, dword 0, dword 0
    


The last two parameters, according to gsignal.h, are "destroy_data" and "connect_flags". If you use the g_signal_connect macro (in C) they are always set to 0. Thanks again!
Post 30 May 2004, 22:14
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.