Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error: ft2build.h: No such file or directory when building OpenSUSE Tumbleweed with Singularity def file #86

Closed
bdklahn opened this issue Jul 17, 2021 · 10 comments

Comments

@bdklahn
Copy link

bdklahn commented Jul 17, 2021

That header and the pkg-config file are there.
/usr/include/freetype2/ft2build.h
/usr/lib64/pkgconfig/freetype2.pc

And pkg-config . . .

> pkg-config --version
1.7.3

I've tried to manually . . .
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig
. . . before the . . .
Rscript -e 'install.packages("shiny", repos="http://cran.r-project.org", dependencies = TRUE)'
. . . which must need ragg for something.

The rest of shiny (and the other R packages) install, except for units.

Below is the full message:

* installing *source* package 'ragg' ...
** package 'ragg' successfully unpacked and MD5 sums checked
** using staged installation
Using PKG_CFLAGS=
Using PKG_LIBS=-lfreetype -lpng16 -ltiff -lz -ljpeg -lbz2
-----------------------------[ ANTICONF ]-------------------------------
Configuration failed to find one of freetype2 libpng libtiff-4. Try installing:
 * deb: libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev (Debian, Ubuntu, etc)
 * rpm: freetype-devel libpng-devel libtiff-devel libjpeg-turbo-devel (Fedora, CentOS, RHEL)
 * csw: libfreetype_dev libpng16_dev libtiff_dev libjpeg_dev (Solaris)
If freetype2 libpng libtiff-4 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a freetype2 libpng libtiff-4.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
<stdin>:1:10: fatal error: ft2build.h: No such file or directory
compilation terminated.
--------------------------------------------------------------------
ERROR: configuration failed for package 'ragg'
* removing '/usr/lib64/R/library/ragg'
@bdklahn
Copy link
Author

bdklahn commented Jul 17, 2021

I think I may have found the issue: It might actually be libtiff-4.

The code in the configure file makes it a little confusing, by combining the three libs together in the test to see if there are pc files.

ragg/configure

Line 10 in adf5f06

PKG_CONFIG_NAME="freetype2 libpng libtiff-4"

ragg/configure

Line 25 in adf5f06

pkg-config --exists ${PKG_CONFIG_NAME} >/dev/null 2>&1 && R_HAS_PKG_CONFIG=1;

Then, when the last of the cases (use pkg-conf) is never met, things never appear to be set up right for ANY of the libraries.

ragg/configure

Lines 42 to 55 in adf5f06

elif [ $R_HAS_PKG_CONFIG ]; then
echo "Found pkg-config cflags and libs!"
PKG_CFLAGS=`pkg-config --cflags ${PKG_CONFIG_NAME}`
PKG_LIBS=`pkg-config --libs ${PKG_CONFIG_NAME}`
PKG_LIBS="$PKG_LIBS -ljpeg"
# Test configuration
printf "$PKG_TEST_HEADER" | ${CC} ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} -E -xc - >/dev/null 2>&1 || R_CONFIG_ERROR=1;
# if the above errors try using --static
if [ $R_CONFIG_ERROR ]; then
PKG_LIBS=`pkg-config --libs --static ${PKG_CONFIG_NAME}`
fi
unset R_CONFIG_ERROR
fi

(I never saw any of those echo statements in the output)

So it fails the test as soon as it hits the first library (freetype2), even though it is one of the two which is installed.

ragg/configure

Lines 61 to 62 in adf5f06

# Test configuration
printf "$PKG_TEST_HEADER" | ${CC} ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} -E -xc - >/dev/null 2>configure.log

I'm not even sure I can even install ragg on my system, since it looks like I might only have "libtiff5" available.
I guess I'll see what I get, when I install libtiff-devel.

Ah . . . I guess it should work:

Information for package libtiff-devel:
--------------------------------------
Repository     : openSUSE:Tumbleweed
Name           : libtiff-devel
Version        : 4.3.0-1.2
Arch           : x86_64
Vendor         : openSUSE
Installed Size : 157.2 KiB
Installed      : No
Status         : not installed
Source package : tiff-4.3.0-1.2.src
Summary        : Development Tools for Programs which will use the libtiff Library
Description    : 
    This package contains the header files and static libraries for
    developing programs which will manipulate TIFF format image files using
    the libtiff library.

@bdklahn
Copy link
Author

bdklahn commented Jul 17, 2021

Looks like this is resolved (I don't get that ERROR any more).

@GuohuaZhu
Copy link

Thank you for your detailed introduction. I also encountered the same error during the installation process. However, after reading your answer, I still don't know how to solve the problem. Can you provide your detailed solution code. Thank you so much!

@GuohuaZhu
Copy link

I don't know what I did, but when I reinstalled it worked. Sorry for disturbing。

@ramiromagno
Copy link

hey,

I also had the same problem on Ubuntu 20.04.

This solved it for me:

sudo apt install libtiff-dev

@lumtvn
Copy link

lumtvn commented Oct 23, 2022

hey,

I also had the same problem on Ubuntu 20.04.

This solved it for me:

sudo apt install libtiff-dev

This worked for me. How did you reach this solution?

@ramiromagno
Copy link

Sorry I can't recall anymore...

@WorksAtAUni
Copy link

This test still fails improperly and provides distracting information.... if one is missing, all are blamed and it left to the installer to figure it out. It is all or nothing.

Also, Looks like you updated the code in the branch, but really something like this would be useful (based on code in this thread). Just a hacky sorta of example

R is frustrating enough.

PKG_CONFIG_NAME="freetype2 libpng libtiff-4 whatever" 
missing_libs=()
for lib in ${PKG_CONFIG_NAME}
do
   ! pkg-config --exists $lib  && missing_libs+=($lib) && R_HAS_PKG_CONFIG=1
done

echo ${missing_libs[@]}

# and then do something nice with $missing_libs since it only contains the missing libs.

@moefear85
Copy link

ft2build.h is a file located in the folder /usr/include/freetype2. If your IDE/compiler can't find it, then either you don't have freetype2 development files installed, or you haven't setup the include path for the IDE/compiler correctly, you would have to add /usr/include/freetype2 to it. To install the needed development files on ubuntu:
sudo apt install libfreetype-dev.

@stephenmjay
Copy link

For what it's worth, I had to run the command more than once before it took (I'm not going to try and explain)
sudo apt install libfreetype-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants