Cairo Clock Example

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
Roland Chastain
Posts: 1007
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Cairo Clock Example

Post by Roland Chastain »

jj2007 wrote:Do you need to download something to build the examples above?

FreeBasic\bin\win32\ld.exe: cannot find -lcairo
To build the examples, you need libcairo.dll.a (which you can found in this package).

To run the examples, you will need some *.dll (idem).
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Cairo Clock Example

Post by MrSwiss »

jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Cairo Clock Example

Post by jj2007 »

Thanks. I tried https://www.cairographics.org/download/ but it looks horribly complicated for a Windows user:

you can have Cairo installed on Win32 as a side-effect of installing GTK+
You probably want at least the zlib, cairo, and libpng run-time archives (you can search on those strings to find them in the page). That should be it

https://www.gtk.org/download/windows.php
The easiest way to install GTK+ and its dependencies in binary form is through the MSYS2 project. MSYS2 provides a UNIX-like development environment for Windows. It provides packages for many software applications and libraries, including the GTK+ stack. These packages are installed using the pacman package manager.

Sorry, but that sounds like many hours of searching and asking questions in specialised forums. No thanks.
Roland Chastain
Posts: 1007
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Cairo Clock Example

Post by Roland Chastain »

@jj2007

Please read my previous answer. All the files you need are in the package that I provided. Actually it isn't as complicated as it sounds.
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Cairo Clock Example

Post by lizard »

Roland Chastain wrote:I should update the package, with the latest examples written by dodicat, by you and by me (with your permission of course). :).
Everything i post in this forum is considered public domain and can be used from anybody for anything. :-)
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Cairo Clock Example

Post by lizard »

Tried to integrate a cairo context in a wx-c main window but found it difficult. In Gtk it seems easier. But as i almost finished the wx-c version it would be waste to stop now. Although wx-c is limited to 32 bit in current version. After that i can still do a gtk version and a pure FB version with "simple gui". Like the idea not to need any other libs to be installed. And that would be the fastest, i suppose.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Cairo Clock Example

Post by jj2007 »

Roland Chastain wrote:Please read my previous answer. All the files you need are in the package that I provided. Actually it isn't as complicated as it sounds.
OK, I've extracted your archive to FreeBasic\lib\Cairo
Still no luck, ld.exe: cannot find -lcairo
I suppose the files have to be moved to some specific folders?
Roland Chastain
Posts: 1007
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Cairo Clock Example

Post by Roland Chastain »

jj2007 wrote:OK, I've extracted your archive to FreeBasic\lib\Cairo
Still no luck, ld.exe: cannot find -lcairo
I suppose the files have to be moved to some specific folders?
The simplest solution is to let all the files (*.dll, *.dll.a *.bas) in the same folder. Otherwise the right place for libcairo.dll.a is in FBC\lib\win32.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Cairo Clock Example

Post by jj2007 »

Roland Chastain wrote:The simplest solution is to let all the files (*.dll, *.dll.a *.bas) in the same folder. Otherwise the right place for libcairo.dll.a is in FBC\lib\win32.
Yep, it works now, thanks. So the only really needed file is libcairo.dll.a, and it must sit in FreeBasic\lib\win32 - good to know.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Cairo Clock Example

Post by MrSwiss »

jj2007 wrote:So the only really needed file is libcairo.dll.a, and it must sit in FreeBasic\lib\win32 - good to know.
Not quite! The .dll also has to be in the ExePath (aka: the same place as the .exe),
otherwise, the application will crash ... (needed at run-time!).
(That's the main difference, between Static/Dynamic linked lib's!)
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Cairo Clock Example

Post by jj2007 »

Oh really?

Code: Select all

FreeBasic\lib\win32\libcairo.dll.a
FreeBasic\tmp\TmpFb.exe
No crash, it works just fine.
Roland Chastain
Posts: 1007
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Cairo Clock Example

Post by Roland Chastain »

jj2007 wrote:Oh really?

Code: Select all

FreeBasic\lib\win32\libcairo.dll.a
FreeBasic\tmp\TmpFb.exe
No crash, it works just fine.
It is certainly because the *.dll are somewhere on your computer. Maybe you have a software installed which came with these files.

For example, on my computer, libcairo-2.dll is in many places.
C:\GTK3\bin\libcairo-2.dll
C:\Program Files (x86)\Inkscape\libcairo-2.dll
C:\Program Files\GIMP 2\32\bin\libcairo-2.dll
You could use a software like Everything to learn where are your files. I use it every day. ;)
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Cairo Clock Example

Post by lizard »

Code: Select all

...
/usr/lib/i386-linux-gnu/libcairo.a
/usr/lib/i386-linux-gnu/libcairo.so
Yes, and for Linux they are libcairo.a to compile and libcairo.so to run. But because they are installed automatically deep in the filesystem with the mentioned apt-get install, the user could give his source code to others and forgets that it depends on files he has not even seen before...
Last edited by lizard on May 06, 2018 10:04, edited 1 time in total.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Cairo Clock Example

Post by jj2007 »

Roland Chastain wrote:Maybe you have a software installed which came with these files.
MySQL perhaps (using C:\libcairo*)?

Code: Select all

libcairo.dll                       	C:\Program Files\MySQL\MySQL Workbench 6.3 CE     1.01 MB  	31.01.17 15:31
libcairo.dll.a                     	C:\FreeBasicFreeBasic\lib\win32                   215 kB   	27.12.10 18:46
libcairo-2.dll                     	C:\Program Files (x86)\FreeArc\bin                776 kB      04.06.09 13:20
libcairo-2.dll                     	C:\FreeBasicFreeBasic\lib\win32\Cairo          	909 kB   	21.09.13 15:46
libcairo-gobject-2.dll             	C:\FreeBasicFreeBasic\lib\win32\Cairo          	54 kB    	21.09.13 15:46
libcairo-gobject.dll.a             	C:\FreeBasicFreeBasic\lib\win32\Cairo          	24 kB    	27.12.10 18:47
libcairo-script-interpreter-2.dll  	C:\FreeBasicFreeBasic\lib\win32\Cairo          	208 kB   	21.09.13 15:46
libcairo-script-interpreter.dll.a  	C:\FreeBasicFreeBasic\lib\win32\Cairo          	60 kB    	27.12.10 18:47
You could use a software like Everything to learn where are your files. I use it every day. ;)
My file manager can do that (FreeCommander), but it's also just four lines of code to find them (this one with C:\*cairo*.dll*):

Code: Select all

1062400  31.01.2017  14:31:46	C:\Program Files\MySQL\MySQL Workbench 6.3 CE\libcairo.dll
603048	28.02.2013  12:49:26	C:\Program Files (x86)\Cisco\JabberVideo\cairo.dll
794572	04.06.2009  13:20:40	C:\Program Files (x86)\FreeArc\bin\libcairo-2.dll
80812 	04.06.2009  13:20:42	C:\Program Files (x86)\FreeArc\bin\libpangocairo-1.0-0.dll
930610	21.09.2013  15:46:17	C:\FreeBasic\lib\win32\Cairo\libcairo-2.dll
54463 	21.09.2013  15:46:17	C:\FreeBasic\lib\win32\Cairo\libcairo-gobject-2.dll
24286 	27.12.2010  17:47:09	C:\FreeBasic\lib\win32\Cairo\libcairo-gobject.dll.a
212454	21.09.2013  15:46:17	C:\FreeBasic\lib\win32\Cairo\libcairo-script-interpreter-2.dll
60518 	27.12.2010  17:47:20	C:\FreeBasic\lib\win32\Cairo\libcairo-script-interpreter.dll.a
119908	21.09.2013  15:46:54	C:\FreeBasic\lib\win32\Cairo\libpangocairo-1.0-0.dll
219638	27.12.2010  17:46:53	C:\FreeBasic\lib\win32\libcairo.dll.a
8294  	31.01.2016  12:09:14	C:\FreeBasic\lib\win32\libcdcairo.dll.a
2272	  31.01.2016  12:09:14	C:\FreeBasic\lib\win32\libcdluacairo52.dll.a
I wonder, though, why the (more recent) SQL version is 4* libcairo.dll.a - 1062400 vs 219638 bytes. Is the .dll.a extension exactly the same as *.dll?
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Cairo Clock Example

Post by caseih »

jj2007 wrote:Is the .dll.a extension exactly the same as *.dll?
No. As far as I know the .dll.a files are stubs that help the linker link against the .dll. They might be the Mingw-equivalent of Visual Studio's .def.
Post Reply