FBC Compile errors with GTK

Windows specific questions.
guyc
Posts: 8
Joined: Aug 14, 2013 21:29

FBC Compile errors with GTK

Postby guyc » Sep 18, 2013 16:38

I am trying to use GTk under windows 7 with FBC and I get the following compile errors trying to test a simple program using GTK libraries. I get the following;

fbc -w all "C:\Users\guyc\Desktop\test.bas" (in directory: c:\Program Files (x86)\FreeBASIC)
c:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -lgtk-win32-2.0
c:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -lgdk-win32-2.0
c:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -lgio-2.0
c:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -lgobject-2.0
c:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -lgthread-2.0
c:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -lglib-2.0
c:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -lgmodule-2.0
c:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -lcairo
c:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -lpango-1.0
c:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -lgdk_pixbuf-2.0
c:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -lpangocairo-1.0
c:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -latk-1.0
Compilation failed.

Here is my code:

#include once "gtk/gtk.bi"
#define NULL 0

Dim As GtkWidget Ptr win

gtk_init(NULL, NULL)

win = gtk_window_new(GTK_WINDOW_TOPLEVEL)
gtk_window_set_title(GTK_WINDOW(win), "Center")
gtk_widget_set_size_request(win, 250, 150)
gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER)

g_signal_connect(G_OBJECT(win), "destroy", _
G_CALLBACK (@gtk_main_quit), NULL)

gtk_widget_show(win)
gtk_main()

END 0

=========================
I downloaded GTK and unzipped in c:\gtk. Under c:\gtk\bin\ I see the dll's. Example: libgdk-win32-2.0-0.dll

Both the path and exact filename do not match the compile error output.
Are there other steps I need to do other than just unzip the GTK package? Is there an FBC or Windows install program I need to run on the unzipped GTK package?
TJF
Posts: 3481
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: FBC Compile errors with GTK

Postby TJF » Sep 19, 2013 6:56

The error messages are coming from the linker. It cannot find the import libraries (*.dll.a).

guyc wrote:I downloaded GTK and unzipped in c:\gtk. Under c:\gtk\bin\ I see the dll's. Example: libgdk-win32-2.0-0.dll

Which GTK+ package did you install? You also need the -dev packages (run-time is not sufficiant) for compilation:


And you've to tell the linker where to find the import libraries by using -p compiler option or by prepending to your source:

    #LIBPATH "c:\gtk\lib"


BTW:
Don't use the END 0 statement unless you really need it. In case of END your UDT DESTRUCTORs wont be executed.
guyc
Posts: 8
Joined: Aug 14, 2013 21:29

Re: FBC Compile errors with GTK

Postby guyc » Sep 20, 2013 18:39

Thanks. That solved the problem
TJF
Posts: 3481
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: FBC Compile errors with GTK

Postby TJF » Sep 21, 2013 6:10

Fine!

One more hint:

You can install both versions on the same system (in the same folder C:\gtk).

  • First, install version 2.24.
  • Then install version 3.8 and overwrite existing files.

In your source code prepend

    #DEFINE __USE_GTK3__
before

    #INCLUDE ONCE "gtk/gtk.bi"
to use the 3,x version and comment (or remove) this line to use the older 2.24 version.
JacquesInBrussels
Posts: 6
Joined: Jun 07, 2015 17:43

Re: FBC Compile errors with GTK

Postby JacquesInBrussels » Feb 20, 2019 10:40

I had the same problem than guic.
I've done exactly what TJF advised.

Mo more linker errors and the program compiles fine without any error.
BUT… When I try to run the program it gives me several popups.

System error - Impossible to execute the code because libobject-2.0-0.dll is nowhere to find. Re-installing the program might solve the problem (or something like that - I translated to English as my comp speaks French).
I have the same error and popup for libgtk-3-0.dll and for libglib-2.0-0.dll.

I tried both downloads pointed by TJF (versions 3.8 and 2.24 for GTK) and tried the two version without success.

Obviously I missed something, please help me.

Jacques

EDIT : More info : It seems that building process in GTK (as described in the readme file) was not successful for some reason.
I've redone the pkg-config in GTK 2.24 and now it seems that I can run the supplied gtk-demo.
I've done the same with the version 3.6 but it is still not happy : the console windows says "error reading pango module file"...
continuing investigations…

EDIT #2 : I reloaded the GTK3+-bundle 3.8.2-20130704 win32-RC1.zip and extracted it. I found it at http://www.tarnyko.net/repo/gtk3_build_system/ and followed the tutorial at http://www.tarnyko.net/repo/gtk3_build_system/tutorial/gtk3_tutorial.htm.
It solved the version 3.8 problem for the gtk-demo.exe.
Now to see if it solves the problem for my program…
Will keep you informed.
JacquesInBrussels
Posts: 6
Joined: Jun 07, 2015 17:43

Re: FBC Compile errors with GTK

Postby JacquesInBrussels » Feb 21, 2019 9:28

OK, everything looks to run fine now…
Except that I've found by the hard way a limitation when using FbEdit : if the compile gives no error you still will have runtime errors (.dll missing) if you use the <run> button from FbEdit. You have to run the .exe file itself directly from the directory of your project.

Rather unexpected and a bit stupid imho.

Jacques
MrSwiss
Posts: 3222
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: FBC Compile errors with GTK

Postby MrSwiss » Feb 21, 2019 14:01

JacquesInBrussels wrote:Rather unexpected and a bit stupid imho.

No, its *expected behaviour* because, the compiler uses the import lib and not
the .dll itself (lib'name'.dll.a, without [']). If the .dll is not in the 'path' or the
.exe's dir, then = not found ...

(Not at all a problem, of the IDE used!)
fxm
Posts: 9129
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FBC Compile errors with GTK

Postby fxm » Feb 21, 2019 14:16

I think Jacques' remark is also that FBEdit does not offer the ability to display runtime errors while many other IDEs (like FBIde, WinFBE, poseidonFB, Geany, ...) do.
JacquesInBrussels
Posts: 6
Joined: Jun 07, 2015 17:43

Re: FBC Compile errors with GTK

Postby JacquesInBrussels » Feb 21, 2019 17:00

Thanks for your answers.
I said "rather unexpected" as I've not the habit of mixing .dll and .exe in the same directory. A note about this behaviour would have saved me some hours of frustration.
And you're right, fxm, I said "stupid" because of the lack of infos when the .exe gives runtime errors.

How's Geany, compared to FBEdit ? I could give it a try if you are positive :)

Jacques.
Last edited by JacquesInBrussels on Feb 21, 2019 17:23, edited 1 time in total.
fxm
Posts: 9129
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FBC Compile errors with GTK

Postby fxm » Feb 21, 2019 17:07

As a recent and complete IDE, I prefer WinFBE (WinFBE_Suite.rar):
    PaulSquires wrote:WinFBE Suite includes integrated editor/compiler/tool suite. It is attached to the release and is in the 60 MB range. It contains the latest WinFBE, latest FBC nightly build, latest WinFBX (Jose's Afx includes), User Tools, and Help files. Everything is pre-configured so you should be able to simply download the archive, unzip it, and start either the 32 or 64 bit version of the editor, compile, and success.....
Last edited by fxm on Feb 21, 2019 17:28, edited 1 time in total.
JacquesInBrussels
Posts: 6
Joined: Jun 07, 2015 17:43

Re: FBC Compile errors with GTK

Postby JacquesInBrussels » Feb 21, 2019 17:26

Thanks for your answer.
I've been away from FreeBasic for years, erm… decades almost. I certainly inherited from bad habits.

Jacques.

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 2 guests