CMake compilation problem with builtin_freetype

Dear all,

I am trying to compile ROOT with CMake. When I enable the option -Dbuiltin_freetype=ON I get the following error

/local/v5-34-01/temp/lib/libfreetype.a(ftgzip.o): In function `ft_gzip_file_done': ftgzip.c:(.text+0x161): undefined reference to `inflateEnd' /local/v5-34-01/temp/lib/libfreetype.a(ftgzip.o): In function `ft_gzip_file_fill_output': ftgzip.c:(.text+0x2c3): undefined reference to `inflate' /local/v5-34-01/temp/lib/libfreetype.a(ftgzip.o): In function `ft_gzip_file_io': ftgzip.c:(.text+0x353): undefined reference to `inflateReset' /local/v5-34-01/temp/lib/libfreetype.a(ftgzip.o): In function `FT_Stream_OpenGzip': ftgzip.c:(.text+0x5a9): undefined reference to `inflateInit2_' collect2: ld returned 1 exit status gmake[2]: *** [lib/] Error 1 gmake[1]: *** [graf3d/ftgl/CMakeFiles/FTGL.dir/all] Error 2 gmake[1]: *** Waiting for unfinished jobs....

On the same machine, same check out, I can compile with the standard makefiles (–enable-builtin-freetype). Could you fix it ?
I would have created a ticket but it seems that there is a migration ongoing…


In cmake/modules/SearchInstalledSoftware.cmake, if I add “-lz” to this line :

then it works. This is NOT a patch. I have no idea of the side effects but I thought it might help you.


I’ll have a look at the proposed change. For which platform did you had the problem?


Yes sorry, I forgot to give details about the platform and version.

SLC5 - 64 bits
ROOT 5.34.01

Best regards

Please try with the attached patch. If it is fine then we will commit it to SVN.
freetypecmake.diff (2.17 KB)


Thanks for the patch. I tried to use it. Now I get the following error when activating freetype :

cmake     -DCMAKE_Fortran_COMPILER=/usr/bin/gfortran  -Dbuiltin_freetype=ON   ..
make -j8
Linking CXX shared library ../../lib/
/usr/bin/ld: cannot find -lmathtext


I cannot reproduce your problem using ROOT 5.34.05. Can you post the output of
make Graf VERBOSE=1

I understood. My patch works for 5.34.04 and later. Please remove the reference to mathtext in there to make it work for 5.34.01 or upgrade to 5.34.05.

I see. I have switched to 5.34.05. It explains why the patch file was not properly working and I had to apply by hand some changes. Now it works. Thank you for the patch and for committing it.

Best regards


I just downloaded ROOT 5.34.06 and ran into the exact same problem described here upon compilation. The fix posted in this thread earlier works well - however, it still needs to be manually applied to the three files in question.

Could you please commit the fix to SVN?

Thank you,


Hi again,

This patch really needs to be committed to Subversion. Could you do it please ?

Thank you