freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft] Linking against freetype in Linux


From: Kris
Subject: [ft] Linking against freetype in Linux
Date: Wed, 26 Jun 2019 11:12:45 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2

Hi everyone!

I'm fairly certain every question about g++ linking of the freetype lib has been asked a million-times already, but after a number of solid evenings on this I'm now crying into my keyboard because I just don't seem to be able to get it to work. :(

I've built a virtual-machine with an Ubuntu desktop install (18.04.2) so I can freely start messing with packages without worrying about breaking my main developer Linux box.

I've used apt to install g++, make, libfreetype6-dev, freetype2-demos, libfreetype6, and pkg-config packages.

My minimal test.cpp file looks like this:

(begin)
#include <ft2build.h>
#include FT_FREETYPE_H

int main(int argc, char** argv)
{
        FT_Library library;
        FT_Error error = FT_Init_FreeType(&library);
        if (error)
        {
                printf("Error occurred during init.\n");
        }
        else
        {
                printf("Initialised OK!\n");
        }

        return 0;
}
(end)

And I'm attempting to compile it with:

   g++ `pkg-config freetype2 --cflags --libs` test.cpp

... but at the linking stage, I'm still getting "undefined reference to FT_Init_FreeType". :(

If I insert the -c switch so that it ONLY compiles but doesn't link, then it works fine. So I know the header files are being included correctly.

The pkg-config command in the backticks produces:

-I/usr/include/freetype2 -I/usr/include/libpng16 -lfreetype

... so I know that pkg-config is working.

I know that the "-lfreetype" must be finding the library correctly, because if I add a library name which I know does NOT exist, then I get an error as I'd expect.

So the linker seems to be able to find the freetype library ... but still doesn't find the symbol FT_Init_FreeType within it!

The library file is in /lib/x86_64-linux-gnu/, but adding a switch of "-L/lib/x86_64-linux-gnu/" makes no difference.

I'm not sure what to try next. Does anyone have any suggestions?

All the best, and HUGE thanks in advance,

Kris.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]