[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Google
  Web www.spinics.net

Re: GTK+ library access issue?



ok. So, I did a complete reinstall of Ubuntu (it's relatively quick, so why not?).
This did nothing. Smae old story.

I then got back on the net and tried Paul's suggestion:

"Try putting it [-lm] at the end of the command, just for kicks."

i.e.,

gcc test.c -lm

Not only did that work for test.c, but it also solved my gtk problem!

I'm gobsmacked.

How come that works, but putting the lib flags before the filename(s) doesn't?

You blew my (now very grateful) mind.

Dave


From: David Buchan <pdbuchan@xxxxxxxxx>
To: David Nečas <yeti@xxxxxxxxxxxxxxx>
Cc: "gtk-list@xxxxxxxxx" <gtk-list@xxxxxxxxx>
Sent: Monday, October 24, 2011 7:06 PM
Subject: Re: GTK+ library access issue?

Hi Dave,

Yes, these commands were copy and pasted directly from the Makefile. I wouldn't trust myself to type it correctly.

I've been using the same Makefile for about 6 months or more. In fact, the program was compiled a day before I had to replace the hard drive.
The only reason I recompiled was to make sure I still could after reinstalling Ubuntu. Oh, how surprised I was.

The first batch of errors are:

main.c: In function ‘main’:
main.c:34:76: warning: variable ‘entry46_text’ set but not used [-Wunused-but-set-variable]
main.o: In function `main':
/main.c:43: undefined reference to `g_threads_got_initialized'
/main.c:44: undefined reference to `g_thread_init'
/main.c:46: undefined reference to `gtk_init'
/main.c:49: undefined reference to `g_malloc0'
/main.c:50: undefined reference to `g_malloc0'
/main.c:51: undefined reference to `g_malloc0'
/main.c:52: undefined reference to `g_malloc0'
/main.c:53: undefined reference to `g_malloc0'
/main.c:54: more undefined references to `g_malloc0' follow
main.o: In function `main':
/main.c:57: undefined reference to `gtk_builder_new'
/main.c:58: undefined reference to `gtk_builder_add_from_file'
/main.c:59: undefined reference to `g_log'
/main.c:60: undefined reference to `g_free'
/main.c:65: undefined reference to `g_slice_alloc'
/main.c:68: undefined reference to `gtk_widget_get_type'
/main.c:68: undefined reference to `gtk_builder_get_object'
/main.c:68: undefined reference to `g_type_check_instance_cast'
/main.c:69: undefined reference to `gtk_widget_get_type'
/main.c:69: undefined reference to `gtk_builder_get_object'
/main.c:69: undefined reference to `g_type_check_instance_cast'
/main.c:70: undefined reference to `gtk_widget_get_type'
/main.c:70: undefined reference to `gtk_builder_get_object'
/main.c:70: undefined reference to `g_type_check_instance_cast'
/main.c:73: undefined reference to `gtk_toggle_button_get_type'
/main.c:73: undefined reference to `gtk_builder_get_object'
/main.c:73: undefined reference to `g_type_check_instance_cast'
/main.c:74: undefined reference to `gtk_toggle_button_get_type'
/main.c:74: undefined reference to `gtk_builder_get_object'
/main.c:74: undefined reference to `g_type_check_instance_cast'
/main.c:75: undefined reference to `gtk_toggle_button_get_type'
/main.c:75: undefined reference to `gtk_builder_get_object'
/main.c:75: undefined reference to `g_type_check_instance_cast'
/main.c:76: undefined reference to `gtk_toggle_button_get_type'
/main.c:76: undefined reference to `gtk_builder_get_object'
/main.c:76: undefined reference to `g_type_check_instance_cast'
/main.c:77: undefined reference to `gtk_widget_get_type'
/main.c:77: undefined reference to `gtk_builder_get_object'
/main.c:77: undefined reference to `g_type_check_instance_cast'
/main.c:78: undefined reference to `gtk_toggle_button_get_type'
/main.c:78: undefined reference to `gtk_builder_get_object'
/main.c:78: undefined reference to `g_type_check_instance_cast'
/main.c:79: undefined reference to `gtk_widget_get_type'
etc... ending with...
collect2: ld returned 1 exit status
make: *** [x] Error 1

The above is a direct copy and paste EXCEPT that I removed the directory structure preceding '/main.c' on each line, and changed the program name to 'x' in the last line.

All in all, there's 1749 lines of this. I painstakingly went through it and except the 1st, rather trivial error, they're all of the same nature.

The first error was not picked up with my previous install. I suspect I now have a slightly newer gcc that is more thorough.

I do wonder whether the Ubuntu repository has changed content, or maybe I forgot that I originally installed something else.
Seems odd though, as things like g_malloc0 and g_free are so fundamental, I would've thought it would be in libgtk2.0-dev.

As I said in a previous email, I installed libgtk-3-dev first, got all these errors, then installed libgtk2.0-dev as well.
When that didn't work, I tried

sudo aptitude remove libgtk-3-dev and tried to compile with gtk2. When that still did the same thing, I went back an did
sudo aptitude install libgtk-3-dev again, figuring that having more libraries increases my chances of success (sign of a desperate man).
My (possibly faulty) understanding is that aptitude carefully keeps track of what is installed and all dependencies, so you get nice clean installs and removals.

Thanks for taking a look Dave.

Dave

From: David Nečas <yeti@xxxxxxxxxxxxxxx>
To: David Buchan <pdbuchan@xxxxxxxxx>
Cc: "gtk-list@xxxxxxxxx" <gtk-list@xxxxxxxxx>
Sent: Monday, October 24, 2011 5:46 PM
Subject: Re: GTK+ library access issue?

On Mon, Oct 24, 2011 at 01:49:05PM -0700, David Buchan wrote:
> I tried pkg-config from the command line and here's what we get:
>
> $ pkg-config --cflags gtk+-2.0 gmodule-2.0
> -pthread -I/usr/include/gtk-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12
>
> $ pkg-config --libs   gtk+-2.0 gmodule-2.0
> -pthread -Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgthread-2.0 -lgmodule-2.0 -lrt -lglib-2.0

This looks good.

So, (1) Are these flags actually used in the compilation – check the
actual command printed by make.  I can see your Makefile variables are
called CCFLAGS and LIBS instead of the more usual CFLAGS and LDFLAGS,
however, if they are consistently called like this it is not a problem.
(2) What are the *first* errors you get after cleaning the source tree
and running make?  Failing to link is often caused by some previous
problems; do you really get only linker errors and no errors from
earlier compilation stages?

Yeti




_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[GIMP Users]     [Yosemite News]    [Yosemite Photos]    [Gimp's Home]     [Steve's Art]

Add to Google Powered by Linux