Gnucap for windows

Paul Reichl <[email protected]> Thu, 02 Feb 2012 18:14:18 +1100
Newsgroups gmane.comp.gnu.gnucap.general
Message-ID <[email protected]>
Hi All,

First of all I would like to say a big thanks to the gnucap developers 
as I have only just started using it and I have found it to be a 
fantastic tool.

Also please forgive me if this email lists down what has already been 
documented/discussed elsewhere, but after being asked if gnucap works in 
windows (personally I much prefer Linux) and not finding any windows 
executable files (or a recipe for generating them) this was the 
procedure that I used to generate a gnucap.exe file that seems (from my 
few limited tests) to work.
Please note that the windows executable was generated on my *linux* box 
using the mingw32 cross compilers (they are fantastic as they allow you 
to generate windows executables from linux!).

My computer is running Ubuntu 11.10 oneiric (64 bit). To generate 
windows binaries from my Ubuntu machine I first needed to install the 
mingw32 cross compilers and wine (if I didn't have wine installed it 
complained during the configure process that I could not execute the 
generated c++ execuatbles (or something along those lines)).

Anyway to install these I simply used

sudo apt-get install mingw32

and for wine

sudo apt-get install wine1.3

I then downloaded gnucap-2009-12-07.tar.gz (from 
http://permalink.gmane.org/gmane.comp.gnu.gnucap.devel/567). I am not 
sure if these are the latest files or not, but these are the ones I used.
After unpacking this archive and changing into the gnucap-2009-12-07 
directory

I ran configure with the options as listed below

./configure CC=i586-mingw32msvc-cc CXX=i586-mingw32msvc-c++ 
CPP=i586-mingw32msvc-cpp

after this was complete I then ran

make

after compiling a number of items it later failed with the message below

i586-mingw32msvc-c++: unrecognized option '-rdynamic'
make[2]: Leaving directory 
`/home/preichl/GNUCAP/SOURCE/TEST2/gnucap-2009-12-07/modelgen'
Making all in src
make[2]: Entering directory 
`/home/preichl/GNUCAP/SOURCE/TEST2/gnucap-2009-12-07/src'
../modelgen/gnucap-modelgen -h d_mos1.model
/bin/bash: ../modelgen/gnucap-modelgen: No such file or directory
make[2]: *** [d_mos1.h] Error 127
make[2]: Leaving directory 
`/home/preichl/GNUCAP/SOURCE/TEST2/gnucap-2009-12-07/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory 
`/home/preichl/GNUCAP/SOURCE/TEST2/gnucap-2009-12-07'
make: *** [all] Error 2

It appears as if i586-mingw32msvc-c++ does not like the compiler flag 
'-rdynamic', so I simply performed a make clean using

make clean

then I edited the configure file and changed
LDFLAGS="$LDFLAGS -rdynamic"
to
LDFLAGS="$LDFLAGS"

This essentially removed the flag -rdynamic. Is it OK to remove this 
option?. Does anyone know what (if any) impact this is likely to have?. 
i.e. will it break something somewhere? (my simple examples work alright 
without it).
According to the gcc man page
-rdynamic
            Pass the flag -export-dynamic to the ELF linker, on targets that
            support it. This instructs the linker to add all symbols, 
not only
            used ones, to the dynamic symbol table. This option is 
needed for
            some uses of "dlopen" or to allow obtaining backtraces from 
within
            a program.

On the assumption that it was OK to remove the flag -rdynamic,

I then ran ./configure again as

./configure CC=i586-mingw32msvc-cc CXX=i586-mingw32msvc-c++ 
CPP=i586-mingw32msvc-cpp

and again ran

make

This time it gets further but fails with the following error message

make[2]: Leaving directory 
`/home/preichl/GNUCAP/SOURCE/TEST2/gnucap-2009-12-07/modelgen'
Making all in src
make[2]: Entering directory 
`/home/preichl/GNUCAP/SOURCE/TEST2/gnucap-2009-12-07/src'
../modelgen/gnucap-modelgen -h d_mos1.model
/bin/bash: ../modelgen/gnucap-modelgen: No such file or directory
make[2]: *** [d_mos1.h] Error 127
make[2]: Leaving directory 
`/home/preichl/GNUCAP/SOURCE/TEST2/gnucap-2009-12-07/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory 
`/home/preichl/GNUCAP/SOURCE/TEST2/gnucap-2009-12-07'
make: *** [all] Error 2

To fix this I edited the src/Makefile and changed the lines that read

%.cc : %.model %.h ${MODELGEN}${EXEEXT}
         ${MODELGEN} -cc $<

%.h : %.model ${MODELGEN}${EXEEXT}
         ${MODELGEN} -h $<

to

%.cc : %.model %.h ${MODELGEN}${EXEEXT}
         ${MODELGEN}${EXEEXT} -cc $<

%.h : %.model ${MODELGEN}${EXEEXT}
         ${MODELGEN}${EXEEXT} -h $<

I then ran did a make clean again using

make clean

and compiled again using

make

This time it ran through to completion and generated a windows 
executable called gnucap.exe in the src directory.

I then copied the gnucap.exe file (roughly 38MB) from my linux machine 
to a windows machine and I was able to successfully run a number of 
examples in windows!.

So essentially my question is: will I have broken anything by removing 
the  -rdynamic flag from the configure file?

Thanks in advance,

Paul.