Compiling under Windows: Difference between revisions
Line 117: | Line 117: | ||
* Run <code>autoreconf -i</code> to get the newest libtool files | * Run <code>autoreconf -i</code> to get the newest libtool files | ||
* Run <code>./configure CC=cl CXX=cl LIB=/vc/lib:/sdk/lib CPPFLAGS="-DEBUG -MD -EHsc -I/vc/include -I/sdk/include" PKG_CONFIG_PATH=/usr/local/lib/pkgconfig</code> | * Run <code>./configure CC=cl CXX=cl LIB=/vc/lib:/sdk/lib CPPFLAGS="-DEBUG -MD -EHsc -I/vc/include -I/sdk/include" PKG_CONFIG_PATH=/usr/local/lib/pkgconfig</code> | ||
* Run <code>LIB=/vc/lib:/sdk/lib | * Run <code>make LIB="/vc/lib:/sdk/lib"</code> | ||
* You need to run <code>make LIB="/vc/lib:/sdk/lib"install</code> to install library and headers correctly. If you have not installed the tools required to build the files in the doc directory, edit Makefile.am there and remove all lines except the first two. | |||
* You need to run <code>LIB=/vc/lib:/sdk/lib | |||
=== Compiling iMath=== | === Compiling iMath=== |
Revision as of 03:28, 26 April 2011
Preparing the Openoffice SDK with Microsoft Visual C++
To build iMath for Windows, you need the Windows Openoffice SDK.
- Download and install the Openoffice SDK
- The following is explained in detail in "SDK installation directory"\sdk\docs\install.html
- Install Microsoft Visual C++ (the free express version will do, then you also need to install the Microsoft Visual Studio 2008 Redistributable Package
- Install make (e.g. copy C:\MinGW\bin\mingw32-make.exe to WINDOWS\system32 and rename it to make.exe)
- Install info-zip (e.g. download from [1] and put zip.exe into C:\Windows\system32)
- To test the SDK installation, open a command prompt and cd to the ...\sdk\examples\cpp\DocumentLoader directory.
- Run ...\sdk\setsdkenv_windows.bat to configure your environment. This should create a custom batch file somewhere in your home directory (usually Application Data\Openoffice\...). Give it the correct paths to the make and zip executables
- I had to edit thecustom batch file and add a correct URE path:
set OO_SDK_URE_HOME=C:\Programme\OpenOffice.org 3\URE
- Now try to build the example by typing make, if this is not successful fix the problems before continuing.
- The next time you want to use the SDK, just run the custom batch file to set the environment variables required
Preparing MSYS and Mingw
- Get the mingw installer from here
- Use the pre-packaged lists for the first install
- Do mingw-get update and mingw-get install msys-base mingw32-base. This should update libtool to 2.4
- Click on the MSYS icon to start a Bourne shell
- Add .../Microsoft Visual Studio 10.0/Common7/IDE and .../Microsoft Visual Studio 10.0/VC/BIN to PATH (e.g
PATH=$PATH:"/c/Programme/Microsoft Visual Studio 10.0/Common7/IDE":"/c/Programme/Microsoft Visual Studio 10.0/VC/bin"
). You can find these paths in vsvars32.bat somewhere in the Visual Studio installation directory. - If you want to use cl (the Microsoft compiler) to compile something, copy .../Microsoft Visual Studio 10.0/include and lib to msys vc/include and vc/lib (or find a better way to make CPPFLAGS accept path names with spaces)
- Copy Microsoft SDKs/Windows/Vxxx/Include and Lib to msys /sdk/include and /sdk/Lib (or find a better way to set the cl.exe LIB path)
Compiling gmp with gcc
Download and unpack gmp into your msys home directory.
- Change into the new directory.
- For a shared library build, run configure with
--disable-static --enable-shared
. Then do make, make check and make install - Change into the .libs subdirectory
- Make sure the MSVC binaries are in your path and run
lib /def:libgmp-3.dll.def /out:libgmp-3.lib
- Copy libgmp-3.exp, libgmp-3.dll.def and libgmp-3.lib into /usr/local/lib.
- Do make distclean
- For a static library build, run configure with
--enable-static --disable- shared
(note that it is not possible to build both static and shared libraries in one compilation run). - Do make, make check and make install
- Note that make install overwrites the libgmp.la for dynamic linking in /usr/local/lib.
- Download objconv objconv and put the executable somewhere into your msys path.
- Change into the .libs subdirectory
- Run
objconv -fcoff -nr:___chkstk:__chkstk libgmp.a libgmp.lib
to make the symbols compatible with MSVC - Copy the new libgmp.lib into /usr/local/lib
To compile a test program with MSVC
- Open a DOS command shell and go to the gmp directory.
- You can find some example files in the demos subdirectory of gmp.
- For a dynamically linked program, run
cl /MD -I \vc\include -I \sdk\include -I \local\include isprime.c /link /LIBPATH: \vc\lib /LIBPATH: \sdk\lib LIBPATH: \local\lib libgmp-3.lib
- For a static link, substitute libgmp-3.lib with libgmp.lib
Compilation with Microsoft Visual C++
This is what I tried to get a native MSVC compile (because Openoffice is compiled with MSVC), in spite of being warned that CLN is not compileable with anything except gcc...
Preparations
- Install mingw (the minimal version will do since we will be using the Microsoft compiler)
- Set your PATH as described above in the gcc compile section and create the msys /vc and /sdk directories
- Create the /vc/include/sys directory and put /vc/include/time.h into it
Compiling CLN
Download the CLN source code and unpack it into your msys home directory
- Change to the source directory
- run
./configure CC=cl CXX=cl CCAS=cl CPPFLAGS="-DEBUG -DNO_ASM -EHsc -MD -I/vc/include -I/sdk/include" LIB=/vc/lib:/sdk/lib
- Run LIB="/vc/lib;/sdk/lib" make
- make will stop and complain about missing files cl_asm.obj and cl_asm_GF2.obj
- copying cl_asm.o from a gcc compile to cl_asm.obj gives lots of linker errors, don't try that
- change to the src subdirectory
- Remove cl_asm.lo and cl_asm_GF2.lo
- Edit the Makefile and find the lines starting with
cl_asm.lo:
andcl_asm_GF2.lo:
. - Change cl_asm.S and cl_asm_GF2.S to cl_asm_.cc and cl_asm_GF2.cc in these lines (because MSVC doesn't recognize the .S extension). Total of three changes for each.
- run make cl_asm.lo and make cl_asm_GF2.lo. This should create cl_asm.obj and cl_asm_GF2.obj
- Run make again
The build will finish with some linker warnings about duplicate definitions and create the library in .libs. The linker errors are (hopefully) all harmless and have to do with different handling of inlined functions by gcc and MSVC
- bool zerop(const cl_RA&): As soon as more than one file includes cl_RA.h, inline bool zerop(..) is defined twice and produces a linker warning
- cl_I numerator (const cl_RA&): same as above
- bool CL_FLATTEN minusp (const cl_RA&): same as above
- const cl_I denominator (const cl_RA&): same as above
- bool zerop (const cl_I&): As soon as more than one file includes cl_I.h, inline bool zerop(..) is defined twice and produces a linker warning
- bool minusp (const cl_I&): Same as zerop
- const cl_LF operator+ (const cl_LF&, const cl_LF&): Defined in cl_LF_2plus.cc and as an inline version in cl_LF.h, these clash when cl_R_mul.cc includes cl_LF.h
- same for operator-
Now try compiling the examples and checks:
- Change to the examples subdirectory
- Run
LIB="/vc/lib;/sdk/lib" make
again - Run
LIB="/vc/lib;/sdk/lib" make check
- On my compile, this compiled without a flaw and said "All two tests passed"
Install the library and headers
- Run
LIB=/vc/lib:/sdk/lib make install
to put them into /local/lib
If you want to use the gmp library as compiled and modified by objconv above, add --with-gmp=/usr/local LDFLAGS=/usr/local/lib/libgmp.lib
to the configure invocation. You might have to create a copy of libgmp.lib named libgmp.a in /usr/local/lib because make will link to both of them.
Compiling GiNaC
Download the Ginac source code from git and unpack it into your msys home directory
- Download pkg-config, gettext and glib2 from the GTK project. Unzip the files and install them under /MinGW/bin
- Change to the source directory
- Run
./configure CC=cl CXX=cl CPPFLAGS="-DEBUG -MD -EHsc -I/vc/include -I/sdk/include" LIB=/vc/lib:/sdk/lib PKG_CONFIG_PATH=/usr/local/lib/pkgconfig --disable-shared --enable-static
- If configure chokes, find pkg.m4 on the web and put it in MinGW/share/aclocal
- If you have not installed libreadline, then configure will give a warning. You can ignore this if you do not plan to build the ginsh.
- run make
- The linker complains about "no public symbols existing" in registrar.obj, which seems to be OK since the source file has no code.
- Make will fail in the ginsh subdirectory if you have not installed libreadline. Run make -t in this directory to ignore the problem.
- Running
LIB=/vc/lib:/sdk/lib make check
passes all 58 tests successfully - Run
LIB=/vc/lib:/sdk/lib make install
to put the library into /local/lib
Compiling EQC
Download the EQC source code and unpack it into your msys home directory
- Don't forget to set the Visual C++ paths as described above
- Edit src/Makefile.am and comment out the line
CXX := /usr/bin/ccache $(CXX)
if you don't have ccache installed - Run
autoreconf -i
to get the newest libtool files - Run
./configure CC=cl CXX=cl LIB=/vc/lib:/sdk/lib CPPFLAGS="-DEBUG -MD -EHsc -I/vc/include -I/sdk/include" PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
- Run
make LIB="/vc/lib:/sdk/lib"
- You need to run
make LIB="/vc/lib:/sdk/lib"install
to install library and headers correctly. If you have not installed the tools required to build the files in the doc directory, edit Makefile.am there and remove all lines except the first two.
Compiling iMath
Download the iMath source code and unpack it into your msys home directory in an msys shell
- Go to /local/lib and copy eqc.lib to libeqc.lib, and ginac.lib to libginac.lib
- Run
autoreconf -i
to get the newest libtool files - Run
./configure LIB=/vc/lib:/sdk/lib CPPFLAGS="-I/vc/include -I/sdk/include" PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
Now change to a DOS shell prepared for the OpenOffice SDK as described above
- Edit the Makefile and adapt the OS and MINGW settings at the beginning
- Go to the src directory and run make
- After make was successful, run make deploy to install the extension