Desperately in need of help compiling Font::FreeType CPAN module with Strawberry Perl - perl

For literally days now, I have been scouring the web, and cursing and tearing my hair out, trying to compile Font::FreeType with dmake for dwimperl-5.14.2.1-v7-32bit (Strawberry Perl 5.14.2.1). For openers, there are several bugs in the FreeType.xs file for which I found a patch at Bug #32713 for Font-FreeType: patch for Font-FreeType-0.03. Lovely. The last update for this module is 11 Sep 2004 (note the day) so it is dead for sure, but I need it for using REAL fonts with perlcairo. So I am determined (desperate) to get it working. So far I have had no problems using cpan with the exception of this module. In fact Strawberry Perl is the only Windows perl I have used that actually works right out of the box with CPAN. This is obviously a rogue module. Even *nix users have had problems with it.
I read How do I fix Perl's Font::FreeType compilation errors? but no help there so I think a new thread is justified.
Number found where operator expected at Makefile.PL line 17, near "my $font_filename = catfile($data_dir, '5"
(Might be a runaway multi-line '' string starting on line 9)
(Do you need to predeclare my?)
Makefile.pl:
1 use ExtUtils::MakeMaker;
2 use File::Spec::Functions;
3
4 WriteMakefile(
5 NAME => 'Font::FreeType',
6 AUTHOR => 'Geoff Richards <qef#laxan.com>',
7 VERSION_FROM => 'lib/Font/FreeType.pm',
8 LIBS => [ '-lfreetype' ],
9 INC => '-I/usr/include/freetype2',
10 NO_META => 1,
11 );
12
13
14 # Generate a listing of the characters in the BDF test font, for checking
15 # that the library can find them all. See t/10metrics_5x7bdf.t
16 my $data_dir = catdir(qw( t data ));
17 my $font_filename = catfile($data_dir, '5x7.bdf');
This runs just fine using perl so what is dmake's problem? If I just run it with perl, dmake will re-run it. I can't figure out how to get dmake to just use what's there and I find no REAL documenation on dmake, just the useless help and man page (at least useless to me).
I tried adding a trailing slash to $data_dir but same error. Finally I just set $font_filename to the complete path. Crude, I know, but it works.
So this now creates FreeType.c but now there are path problems:
gcc -c -I/usr/include/freetype2 -s -O2 -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -mms-bitfields -s -O2 -DVERSION=\"0.03\" -DXS_VERSION=\"0.03\" "-IC:\Dwimperl\perl\lib\CORE" FreeType.c
FreeType.xs:19:22: fatal error: ft2build.h: No such file or directory
FreeType.c contains:
#include <ft2build.h>
#include FT_FREETYPE_H
I tried changing include paths in Makefile.pl but I really don't know the "proper" way to do that:
WriteMakefile(
.
LIBS => '-LC:/gtk/lib -lfreetype',
INC => '-IC:/gtk/include/freetype2 -IC:/gtk/include -IC:/Dwimperl/c/include',
I think now the problem is converting *nix paths to Windows ones so the compiler can find all the header files. Has anyone successfully compiled this damned module in Windows using ANY compiler? Or does anyone at least know how to specify the Windows paths for WriteMakefile?

I was also trying to get the latest FreeType module to install on cygwin using cpan like so:
$ cpan
cpan shell -- CPAN exploration and modules installation (v1.9800)
Enter 'h' for help.
cpan[1]> install Font::FreeType
The first issue I ran into was during the make phase. Make was complaining about not being able to find ft2build.h.
It's then that I realized I had to download and compile/install the FreeType library first (doh!). So, I downloaded the latest from the FreeType download page, and installed it like so:
$ cd cygwin/freetype-2.4.0
$ ./configure
...
$ make
...
$ make install
The next issue is that when I tried to make the module in cpan again, it was failing at the following line in ft2build.h:
#include <freetype/config/ftheader.h>
If you take a look at the actual file (in /usr/local/include/ft2build.h on my system, but it may be somewhere else on yours) you will see this comment before that line:
/* `<prefix>/include/freetype2' must be in your current inclusion path */
So, I set the appropriate environment variable (The "proper" way, I believe -- better than modifying the "INC" line in the make file):
$ C_INCLUDE_PATH=/usr/local/include/freetype2
$ export C_INCLUDE_PATH
After fixing that, the next problem I ran into is the lvalue error:
$ cpan install Font::FreeType
CPAN: Storable loaded ok (v2.27)
...
FreeType.xs:808:21: error: lvalue required as left operand of assignment
...
Makefile:340: recipe for target `FreeType.o' failed
make: *** [FreeType.o] Error 1
GEOFFR/Font-FreeType-0.03.tar.gz
/usr/bin/make -- NOT OK
CPAN: YAML loaded ok (v0.84)
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible
I know you've already fixed that, but I'll post the info here in case someone else runs into it. Save the patch file from here to FreeType.xs.diff (Your Font-FreeType-0.03 directory may be named differently), apply it, and make/compile like below. Note that since we modified the module we can't use cpan anymore, thus we make it manually:
$ cd ~/.cpan/build/Font-FreeType-0.03
$ patch FreeType.xs FreeType.xs.diff
patching file FreeType.xs
$ make
Makefile out-of-date with respect to Makefile.PL
...
==> Your Makefile has been rebuilt. <==
==> Please rerun the make command. <==
false
Makefile:866: recipe for target `Makefile' failed
make: *** [Makefile] Error 1
$ make
cp lib/Font/FreeType.pm blib/lib/Font/FreeType.pm
...
Manifying blib/man3/Font.FreeType.3pm
$ make install
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
...
Appending installation info to /usr/lib/perl5/5.14/i686-cygwin-threads-64int/perllocal.pod
Voila! It's compiled! Another thing to point out is that I used regular gnu make rather than dmake, as Borodin pointed out earlier. The FreeType install notes say you have to run GNU Make 3.80 or later. You can check what version of make you have installed like this:
$ make -v
GNU Make 3.82.90
Built for i686-pc-cygwin
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Related

Issue while installing DBI Perl module via CPAN prompt on Solaris 11

I am getting error "sh: cc: not found" when I try to install DBI module from CPAN prompt. Is there any way to resolve this? I have already installed gcc compiler from gnu site.
$ which gcc
/bin/gcc
$
and environment variable is already set like this cc=gcc
But, still I got this error:
cc -c -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -xO3 -DVERSION=\"1.643\" -DXS_VERSION=\"1.643\" -KPIC "-I/usr/perl5/5.12/lib/sun4-solaris-64int/CORE" -DDBI_NO_THREADS Perl.c
sh: cc: not found
*** Error code 127
make: Fatal error: Command failed for target `Perl.o'
Current working directory /root/.cpan/build/DBI-1.643-2
TIMB/DBI-1.643.tar.gz
/usr/bin/make -- NOT OK
Failed during this command:
TIMB/DBI-1.643.tar.gz : make NO
In order to avoid any binary incompatibilities, Perl expects all C code to be compiled with the same compiler as was used to build Perl itself. It looks like you're using the standard Solaris installation of Perl. That will have been built with the Solaris C compiler, not with gcc (you can check by running perl -V:cc).
So you're going to need the Solaris C compiler installed in order to install any CPAN modules that require C code to be compiled.
It's been years (decades probably) since I used Solaris. Is there no standardised package repository that you can use to install extra packages - something like RedHat's rpm?

INSTALL_BASE=~/perl5 -- NOT OK - While installing Perl Module

I am trying to install one of the Perl module in my local system (Windows 7). But its failing to install the module
Here is what its displaying
C:\Windows\system32>perl -MCPAN -e "install Net::SFTP"
Reading 'C:\Users\AppData\Local\.cpan\Metadata'
Database was generated on Sun, 26 May 2019 05:17:03 GMT
Running install for module 'Net::SFTP'
Checksum for C:\Users\AppData\Local\.cpan\sources\authors\id\L\LK\LKINLE
Y\Net-SFTP-0.12.tar.gz ok
Configuring L/LK/LKINLEY/Net-SFTP-0.12.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Warning: prerequisite Math::Int64 0.54 not found.
Warning: prerequisite Net::SSH::Perl 2.12 not found.
The getpwuid function is unimplemented at C:/Perl64/lib/ExtUtils/MakeMaker.pm li
ne 1064.
Warning: No success on command[C:\Perl64\bin\perl.exe Makefile.PL INSTALL_BASE=~
/perl5]
LKINLEY/Net-SFTP-0.12.tar.gz
C:\Perl64\bin\perl.exe Makefile.PL INSTALL_BASE=~/perl5 -- NOT OK
It was working fine before and I have installed couple of modules, don't know what happens suddenly.
Please help me to resolve this. Do I need to make any modifications in config?
You're telling Perl to into ~/perl5. That's not a Windows path, and ExtUtils::MakeMaker is using a unix-specific function (getpwuid) to expand it. Your problem should go away if you use a Windows path.
That said, if you have access to write to C:\Perl64\..., I suggest that you install modules to the default directory by removing INSTALL_BASE=~/perl5.
If you don't have access to write to C:\Perl64\..., I suggest that you install Perl itself in a directly to which you do have access to write, and then I'd install modules to the default directory by removing INSTALL_BASE=~/perl5.
Since you didn't actually specify INSTALL_BASE=~/perl5 on the command line, you are specifying it through the environment (PERL_MM_OPT and PERL_MB_OPT), or in cpan's configuration (o conf from within cpan).

Cannot install Date::Calc perl module

I'm running Solaris on my machine and I would need to install the Date::Calc perl module in order for one of my scripts to work.
When I run the following command:
sudo perl -MCPAN -e 'install Date::Calc'
I get the following error:
Tests succeeded but one dependency not OK (Bit::Vector)
STBEY/Date-Calc-6.3.tar.gz
[dependencies] -- NA
Running make install
make test had returned bad status, won't install without force
I have no prior experience in Perl development, so I have no clue about what the error might be or where to get more information.
What should I do to fix this?
When trying to install Bit::Vector first, i.e. when running the following command:
sudo perl -MCPAN -e 'install Bit::Vector'
i get the following error message:
Checking if your kit is complete...
Looks good
Writing Makefile for Bit::Vector
Writing patchlevel.h for /usr/bin/perl (5.012003)
cp lib/Bit/Vector/Overload.pm blib/lib/Bit/Vector/Overload.pm
cp Vector.pm blib/lib/Bit/Vector.pm
cp Vector.pod blib/lib/Bit/Vector.pod
cp lib/Bit/Vector/Overload.pod blib/lib/Bit/Vector/Overload.pod
cp lib/Bit/Vector/String.pod blib/lib/Bit/Vector/String.pod
cp lib/Bit/Vector/String.pm blib/lib/Bit/Vector/String.pm
cc -c -DPTR_IS_LONG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -xO4 -DVERSION=\"7.2\" -DXS_VERSION=\"7.2\" -KPIC "-I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE" BitVector.c
sh: line 1: cc: not found
*** Error code 127
make: Fatal error: Command failed for target `BitVector.o'
STBEY/Bit-Vector-7.2.tar.gz
/usr/bin/make -- NOT OK
'YAML' not installed, will not store persistent state
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible
I installed gcc via the following commands (as adviced here):
pkg install gcc-45
pkg install system/header
but I still get the same error when trying to install Bit::Vector. Indeed, when I type cc on the command-line, I get the command not found error. When I type gcc, however, I get gcc: no input files.
The error means that Bit::Vector (a dependency of Date::Calc) failed to install for some reason. Bit::Vector requires compiling C code, which means your CPAN configuration will need access to the C compiler and libraries (and headers) that were used to build your perl.
From what I understand, that can sometimes be painful on Solaris.
If you have another C compiler available, you might consider building and installing a local Perl using perlbrew.
So it turns out that the only option is to install the Oracle Solaris Studio prior to installation of new perl modules which need to compile C code.
From a related discussion at Oracle Solaris forum:
CC modification in /usr/perl5/5.12/lib/i86pc-solaris-64int/Config.pm
will not resolve the compilation issue. New errors will be produced
and some part will not use this variable.
By default, this method to build modules will use perl compiled
options. And in this case, as we used Oracle Studio, this software
will be required because some options are not available with gcc.
I tried with Oracle Studio, and the compilation was done successfully.
If you want to use gcc, then this will be very tricky to modify
several perl config files. An another method is to compile manually
each necessary modules after you customize each Makefile.

Installing CPAN modules without root

I followed this helpful tutorial to get Perl installed just for my user. I am sorry to link to an external site but I think reading this is the only way to understand how to answer the question.
Anywho, I am feeding defaults to the CPAN config - the .cpan and CPAN directories created via the tutorial - yet for some reason CPAN still wants to dig into /usr/lib/ - which it just can't get to - when I try to install a module. This was while installing DBD::CSV.
Here is the error message:
All tests successful (7 subtests UNEXPECTEDLY SUCCEEDED), 3 tests skipped.
Files=23, Tests=706, 3 wallclock secs ( 2.28 cusr + 0.54 csys = 2.82 CPU)
/usr/bin/make test -- OK
Running make install
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/perl5lib/lib/Bundle/DBD'
mkdir /perl5lib: Permission denied at /usr/lib/perl5/5.8.8/ExtUtils/Install.pm line 457
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
at -e line 1
make: *** [pure_site_install] Error 13
/usr/bin/make install -- NOT OK
It seems to be going to the wrong perl5lib.
Yeah, local::lib helps. I suggest using cpanm instead of cpan. I think it defaults to installing everything ~/perl5/lib/perl5. Here's a super useful tutorial.
local::lib causes installers to use INSTALL_BASE, which I consider broken. I use perlbrew to install a local copy of Perl instead.
You don't mess with your system's install of Perl, so you don't break your operating environment.
Allows you to have multiple versions and builds of Perl installed with no hassle.
INSTALL_BASE need not be used.
No need for special permissions.
take a look at this module: local::lib
did you configure the myconfig.pm inside cpan instead of letting it automatically fill in all the defaults? During the cpan configuration you needed to add PREFIX="" for the Makefile.PL portion so that it installs the modules to this new location where you have write access. Since its already configured automatically for you, go into .cpan/CPAN/, look for a MyConfig.pm and edit it. locate the line "makepl_arg" and change the value in [ ] to contain PREFIX="". Then try the perl -MCPAN -e shell and install a module.

installing perl module Class-Load-XS

I tried to install module Class-Load-XS-0.04 manually. I saw the following error:
$ perl Build.PL
Warning: ExtUtils::CBuilder not installed or no compiler detected
Proceeding with configuration, but compilation may fail during Build
However, the execution of perl -e 'use ExtUtils::CBuilder' was perfectly fine. I even tried to re-install ExtUtils::CBuilder, but it still does not work.
Could you please help?
I tried on my Win 7 machine, and it shows some warnings like this when I do perl Build.pl:
collect2: ld returned 1 exit status
Checking prerequisites...
requires:
! Class::Load is not installed
build_requires:
! Class::Load is not installed
! Module::Implementation is not installed
! Test::Fatal is not installed
! Test::Requires is not installed
ERRORS/WARNINGS FOUND IN PREREQUISITES. You may wish to install the versions
of the modules indicated above before proceeding with this installation
Then I installed the above mentioned modules, and things went fine then.
You may try install these modules first.
Hope it helps.
It looks to me like you don't have a compiler. Try this:
perl -e 'use ExtUtils::CBuilder; $cb = ExtUtils::CBuilder->new; print $cb->have_compiler ? "have\n" : "dont have\n";'
Can I guess that you are on Windows using ActiveState Perl? If so perhaps try Strawberry Perl which comes with a compiler.
Had a similar problem installing a different module (Win32::Mutex). This isn't a great fix, but it got the job done. From the build directory (e.g., ~/.cpan/build/The-Module-mYyzLx)
First, set the CC environment variable yourself
SET CC=C:\strawberry\c\bin\g++.exe [Windows]
export CC=/usr/bin/g++.exe [Cygwin]
and try to build (perl Build.PL, perl Build, ...). If it is still complaining about missing programs (g++, dlltool, etc.):
Second, copy pieces of your tool chain into the build directory
COPY C:\strawberry\c\bin\g++.exe . [Windows]
COPY C:\strawberry\c\bin\dlltool.exe .
cp /usr/bin/g++ . [Cygwin]
cp /usr/bin/dlltool .
If the build still complains about missing programs, copy those to your build directory too.
The fix and the symptoms are consistent with ExtUtils::CBuilder not being able to use the current PATH setting, though I have no idea what that would be so difficult.
I'd suggest installing these first:
apt-get install libc6-dev
and
apt-get install libtest-exception-perl
By the way you describe the problem it looks like you have these two perl modules missing. On the other hand it takes just a couple of seconds to double-check if those are installed, but these 'seconds' could help you save on a lot of head ache.