LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-05-2005, 09:41 PM   #1
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
GTK+ link error: gdk_display_new()


Hi -

I'm a complete newbie to GTK+:

We're writing a Linux-based app; one of our requirements is that the GUI must be
able to address multiple different video cards independently.

SuSE 9.2 recognizes each of the three video cards in our system, and addresses t
hem as:

unix:0.0
unix:0.1
... and ...
unix:0.2

So far, so good.

I've installed the default GTK+/GDK libraries that come with SuSE 9.2 (GTK2, 2.4 .9-10.1), and I'm trying to adapt the sample code in "Multi-head Support Overview". It's failing with this link error:

make =>
gcc -g -O2 -o hello_glade main.o support.o interface.o callbacks.o \
-Wl,--export-dynamic -L/opt/gnome/lib -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
main.o(.text+0xb2): In function `main':
/home/paulsm/proj/hello_glade/src/main.c:56:
undefined reference to `gdk_display_new'

Does anybody have any ideas why my (C-language, not C++) build isn't finding this function?

Are there any alternative GTK+ functions for doing graphics I/O to multiple different video cards?

Thank you *very* much in advance .. PSM
 
Old 04-06-2005, 03:45 AM   #2
ahwkong
Member
 
Registered: Aug 2004
Location: Australia
Distribution: Fedora
Posts: 282

Rep: Reputation: 30
You can compare the flags you had in the Makefile for the gcc command line with the result obtained from this command

Code:
gtk-config --cflags --libs
 
Old 04-06-2005, 11:25 AM   #3
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

1. Thank you for your response.
Here's the output:

gtk-config --cflags --libs =>
-I/opt/gnome/include -I/opt/gnome/include/gtk-1.2 -I/opt/gnome/include/glib-1.2
-I/opt/gnome/lib/glib/include -I/usr/X11R6/include
-L/opt/gnome/lib -L/usr/X11R6/lib -lgtk -lgdk -rdynamic -lgmodule -lglib -ldl -lXi -lXext -lX11 -lm

2. This means that I have GTK 1.2 installed (I do, along with GTK+ 2.0 in parallel), and that
"gtk-config" happens to point to GKS 1.2.

3. My compile/link command, however, should be pointing exclusively to GTK+ 2.0. And that
GTK+ 2.0 build isn't finding gdj_display_new().

4. I'll de-install all the GTK development packages, re-install GTK+ 2.0, verify that gtk-config
now points to GTK +2.0, and re-try the make.

Your .. PSM
 
Old 04-06-2005, 01:59 PM   #4
Harmaa Kettu
Member
 
Registered: Apr 2005
Location: Finland
Posts: 196

Rep: Reputation: 30
That function should be gdk_display_open(). See http://www.gtk.org/api/2.6/gdk/GdkDisplay.html
 
Old 04-06-2005, 02:50 PM   #5
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
GTK graphics to multiple displays: gdk_display_open()

Hi -

1. Thank you very much, Harmaa Kettu. I just discovered the same thing a few moments before I saw your post

THIS CODE PERMITS REDIRECTING GTK+ GRAPHICS TO A DIFFERENT X DISPLAY (EXAMPLE: TO "unix:0.2"):
Harmaa Kettu

GtkWidget *
create_drawing_area ()
{
GdkDisplay *gdisplay;
GtkWidget *window;
GtkWidget *frame;
...

/* Create toplevel window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");

/* Assign screen and display */
gdisplay = gdk_display_open("unix:0.2");
if (gdisplay) {
GdkScreen *gscreen;
gscreen = gdk_display_get_default_screen(gdisplay);
if (gscreen) {
gtk_window_set_screen(GTK_WINDOW(window), gscreen);
}
else {
printf ("WARNING: Unable to get screen!\n");
...

2. Thank you, too, for your help ahwkong.

I discovered, however, that the reason "gtk-config" was pointing to my GTK 1.2 libraries ... is because
gtk-config (and glib-config, etc) are all GTK 1.2 scripts.

In GTK+ 2.0, all of the individual "g*-config" scripts have been replaced by one new, common tool:

pkg-config
<= THIS SHOULD BE USED FOR ALL CURRENT GTK+ DEVELOPMENT WORK

Your .. PSM
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to link helpblocks application to gtk application m.harshavardhan Linux - Software 0 08-16-2005 08:39 AM
gtk error xpcandrew Linux - Software 3 02-01-2005 03:23 PM
GTK error when starting gtk-chtheme Dswissmiss Linux - Software 1 10-01-2004 11:53 PM
compiling gaim/ gtk error (two versions of gtk) webazoid Linux - Software 0 07-06-2004 06:05 PM
gtk-gnutella link and icon? Skinner2 Linux - Software 1 04-30-2002 12:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration