Adding mcrypt Support to Sun’s CoolStack
October 26th, 2008
A very boring first post – but I thought I’d blog about this since it’s fresh in my mind!
Sun’s Web Stack – CoolStack
We’ve been using Solaris in an ever increasing way here at EveryCity for a while now. Solaris is an excellent operating system for many reasons, and I’ll no doubt be blogging about it plenty in the weeks and months to come. But one of the key areas Solaris currently lags behind Linux with is the availability of well made, precompiled packages of popular open source software. A very large number of servers these days are deployed to run web services, including Apache, PHP, MySQL, Ruby on Rails, etc, and installing this on Linux can be as simple as “yum install apache php mysql”.
So Sun set out to provide a solution to this on Solaris – enter CoolStack. CoolStack has a good selection of software, including:
- Apache HTTP Server
- PHP Hypertext Processor
- MySQL Database
- Perl Scripting Language
- Ruby (Including rubygems and rails)
- Tomcat J2EE/Java Web Server
- Squid Caching Proxy Server
The PHP package includes a good selection of libraries, so you can get started straight out of the box.
Adding mcrypt Support to PHP on CoolStack 1.3.1
One of the things that CoolStack is missing however is the mcrypt extension, which is used in a number of PHP applications, for example PHPMyAdmin. I was surprised this was missed out, as so many others are included. However it’s not too hard to add this ourself. This example is for CoolStack 1.3.1, but assuming the stack doesn’t change too much, the principles should be the same.
Compiling libmcrypt
Head on over to http://sourceforge.net/projects/mcrypt and download the latest libmcrypt source. You’ll need a healthy development environment, which I’m hoping to blog about in a future post (Hint: Grab Sun Studio 11 and put /opt/SUNWspro/bin at the front of your path).
You’ll want to choose a sensible place to install libmcrypt to – since I was producing a package for deployment to other servers, I chose “/opt/libs/libmcrypt”, but where you place this is up to you – “/opt/coolstack” is another suitable PREFIX path.
Let’s now compile and install libmcrypt (Using cc rather than gcc):
unset CC LDFLAGS CFLAGS export CC=cc ./configure --prefix=/opt/libs/libmcrypt --enable-dynamic-loading \ --with-included-algos=cast-128,gost,rijndael-128,twofish,arcfour,cast-256,loki97,rijndael-192,saferplus,wake,blowfish-compat,des,rijndael-256,serpent,xtea,blowfish,enigma,rc2,tripledes make make install
Et VoilĂ ! You now have libmcrypt installed. If your compiler barfs, post a printout of what you get in the comments and I’ll assist if I can.
Compiling the php mcrypt extension
Assuming you have already downloaded, installed and configured CoolStack, all we need to do is fetch two CoolStack source packages. Nip on over to http://cooltools.sunsource.net/coolstack/, click the link to download, and choose “Source” as the Platform.
Download and install CSKruntime_1.3.1_Src.pkg.bz2 and CSKamp_1.3.1_Src.pkg.bz2 – this should place files under /opt/coolstack/src. Now lets compile the mcrypt extension:
cd /opt/coolstack/src/php5/ ./prepare_src cd php-5.2.6/ext/mcrypt /opt/coolstack/php5/bin/phpize ./configure --with-php-config=/opt/coolstack/php5/bin/php-config \ --with-mcrypt=/opt/libs/libmcrypt/ make make install
You can check to make sure the resulting mcrypt.so file is safe to use by doing:
ldd /opt/coolstack/php5/lib/php/extensions/no-debug-non-zts-20060613/mcrypt.so
This should not show any “(file not found)” errors.
Finally, add extension=mcrypt.so to /opt/coolstack/php5/lib/php.ini. Restart Apache (svcadm restart http) – phpinfo(); in a php file should now show a happy mcrypt installation :)

Entry Filed under: Compiling Stuff,CoolStack,SAMP,Solaris

14 Comments Add your own
1. hamdi | December 9th, 2008 at 6:22 am
Thanks for this tutorial, I’m looking for this.
2. Alasdair | December 10th, 2008 at 4:08 pm
No problem hamdi! We’ve made a collection of Coolstack related packages – let me know if you’re interested.
3. Murray | January 5th, 2009 at 6:32 am
I am trying to compile libmcrypt and when I run the make command I get the following error.
gmake[3]: Entering directory `/usr/lib/libmcrypt/modules/algorithms’
if /bin/sh ../../libtool –tag=CC –mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I. -I../.. -I../../lib -g -O2 -MT 3-way.lo -MD -MP -MF “.deps/3-way.Tpo” -c -o 3-way.lo 3-way.c; \
then mv -f “.deps/3-way.Tpo” “.deps/3-way.Plo”; else rm -f “.deps/3-way.Tpo”; exit 1; fi
gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I. -I../.. -I../../lib -g -O2 -MT 3-way.lo -MD -MP -MF .deps/3-way.Tpo -c 3-way.c -fPIC -DPIC -o .libs/3-way.o
In file included from 3-way.c:14:
../../lib/libdefs.h:18:19: ltdl.h: No such file or directory
3-way.c:73: warning: conflicting types for built-in function ‘gamma’
gmake[3]: *** [3-way.lo] Error 1
gmake[3]: Leaving directory `/usr/lib/libmcrypt/modules/algorithms’
gmake[2]: *** [all-recursive] Error 1
gmake[2]: Leaving directory `/usr/lib/libmcrypt/modules’
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/usr/lib/libmcrypt’
gmake: *** [all] Error 2
Can you make any suggestions. Thanks
4. Andy Fore | January 31st, 2009 at 6:12 pm
When I compile libmcrypt using cc I get the following error:
*** Error code 1
The following command caused the error:
set fnord $MAKEFLAGS; amf=$2; \
dot_seen=no; \
target=`echo all-recursive | sed s/-recursive//`; \
list=’libltdl modules lib src doc’; for subdir in $list; do \
echo “Making $target in $subdir”; \
if test “$subdir” = “.”; then \
dot_seen=yes; \
local_target=”$target-am”; \
else \
local_target=”$target”; \
fi; \
(cd $subdir && make $local_target) \
|| case “$amf” in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test “$dot_seen” = “no”; then \
make “$target-am” || exit 1; \
fi; test -z “$fail”
make: Fatal error: Command failed for target `all-recursive’
Current working directory /opt/src/libmcrypt-2.5.7
*** Error code 1
make: Fatal error: Command failed for target `all’
If I compile using gcc it makes successfully. What is the reasoning behind using cc instead of gcc?
Thanks,
Andy
5. Alasdair | January 31st, 2009 at 6:34 pm
Hi Andy,
Do you have Sun Studio 12 installed? Typing “which cc” should show something along the lines of:
# which cc
/opt/SUNWspro/bin/cc
The error message is a bit obscure and not terribly helpful, not having a “cc” is the first thing that springs to mind.
Generally an up to date and patched Sun Studio 12 produces “better” binaries than gcc (or so advocates tell me). However the main reason I do it is that we package up most of the things we compile for deployment to other servers, and I prefer to not have packages depend on libgcc. Quite often if you compile something with gcc it ends up linking against /usr/sfw/lib/libgcc_s.so.1
Generally I’ll try with Sun Studio first, then revert to gcc if it fails.
Murray – sorry for missing your comment. I’m not sure about your issue, if you’re still having problems, drop me an email: al at everycity dot co.uk.
Cheers!
6. Andy | February 6th, 2009 at 9:53 pm
Alasdair,
Thanks for your help so far. I downloaded and installed SunStudio 12. Now I can compile and install libmcrypt! Yay!
However, I am getting an error when doing the second part.
[root@shem : mcrypt]$ /opt/coolstack/php5/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
NONE:0: /usr/sfw/bin/gm4: `__program__’ from frozen file not found in builtin table!
autom4te: /usr/sfw/bin/gm4 failed with exit status: 1
Any ideas?
I looked at your pre-compiled packages, but unfortunately they are for Solaris x86 not Sparc.
Thanks,
Andy
7. Paul | February 7th, 2009 at 9:18 pm
Hi,
When running the phpize command i got this error
# /opt/coolstack/php5/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.
8. Alasdair | February 8th, 2009 at 1:12 pm
Hi Andy,
I’m afraid not – looks Sparc specific. The Sun Forums have a Webstack section and may be able to help. Unfortunately we don’t have any Sparc boxes I can test things on.
Paul – You’ll need GNU Autoconf and Automake. They’re included on the Solaris 10 Companion DVD/CD, and have the names SFWaconf and SFWamake. If they’re already installed you just need to add them to your path, by doing:
export PATH=$PATH:/opt/sfw/bin
(Note the SFW Companion CD/DVD packages install to /opt/sfw NOT /usr/sfw (at least in Zones anyway)).
9. Mark | February 19th, 2009 at 5:32 pm
old post, but just to note, if your shell is zsh, you’ll encounter problems during the configure phase when it switches to configuring libltdl and you have set the compilers via CC and CXX env variables.
changing to bash for the configure and compile worked for me.
10. Gavin | March 30th, 2009 at 9:22 pm
I’ve successfully compiled the mcrypt modules for php – however when I view the php info via browser it does not display the support ciphers and modes for mcrypt.
Please advise
11. Chris | October 13th, 2009 at 7:18 pm
Hi, just wanted to say thanks! Your directions saved me a lot of time.
12. Martin Ramos | April 22nd, 2010 at 5:07 pm
It worked for me, I used a T2000 server SPARC, solaris 10 SPARC, in a Solaris 10 zone.
I just change:
libmcrypt-2.5.7 instead of libmcrypt-2.5.8
gcc instead of cc, because I had not cc installed.
13. Marc Lobelle | October 21st, 2011 at 1:49 pm
Hello,
I need mcrypt because it is used by phpldapadmin. I need in particular md5crypt that is used in LINUX and I need to import a set of users from a ldap running on a LINUX system to one running on solaris.
As you noticed mcrypt is missing from solaris distros.
I tried to compile libmcrypt according to your indications (by the way, I added md5 at the end of the list of algorithms, was that right) and got this result
tempest-[2]-mcrypt-2.6.8# ./configure –prefix=/opt/libs/libmcrypt –enable-dynamic-loading –with-included-algos=cast-128,gost,rijndael-128,twofish,arcfour,cast-256,loki97,rijndael-192,saferplus,wake,blowfish-compat,des,rijndael-256,serpent,xtea,blowfish,enigma,rc2,tripledes
checking build system type… i386-pc-solaris2.10
checking host system type… i386-pc-solaris2.10
checking target system type… i386-pc-solaris2.10
checking for a BSD-compatible install… /opt/sfw/bin/install -c
checking whether build environment is sane… yes
checking for a thread-safe mkdir -p… /opt/sfw/bin/mkdir -p
checking for gawk… gawk
checking whether make sets $(MAKE)… yes
checking for style of include used by make… GNU
checking for gcc… cc
checking for C compiler default output file name… a.out
checking whether the C compiler works… yes
checking whether we are cross compiling… no
checking for suffix of executables…
checking for suffix of object files… o
checking whether we are using the GNU C compiler… no
checking whether cc accepts -g… yes
checking for cc option to accept ISO C89… none needed
checking dependency style of cc… none
checking for a sed that does not truncate output… /opt/csw/bin/sed
checking for grep that handles long lines and -e… /opt/csw/bin/ggrep
checking for egrep… /opt/csw/bin/ggrep -E
checking for fgrep… /opt/csw/bin/ggrep -F
checking for non-GNU ld… /usr/ccs/bin/ld
checking if the linker (/usr/ccs/bin/ld) is GNU ld… yes
checking for BSD- or MS-compatible name lister (nm)… /usr/ccs/bin/nm -p
checking the name lister (/usr/ccs/bin/nm -p) interface… BSD nm
checking whether ln -s works… yes
checking the maximum length of command line arguments… 786240
checking whether the shell understands some XSI constructs… yes
checking whether the shell understands “+=”… no
checking for /usr/ccs/bin/ld option to reload object files… -r
checking how to recognize dependent libraries… pass_all
checking for ar… ar
checking for strip… strip
checking for ranlib… ranlib
checking command to parse /usr/ccs/bin/nm -p output from cc object… ok
checking how to run the C preprocessor… cc -E
checking for ANSI C header files… yes
checking for sys/types.h… yes
checking for sys/stat.h… yes
checking for stdlib.h… yes
checking for string.h… yes
checking for memory.h… yes
checking for strings.h… yes
checking for inttypes.h… yes
checking for stdint.h… yes
checking for unistd.h… yes
checking for dlfcn.h… yes
checking for objdir… .libs
checking for cc option to produce PIC… -KPIC -DPIC
checking if cc PIC flag -KPIC -DPIC works… yes
checking if cc static flag -Bstatic works… no
checking if cc supports -c -o file.o… yes
checking if cc supports -c -o file.o… (cached) yes
checking whether the cc linker (/usr/ccs/bin/ld) supports shared libraries… yes
checking dynamic linker characteristics… solaris2.10 ld.so
checking how to hardcode library paths into programs… immediate
checking whether stripping libraries is possible… no
checking if libtool supports shared libraries… yes
checking whether to build shared libraries… yes
checking whether to build static libraries… yes
checking for gcc… (cached) cc
checking whether we are using the GNU C compiler… (cached) no
checking whether cc accepts -g… (cached) yes
checking for cc option to accept ISO C89… (cached) none needed
checking dependency style of cc… (cached) none
checking for libmcrypt-config… no
checking for libmcrypt – version >= 2.5.0… no
*** Could not run libmcrypt test program, checking why…
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means LIBMCRYPT was incorrectly installed
*** or that you have moved LIBMCRYPT since it was installed. In the latter case, you
*** may want to edit the libmcrypt-config script: no
configure: error: *** libmcrypt was not found
tempest-[3]-mcrypt-2.6.8# glocate libmcrypt
tempest-[4]-mcrypt-2.6.8# ls /opt/libs/
./ ../
tempest-[5]-mcrypt-2.6.8#
actually, if I check config.log, it appears that /usr/include/ mcrypt.h is missing
and I do not have it anywhere
Do you have it and where did you get it ?
Thanks
Marc
14. Marc Lobelle | October 21st, 2011 at 4:50 pm
Thinking about it, if I am just wanting to compile libmcript, it means I do not have it and thus not mcript.h either, so why does configure complain ?
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed