Wednesday 2 October 2019

cygwin - gcc not finding header file though its path has been included with -I


I'm trying to install a module (Package::Stash::XS) via cpanm, but the installation is failing due to a gcc error. The command:


gcc -c    -DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -fno-strict-aliasing -pipe -fstack-protector -DUSEIMPORTLIB -O3    -DVERSION=\"0.28\"  -DXS_VERSION=\"0.28\"  "-I/usr/lib/perl5/5.14/x86_64-cygwin-threads/CORE"   XS.c

fails with the error:


XS.xs:1:20: fatal error: EXTERN.h: No such file or directory
compilation terminated.

at the line:


#line 1 "XS.xs"
#include "EXTERN.h"

However, the file EXTERN.h does exist in the -I included /usr/lib/perl5/5.14/x86_64-cygwin-threads/CORE:


$ ls /usr/lib/perl5/5.14/x86_64-cygwin-threads/CORE/E*
/usr/lib/perl5/5.14/x86_64-cygwin-threads/CORE/EXTERN.h

What could the issue be, and how can I make the compilation succeed? I've tried changing the -I to -iquote (though gcc manual does say double quoted includes also eventually use -I), but that doesn't help. My first thought was it was a permission issue, but this is Cygwin and cpanm is running as me and I do have read access to EXTERN.h and exec access on the CORE directory.



Answer



Ok, I believe I've found the issue. I'm running this in Cygwin as mentioned, and it appears Cygwin was trying to use Windows strawberry Perl's gcc since it's own gcc wasn't installed! The Windows gcc probably had problems with a Cygwin style path, hence the weird error. I've now installed Cygwin's gcc and this problem is gone. It complained next about a , that too was solved by installing libcrypt-devel from the Cygwin setup dialog.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...