Help needed with Cairo / Graphics lazarus / 39-Graphics ---------------------------------------------------------------------- AL · 2024-03-23 21:15 I am trying to "translate" a program using graphics to Lazarus/FPC.  The program is written in C and use Cairo as a graphic tool.  I was thinking that using Cairo in FPC would be the easiest to do.  So far all my attempts to get Cairo working are unsuccessfull. I tried to follow this    https://forum.lazarus.freepascal.org/index.p hp/topic,57657.msg471085.html#msg471085 but it does not work for me. It gives an error right at the start.   I copied the LibCairo-2.dll in system32. I am using Laz 3.2 in Windows 10. Is Cairo really working in Windows and FPC? Any help would be appreciated. Thanks. ---------------------------------------------------------------------- d-_-b · 2024-03-23 22:16 Quote from: AL on March 23, 2024, 10:15:03 pmIs Cairo really working in Windows and FPC? I can confirm that I could download cairo-pascal-tutorial-source.zip open cairo_071.lpr and compile and execute cairo_071.exe on Windows 10 using Lazarus 3.2 (rev lazarus_3_2) FPC 3.2.2 x86_64-win64-win32/win64. But I had to use MSYS2and pacman -S mingw-w64-x86_64-cairo to get all the needed dll's as noted below. Quote from: AL on March 23, 2024, 10:15:03 pmAny help would be appreciated. Run your compiled exe from explorer.exe or cmd.exe and then you will see you need more then just LibCairo-2.dll. For example from Topic: What You See Drawing Canvas vs Printing/PDF (CairoCanvas): Here is a definite list of dlls needed for you application to work     libcairo-2.dll     libglib-2.0-0.dll     libgmodule-2.0-0.dll     libgobject-2.0-0.dll     libpango-1.0-0.dll     libpangocairo-1.0-0.dll     libpangowin32-1.0-0.dll     libpng12-0.dll     zlib1.dll So i wanted to do a lld libcairo-2.dll and it seems on windows you must use ntldd so i installed it pacman -S mingw-w64-x86_64-ntldd in MSYS2 and grepped the following list for you. $ ntldd -R '/c/msys64/mingw64/bin/libcairo-2.dll' | grep -v 'Windows' | grep -v 'not found'         libgcc_s_seh-1.dll => C:\msys64\mingw64\bin\libgcc_s_seh-1.dll (0x0000016bb6cd0000)          libwinpthread-1.dll => C:\msys64\mingw64\bin\libwinpthread-1.dll (0x0000016bb6d10000)         libstdc++-6.dll => C:\msys64\mingw64\bin\libstdc++-6.dll (0x0000016bb7370000)         libfontconfig-1.dll => C:\msys64\mingw64\bin\libfontconfig-1.dll (0x0000016bb6d10000)          libexpat-1.dll => C:\msys64\mingw64\bin\libexpat-1.dll (0x0000016bb6e60000)          libiconv-2.dll => C:\msys64\mingw64\bin\libiconv-2.dll (0x0000016bb7640000)          libintl-8.dll => C:\msys64\mingw64\bin\libintl-8.dll (0x0000016bb7610000)         libfreetype-6.dll => C:\msys64\mingw64\bin\libfreetype-6.dll (0x0000016bb6e60000)          libbz2-1.dll => C:\msys64\mingw64\bin\libbz2-1.dll (0x0000016bb6cd0000)          libbrotlidec.dll => C:\msys64\mingw64\bin\libbrotlidec.dll (0x0000016bb6cd0000)           libbrotlicommon.dll => C:\msys64\mingw64\bin\libbrotlicommon.dll (0x0000016bb7370000)          libharfbuzz-0.dll => C:\msys64\mingw64\bin\libharfbuzz-0.dll (0x0000016bb7370000)           libglib-2.0-0.dll => C:\msys64\mingw64\bin\libglib-2.0-0.dll (0x0000016bb74b0000)            libpcre2-8-0.dll => C:\msys64\mingw64\bin\libpcre2-8-0.dll (0x0000016bb7610000)           libgraphite2.dll => C:\msys64\mingw64\bin\libgraphite2.dll (0x0000016bb74b0000)         libpixman-1-0.dll => C:\msys64\mingw64\bin\libpixman-1-0.dll (0x0000016bb6e60000)         libpng16-16.dll => C:\msys64\mingw64\bin\libpng16-16.dll (0x0000016bb7370000)         zlib1.dll => C:\msys64\mingw64\bin\zlib1.dll (0x0000016bb6cd0000) Hope it helps, ---------------------------------------------------------------------- Roland57 · 2024-03-24 04:30 @d-_-b Thank you for this detailed information. Another way to get Cairo binaries on Windows is to install a software using Cairo, like Gimp or Inkscape. ---------------------------------------------------------------------- AL · 2024-03-24 14:57 Thank you very much, this should get me going. But: does that mean that to distribute my exe I will need to include all these dll also. Is there a way to get them in the compiled binary? ---------------------------------------------------------------------- domasz · 2024-03-24 15:25 No. But you should be able to put them in your exe as resources and extract to temp dir. ---------------------------------------------------------------------- jamie · 2024-03-24 15:36 Hmm,  the Cario package in the FPC folder does nothing for you? ---------------------------------------------------------------------- AL · 2024-03-24 19:56 No the prog compile fine but I always get an error at start. Unable to trace, even F7 give the error. The example given ( version no) does not give an error but the result give 0.0.0 which is probably wrong ---------------------------------------------------------------------- Roland57 · 2024-03-24 21:27 @AL You probably already know it, but there are 32-bit and 64-bit DLL. You have to pay attention to that. ---------------------------------------------------------------------- AL · 2024-03-25 14:00 Quote from: d-_-b on March 23, 2024, 11:16:14 pmI can confirm that I could download cairo-pascal-tutorial-source.zip open cairo_071.lpr and compile and execute cairo_071.exe on Windows 10 using Lazarus 3.2 (rev lazarus_3_2) FPC 3.2.2 x86_64-win64-win32/win64. MacAfee antivirus would not let me download this file as it detect a threat in the file. ---------------------------------------------------------------------- Roland57 · 2024-03-25 14:38 Quote from: AL on March 25, 2024, 03:00:38 pmMacAfee antivirus would not let me download this file as it detect a threat in the file. Maybe because I had put http instead of https in the link. Fixed now. By the way, the file contains only Pascal source code and PNG pictures. ---------------------------------------------------------------------- AL · 2024-03-27 13:35 Update: I made progress. I could run a simple Cairo example. I had to install several DLL as suggested by d-_-b and inspired by Roland57 demos I could draw it in a paint box.  However, when writing text in a Paintbox with Cairo the text was upside down because of the Translate() and Scale() Cairo commands he is using.  Using the Form.canvas directly solved that.  I will try a frame in the form and see if it is still OK. The Cairo unit of FPC is referencing LibCairo2.dll only, but LibCairo2.dl on its own is referencing several others Dlls. I still need to find how to include all these Dlls as resources and how to use them from resources. Thanks for the help! ---------------------------------------------------------------------- Roland57 · 2024-03-28 11:25 Quote from: AL on March 27, 2024, 02:35:10 pmThe Cairo unit of FPC is referencing LibCairo2.dll only, but LibCairo2.dl on its own is referencing several others Dlls. Maybe you should take a look to this repository. If I well understood, it's a Cairo DLL without dependencies (not tested).