Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
1

Cairo: avoid using dll on windows?

Participant ,
Aug 13, 2017 Aug 13, 2017

Hi. I'm using cairo and on mac everything is fine, but on Windows I can't get my plugin to run if the cairo .dll is not next to afterFX.exe. I tried to feed visual studio a complete .lib for cairo and set it to MT instead of MD, but when I apply it AE gives an error about an invalid effect. Sounds like a dependency error from reading the previous posts.

So my question is, is it possible to give visual studio a .lib so it won't need a .dll? If so, I guess I haven't configured something correctly.

TOPICS
SDK
2.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 13, 2017 Aug 13, 2017

There are two ways of linking on most operating systems: dynamic linking and static linking. Dynamic linking means you only link with a stub with the necessary function declarations, but not with the actual implementation. To run an application with such a dynamically linked library, its shared external object file (.dll on Windows, .so on MacOS and Linux, MacOS additionally also. dylib) needs to be present at runtime.

Static linking on the other hand takes the complete implementation code of the library and directly integrates it into your application on compilation/link time. It does therefore not need a shared library/DLL present when run.

Most third party libraries on most operating systems are available (or can be compiled) as dynamic or static versions, so make sure you link to the correct one. It seems you are currently linking to the dynamic Cairo version. Unfortunately, on Windows/Visual Studio, both variants have the .lib extension.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 13, 2017 Aug 13, 2017

Thanks Toby, that's very helpful info. It seems likely that I just need to keep trying to build or download cairo as a static library and it should work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 13, 2017 Aug 13, 2017

There is a Visual Studio solution available for easier building of Cairo with Microsoft compilers (instead of MinGW). You however also need static libs of libpng and zlib. Also, there are several configuration options you can set before building that might require additional libraries. The solution does however create static Cairo libs by default. And you also have to set a specific compiler define (CAIRO_WIN32_BUILD or something) in your own application before including the Cairo header.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 13, 2017 Aug 13, 2017

Thanks, I'll try to implement that solution. This one looked promising, but I couldn't get it to work. Cairo static library - NuGet Must Haves

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 14, 2017 Aug 14, 2017

believe the define is: CAIRO_WIN32_STATIC_BUILD

from this article: GitHub - DomAmato/Cairo-VS: Solution for compiling Cairo on Windows 32/64 bit

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 14, 2017 Aug 14, 2017

Yes, that is the actual define name.

This morning I tried just for fun to create a static lib build of Cairo with Visual Studio and it seemed to work without problems with various backends (image buffer, PNG, SVG, PDF, PS, GDI, etc.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 14, 2017 Aug 14, 2017

I could also compile a static Cairo lib for you if you want.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 15, 2017 Aug 15, 2017

Thanks for your generous offer Toby, though I managed to get it working on windows with that previous link. On mac though, the .plugin bundle doesn't change size regardless of using the static (libcairo.a) or the dynamic (libcairo.dylib). I added libcairo.a as a framework to my target. Do you think this is my xCode settings being wrong, or my building of the libcairo.a which is wrong?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 15, 2017 Aug 15, 2017

On Mac and Linux, things can sometimes be a bit different. I assume your static libcairo.a file still uses some external dynamic libraries so you won't see a change in size. But it could be for some other reasons as well. Maybe best to try to test it on a vanilla Mac from a user.

Be aware that Cairo is a quite complex library with various functionality that can be linked in at compile time (e.g. Freetype support) and particularly the various backends that require additional third party libraries, in addition to its own base library pixman.

You should probably compile a version of Cairo only with the backends activated that you need for your functionality.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 15, 2017 Aug 15, 2017

I think you're right. If I use cairo.a and delete the cairo.dylib, it builds but doesn't work in AE so I'm guessing it's referencing the dylib.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 28, 2021 Nov 28, 2021
LATEST

I dont think this solution works anymore. I want to use a non-vcpkg method for libcairo.lib - the default meson method builds libcairo.a on windows. Has anyone managed to build libcairo.lib on windows recently.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 03, 2020 Mar 03, 2020

Hello Toby

 

I know that's an old thread, but I was having the same problem with the dynamic cairo library and am trying to compile a static version of it following the instructions linked below from JamesWhiffin555

However I am not sure about the "static libs of libpng and zlib": Do they have to be included in my project, or need to be part of the solution used to complie the static cairo/pixman?

Many thanks in advance
Dani

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 03, 2020 Mar 03, 2020

Hi Dani,

Cairo relies on libpng (which in turn relies on zlib) for PNG support. Which means just to compile Cairo with PNG support (no matter if static or dynamic), you need to have the compiled libraries for these two libs as well already, in either dynamic or (preferrably) static format. So the usual procedure is to have separate solutions for zlib and libpng, which output static libs. Then you compile the Cairo static lib. And in your After Effects plugin project, you include the Cairo header and link to all of these static libs in your project settings.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 03, 2020 Mar 03, 2020

Crystal clear
Many thanks Toby, I'll give it a shot

Best

Dani

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines