Sunday, March 23, 2008

yywrap it up

This weekend I decided to download the beta version of the highly anticipated Ubuntu 8.04.

After installing it on a virtual machine I promptly proceeded to building ZeroBUGS on it.

And I ran into a small roadblock: The debugger has a built-in C/C++ interpreter, for evaluating simple expressions and function calls. This code failed to link, because in this new Hardy Heron version of Ubuntu the yyFlexLexer class (see /usr/include/FlexLexer.h) has a virtual method called yywrap(). In older versions of flex yywrap used to be a standalone, extern "C" function.

To work around this issue in a portable manner I defined a new function in my file.

It attempts to compile a small C++ program that assigns a pointer to method. If the compilation fails, I assume that yyFlexLexer::yywrap is not defined.

Here's the code:

[AC_CACHE_CHECK([for yyFlexLexer::yywrap],
cat > tmp.cpp << ---end---

#include <FlexLexer.h>
int main()
int (yyFlexLexer::*method)() = &yyFlexLexer::yywrap;
return 0;
if g++ tmp.cpp 2>/dev/null; then
rm a.out
rm tmp.cpp])

if test "$ac_cv_yyFlexLexer_yywrap" = true; then
[Define if yyFlexLexer::yywrap is declared])


And you can test drive a pre-release of ZeroBUGS for Ubuntu 8.04 here:

The md5sum is: 5b80e9f0f867b858620c740096e432dd


Andrea M. said...

Hi, thank for your work.
I've a little problem installin your .deb:
the result of typing

$ sudo dpkg -i --force-all zero....

is this:

Detecting plugins...
debugger_init: cannot open shared object file: No such file or directory

I checked, and I have installed in \usr\lib


NB: OS is UBUNTU 8.04 64bit and I need your solution to install OpenFOAM (?), see:

The Free Meme said...

You do not need my DEB to install OpenFOAM. Maybe I confused you by posting that deb...

The intent of the post was to present a problem that I run into ***while working on my very own ZeroBUGS project***.

But maybe I misread and you indeed want to give my debugger a try :)

Here's the problem: the 32-bit package is not designed to install on a 64-bit system.

Please go to, and make sure you get the 64-bit version. Cheers!

The Free Meme said...

I believe the solution could be rewritten more elegantly by using the AC_TRY_COMPILE macro...