CMake unable to find Freetype in Ubuntu

Problems building or running the engine, queries about how to use features etc.
Post Reply
Jamie_Edwards
Gnoblar
Posts: 10
Joined: Tue Jun 17, 2014 10:57 pm

CMake unable to find Freetype in Ubuntu

Post by Jamie_Edwards »

Hi guys,

While trying to configure the Ogre SDK in Ubuntu 14.04, I get the following error from CMake:

Code: Select all

CMake Error at CMake/Utils/MacroLogFeature.cmake:100 (MESSAGE):
  -----------------------------------------------------------------------------
  -- The following REQUIRED packages could NOT be located on your system.
  -- Please install them before continuing this software installation.
  -- If you are in Windows, try passing -DOGRE_DEPENDENCIES_DIR=<path to
  dependencies>
 -----------------------------------------------------------------------------
  + freetype: Portable font engine
 -----------------------------------------------------------------------------
Call Stack (most recent call first):
  CMake/Dependencies.cmake:234 (MACRO_DISPLAY_FEATURE_LOG)
  CMakeLists.txt:194 (include)
Configuring incomplete, errors occurred!
I have Freetype already installed, under /usr/include/freetype2/

How can I get CMake to point to, and find, Freetype??

Thanks,

Jamie
lscandolo
Gnoblar
Posts: 17
Joined: Tue Apr 30, 2013 5:17 pm
x 1

Re: CMake unable to find Freetype in Ubuntu

Post by lscandolo »

You can install cmake-gui (package is cmake-qt-qui in the newest distros) and use it to manually set the corresponding variables.
Nevertheless I never had a problem with freetype on ubuntu, did you install it from the regular repos ? (package should be libfreetype6-dev)

*EDIT:

The variables you need to set (in 1.9) are FREETYPE_FT2BUILD_INCLUDE_DIR, FREETYPE_INCLUDE_DIR, FREETYPE_LIBRARY_DBG and FREETYPE_LIBRARY_REL.
The first 2 should point to your include directory, in your case /usr/include/freetype2/
The last two should point to the library itself. In ubuntu (depending on your distribution/architecture) they should be in /usr/lib/libfreetype.so or /usr/lib/[i386-linux-gnu / x86_64-linux-gnu]/libfreetype.so
If you have the debug package installed, you should point the FREETYPE_LIBRARY_DBG to the debug version of the library.
Jamie_Edwards
Gnoblar
Posts: 10
Joined: Tue Jun 17, 2014 10:57 pm

Re: CMake unable to find Freetype in Ubuntu

Post by Jamie_Edwards »

Ok, so that went fine, thank you... BUT... I get a new error during the "make" command:

Code: Select all

Linking CXX executable ../../bin/OgreXMLConverter
../../lib/libOgreMain.so.1.8.1: undefined reference to `FT_New_Memory_Face'
../../lib/libOgreMain.so.1.8.1: undefined reference to `FT_Load_Char'
../../lib/libOgreMain.so.1.8.1: undefined reference to `FT_Init_FreeType'
../../lib/libOgreMain.so.1.8.1: undefined reference to `FT_Done_FreeType'
../../lib/libOgreMain.so.1.8.1: undefined reference to `FT_Set_Char_Size'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/OgreXMLConverter] Error 1
make[1]: *** [Tools/XMLConverter/CMakeFiles/OgreXMLConverter.dir/all] Error 2
make: *** [all] Error 2
Any ideas?
lscandolo
Gnoblar
Posts: 17
Joined: Tue Apr 30, 2013 5:17 pm
x 1

Re: CMake unable to find Freetype in Ubuntu

Post by lscandolo »

That means that your libOgreMain (the core ogre library) has a declared symbol (a freetype function taken from the freetype headers) for which there is no actual implementation in any of the libraries the executable is linking against.

So, either you're linking to a wrong freetype library that doesn't have those symbols defined or the make script is not actually trying to link against the library (basically there is no -lfreetype flag).

So, you can check that the library you set in the cmake configuration has those symbols (by doing nm -D libfreetype.so | grep FT_New_Memory_Face), and if that is actually there then you can check that the make script is actually trying to link with the -lfreetype flag set (you can check this by doing 'make VERBOSE=1' to see the actual commands being run).
Jamie_Edwards
Gnoblar
Posts: 10
Joined: Tue Jun 17, 2014 10:57 pm

Re: CMake unable to find Freetype in Ubuntu

Post by Jamie_Edwards »

The FT_New_Memory_Face is where it's supposed to be.

Make on the other hand is not using the -lfreetype flag as far as I can see though.
Jamie_Edwards
Gnoblar
Posts: 10
Joined: Tue Jun 17, 2014 10:57 pm

Re: CMake unable to find Freetype in Ubuntu

Post by Jamie_Edwards »

anyone got any ideas on how I could fix this?
lscandolo
Gnoblar
Posts: 17
Joined: Tue Apr 30, 2013 5:17 pm
x 1

Re: CMake unable to find Freetype in Ubuntu

Post by lscandolo »

Well, you can always edit the link flags to explicitly add the freetype libs. With cmake-gui edit the link flags definition and add "-L[dir-where-libfreetype.so lives] -lfreetype". That should add the freetype library to everything you build.
Spekoda
Halfling
Posts: 40
Joined: Wed Jun 12, 2013 5:38 pm
Location: Finland
x 2

Re: CMake unable to find Freetype in Ubuntu

Post by Spekoda »

Jamie_Edwards wrote:anyone got any ideas on how I could fix this?
In ubuntu I had to edit cmake files and add correct paths, because something wasn't installed where cmake wanted it to be. Nothing new with cmake.
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: CMake unable to find Freetype in Ubuntu

Post by c6burns »

Yeah the world is still waiting for GandalfMake where it just finds everything by magic regardless of what arbitrary changes your distro makes. Until then ...
Post Reply