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

C++ error during installation with freetype2 2.13.3 #170

Closed
ChangqingW opened this issue Aug 15, 2024 · 18 comments · Fixed by #172
Closed

C++ error during installation with freetype2 2.13.3 #170

ChangqingW opened this issue Aug 15, 2024 · 18 comments · Fixed by #172

Comments

@ChangqingW
Copy link

Encountered the following error during installation:

agg/src/agg_font_freetype.cpp: In instantiation of ‘bool agg::decompose_ft_outline(const FT_Outline&, bool, const trans_affine&, PathStorage&) [with PathStorage = path_storage_integer<int, 6>; FT_Outline = FT_Outline_]’:
agg/src/agg_font_freetype.cpp:1071:48:   required from here
 1071 |                         if(decompose_ft_outline(m_cur_face->glyph->outline,
      |                            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1072 |                                                 m_flip_y,
      |                                                 ~~~~~~~~~
 1073 |                                                 m_affine,
      |                                                 ~~~~~~~~~
 1074 |                                                 m_path32))
      |                                                 ~~~~~~~~~
agg/src/agg_font_freetype.cpp:182:35: error: invalid conversion from ‘unsigned char*’ to ‘char*’ [-fpermissive]
  182 |             tags  = outline.tags  + first;
      |                     ~~~~~~~~~~~~~~^~~~~~~
      |                                   |
      |                                   unsigned char*
agg/src/agg_font_freetype.cpp: In instantiation of ‘bool agg::decompose_ft_outline(const FT_Outline&, bool, const trans_affine&, PathStorage&) [with PathStorage = path_storage_integer<short int, 6>; FT_Outline = FT_Outline_]’:
agg/src/agg_font_freetype.cpp:1092:48:   required from here
 1092 |                         if(decompose_ft_outline(m_cur_face->glyph->outline,
      |                            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1093 |                                                 m_flip_y,
      |                                                 ~~~~~~~~~
 1094 |                                                 m_affine,
      |                                                 ~~~~~~~~~
 1095 |                                                 m_path16))
      |                                                 ~~~~~~~~~
agg/src/agg_font_freetype.cpp:182:35: error: invalid conversion from ‘unsigned char*’ to ‘char*’ [-fpermissive]
  182 |             tags  = outline.tags  + first;
      |                     ~~~~~~~~~~~~~~^~~~~~~
      |                                   |
      |                                   unsigned char*
make: *** [/usr/lib64/R/etc/Makeconf:204: agg/src/agg_font_freetype.o] Error 1
ERROR: compilation failed for package ‘ragg’
* removing ‘/home/q/R/x86_64-pc-linux-gnu-library/4.4/ragg’

The downloaded source packages are in
        ‘/tmp/RtmpUzUHT4/downloaded_packages’
Warning message:
In install.packages("ragg") :
  installation of package ‘ragg’ had non-zero exit status
> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Arch Linux

Matrix products: default
BLAS:   /usr/lib/libblas.so.3.12.0
LAPACK: /usr/lib/liblapack.so.3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: Australia/Melbourne
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_4.4.1 tools_4.4.1

I believe I had all the required libraries installed:

> pacman -Q | grep -P '(freetype2)|(libpng)|(libtiff)|(libjpeg)'
freetype2 2.13.3-1
libjpeg-turbo 3.0.3-1
libpng 1.6.43-1
libtiff 4.6.0-5
@ChangqingW ChangqingW changed the title C++ error during installation C++ error during installation with freetype2 2.13.3-1 Aug 15, 2024
@ChangqingW
Copy link
Author

ChangqingW commented Aug 15, 2024

Looks like with the newer version of freetype2, tags from FT_Outline changed from char* to unsigned char*, I wonder if this is causing the error.
https://sourceforge.net/projects/freetype/files/freetype2/2.13.3/

CHANGES BETWEEN 2.13.2 and 2.13.3 (2024-Aug-11)

  I. IMPORTANT CHANGES

  - Some  fields  in  the  `FT_Outline` structure  have been   changed
    from signed  to unsigned type,  which  better reflects  the actual
    usage.   It  is  also  an  additional  means  to  protect  against
    malformed input.

https://freetype.org/freetype2/docs/reference/ft2-outline_processing.html#ft_outline
https://freetype.sourceforge.net/freetype2/docs/reference/ft2-outline_processing.html#FT_Outline

@ChangqingW ChangqingW changed the title C++ error during installation with freetype2 2.13.3-1 C++ error during installation with freetype2 2.13.3 Aug 15, 2024
@ChangqingW
Copy link
Author

tags = outline.tags + first;

-            tags  = outline.tags  + first;
+            tags  = (char*)outline.tags  + first;

Casting outline.tags to char* seems to have resolved this for me.

@joshweiland
Copy link

Until/unless freetype2 is updated, is there a way to get around this error in R? This is blocking installation of tidyverse as well. I'm not a C++ user, but I can code - do I have to learn to hack into freetype2? Is there a way to modify the ragg installation to get around this? Sorry if this is not an appropriate question. Also, does anyone know an order of magnitude timeline for something like this to be updated in a downstream code like freetype2? Days, weeks, months? Thanks!

@emersonhsieh
Copy link

Until/unless freetype2 is updated, is there a way to get around this error in R? This is blocking installation of tidyverse as well. I'm not a C++ user, but I can code - do I have to learn to hack into freetype2? Is there a way to modify the ragg installation to get around this? Sorry if this is not an appropriate question. Also, does anyone know an order of magnitude timeline for something like this to be updated in a downstream code like freetype2? Days, weeks, months? Thanks!

Freetype was updated to 2.13.3 at commit Homebrew/homebrew-core@28e294c. Its immediate parent is Homebrew/homebrew-core@d28afc3, which contains the script to install freetype version 2.13.2.

To install freetype version 2.13.2, download the previous installation script and manually install with brew:

curl -L https://raw.githubusercontent.com/Homebrew/homebrew-core/d28afc3bfdb5d24eab02157bfffcc9e17ed6666c/Formula/f/freetype.rb > freetype.rb && brew install freetype.rb

Then install.packages("ragg") should work.

@joshweiland
Copy link

Thanks for the tip. I have run the code for Freetype as above, and it seems to work - it says that 2.13.2 is installed. I still get the same error when trying to install ragg, however. When I run freetype-config --version, it says 26.2.20, which the internet says is 2.13.3. So though it looks like 2.13.2 is being installed, it seems it is not? Thank you for all the help!

ahasverus added a commit to ahasverus/ragg that referenced this issue Sep 3, 2024
Implement hack proposed here: r-lib#170 (comment)
@dimino
Copy link

dimino commented Sep 3, 2024

Based on email correspondence, @thomasp85 doesn't consider this to be worth fixing for the time being, since there are workarounds available to sufficiently sophisticated R users.

@thomasp85
Copy link
Member

@dimino i would be grateful if you did not misrepresent what I wrote. It is definitely worth fixing, but I am having higher priorities right now. I provided you with workarounds for the time being to help you out, not to say that the issue doesn't matter

@dimino
Copy link

dimino commented Sep 3, 2024

@thomasp85 apologies if there was confusion! My intention was to explain that you didn't consider this worth fixing for the time being, which is what "higher priorities" means. Worth here being applied relatively to the worth of the other work you're doing.

And strictly speaking no, you provided no workarounds to me I was not already aware of. I submitted the PR based on a workaround provided by @ChangqingW .

Further, the issue is not my specific problem, but the problem of all remaining people for whom you have not provided a sufficient workaround for, which are the people who may lack the technical sophistication to apply the workarounds discussed here.

This is obviously your call, as you have refused my offer to help merge the relevant PR and cut a release. You can decide how to prioritize your time and manage this repo however you like. But the fact remains that you consider this blocking issue (to others, not me) to be of insufficient worth to resolve in a timely manner. That is a fact worth making clear to anyone who comes here searching for a solution.

@fvalenduc
Copy link

It would be more interesting if you could share the workarounds here. Personally, I cloned the original repo, I applied the patch quoted above and I installed the package from this repo.

@thomasp85
Copy link
Member

For the time being, the PR can easily be installed with pak::pak("r-lib/ragg#171")

Be aware that I haven't looked at the changes in the PR so I can't really vouch for it's correctness, but if it works it can get you through the next couple of weeks

@ablechow29
Copy link

ablechow29 commented Sep 4, 2024

I am experiencing the same issue described by the OP. I am on archlinux and can confirm that re-installing freetype2 does not resolve the issue. And pak::pak("r-lib/ragg#171") does not install ragg successfully either.

Downgrading freetype2 to is previous version does resolve the issue
sudo pacman -U file:///var/cache/pacman/pkg/freetype2-2.13.2-2-x86_64.pkg.tar.zst
install.packages("ragg") works normally afterwords
Hopefully this gets fixed soon.

@chartgerink
Copy link

@dimino no reason to be pedantic to the maintainer. It's not a good look. You are not entitled to their time, attention, or having your suggestions included.

Thanks for all your work on this open source package @thomasp85 <3

@dimino
Copy link

dimino commented Sep 4, 2024

@chartgerink I hope I haven't upset you! I feel zero entitlement to anyone's time or attention, but when a maintainer refuses to accept the offered help, they're deliberately creating a bottleneck around their availability. This is any maintainer's prerogative, of course, but the bottleneck remains, as do those who are stuck waiting behind it.

@joshweiland
Copy link

I've been able to get ragg (and therefore tidyverse) installed using pak::pak("r-lib/ragg#171"). Thanks to all who are working on this!

@vippeople22
Copy link

vippeople22 commented Sep 9, 2024

https://archive.archlinux.org/packages/f/freetype2/
2.13.2-2 works fine after using
sudo pacman -U file.tar.gz
and
install.packages("tidyverse") in RStudio

@WildPenquin
Copy link

WildPenquin commented Sep 10, 2024

On Arch here, I don't need to downgrade libfreetype2.2.13.3-1 works fine with the PR (pak::pak("r-lib/ragg#171").

Thanks for the work and all involved!

EDIT: I don't know why other users here need to downgrade libfreetype2. I'm guessing you are running install.packages("ragg") afterwards? Note, you don't need (and absolutely don't want to do that as it will undo the ragg installation with the PR) to do that, as pak has already installed ragg. As you have installed pak, it's much more worthwhile to use it for installing packages now.

@thomasp85
Copy link
Member

ragg has been updated on CRAN so you can just install from there.

You likely get an error because you pass in #171 rather than r-lib/ragg#171 to pak()

@gabx
Copy link

gabx commented Sep 20, 2024

ragg has been updated on CRAN so you can just install from there.

You likely get an error because you pass in #171 rather than r-lib/ragg#171 to pak()

Thank you. I deleted my comment as I was able to install ragg whith downgrading Freetype 2 on my archlinux box

supermarin pushed a commit to supermarin/nixpkgs that referenced this issue Oct 15, 2024
Fixes build that is currently failing with

> error: invalid conversion from 'unsigned char*' to 'char*'

See also r-lib/ragg#170
amarshall added a commit to amarshall/nixpkgs that referenced this issue Oct 15, 2024
Fixes build that is currently failing with

> error: invalid conversion from 'unsigned char*' to 'char*'

See also r-lib/ragg#170
ners pushed a commit to ners/nixpkgs that referenced this issue Oct 16, 2024
Fixes build that is currently failing with

> error: invalid conversion from 'unsigned char*' to 'char*'

See also r-lib/ragg#170
vinylen pushed a commit to vinylen/nixpkgs that referenced this issue Oct 17, 2024
Fixes build that is currently failing with

> error: invalid conversion from 'unsigned char*' to 'char*'

See also r-lib/ragg#170
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

Successfully merging a pull request may close this issue.