Perl WWW::Curl installation on OSX 10.9 Mavericks

  19 Feb 2014


This recipe works for me as my quick hack. So I just share what I did which might help someone who experiences similar error.

Basically, if you got this kind of error

Bareword "CURLOPT_xxx" not allowed while "strict subs"

on OSX 10.9.x Mavericks when trying to install WWW::Curl and its wrapper.

It’s time to get a more recent version of curl and gcc

First, upgrade or install curl with homebrew

brew install curl 

In this case, the installed version is 7.34.0

Set the CURL_CONFIG variable to the proper curl-config path instead of the one provided by Apple.

export CURL_CONFIG=/usr/local/Cellar/curl/7.34.0/bin/curl-config

After a few attempts with cpanm -v WWW::Curl, the problem is still there.

Download and build WWW::Curl is an alternative.

curl -O http://cpan.metacpan.org/authors/id/S/SZ/SZBALINT/WWW-Curl-4.15.tar.gz

Extract and go inside the WWW-Curl-4.15 directory

gunzip -c WWW-Curl-4.15.tar.gz | tar -xvf -
cd WWW-Curl-4.15

At this point, perl Makefile.PL should work but apple provides the old gcc or something else doesn’t work…

Let’s try to install gcc49

brew install homebrew/versions/gcc49

Run the following to replace the cpp with cpp-4.9

sed -i.bak "s|cpp\"|/usr/local/Cellar/gcc49/4.9-20140119/bin/cpp-4.9\"|g" Makefile.PL

After you have replaced. Immediately, run

perl Makefile.PL

Then, modify the result Makefile

sed -i.bak "s|CC = cc|CC = /usr/local/Cellar/gcc49/4.9-20140119/bin/gcc-4.9|g" Makefile

Now it’s time to get a proper installation.

Run

make
make test
make install

And

cpanm -v WWW::Curl::Simple

Done \o/

comments powered by Disqus