www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Makefile for linking in a c routine that uses GTK: a solution

The Makefile:
CC = gcc -g -I/usr/include/gdk
CD = dmd
DMD_DIR = /usr/local/dmd
DLNK = -L$(DMD_DIR)/lib -lphobos -lpthread -lm

all:  test1

test1:  test1md.o test1a.o
	$(CC)	test1md.o test1a.o `pkg-config --libs gtk+-2.0` 
-L/home/charles/lib $(DLNK) -o test1

	$(CD)  -c test1md.d  -oftest1md.o

test1a.o: test1a.c
	$(CC)  `pkg-config --cflags gtk+-2.0` -c test1a.c -o test1a.o


Thanks to all who helped me debug this.
P.S.:  This is the "hello world" routing from the GTK C 
tutorial.  For those who are curious:

test1md.d is:
extern(C)  int  test();

void  main()  {  test;  }

and test1a.c is:
#include	<gtk/gtk.h>

static	void	hello	(GtkWidget *widget,	gpointer data)
{	g_print	("Hello World\n");	}

static	gboolean	delete_event	(GtkWidget *widget,	GdkEvent 
*event,	gpointer data)
{	/*	returning TRUE means don't send the destroy signal	*/
	g_print	("delete event occurred\n");
	//return	TRUE;
	return	FALSE;

static	void	destroy	(GtkWidget *widget,	gpointer data)
{	gtk_main_quit();	}

int	test()
{	GtkWidget	*window;
	GtkWidget	*button;

	gtk_init	(NULL, NULL);

	window	=	gtk_window_new	(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window), "Testing, 
testing...1, 2, 3...");

	g_signal_connect	(G_OBJECT(window), "destroy", 
G_CALLBACK(destroy), NULL);

	gtk_container_set_border_width (GTK_CONTAINER(window), 10);

	button	=	gtk_button_new_with_label("Hello World");
	g_signal_connect (G_OBJECT(button), "clicked", 
	gtk_container_add(GTK_CONTAINER(window), button);
	return	0;

//int main(int argc, char *argv[])
//{	return	test(argc, argv);	}
Jul 27 2007