Cross-compiling for Windows: Difference between revisions
(Created page with '= Cross-compiling for Windows = == Ubuntu, wine, and msys installed into wine == I have not been successful with this. If you want to try, get the automated MinGW installer fro…') |
|||
Line 1: | Line 1: | ||
== Ubuntu, wine, and msys installed into wine == | == Ubuntu, wine, and msys installed into wine == | ||
Revision as of 04:54, 13 October 2010
Ubuntu, wine, and msys installed into wine
I have not been successful with this. If you want to try, get the automated MinGW installer from Sourceforge. Choose the pre-packaged lists, and then run mingw-get update; mingw-get install msys-base mingw32-base
, which should update libtool to version 2.4
Ubuntu, mingw32, wine and Microsoft Visual C++
General setup
It seems that an Openoffice extension for Windows must be compiled with MSVC to be compatible. Here is a way to do this from within Ubuntu. Make sure you have mingw32 and wine installed. Then, get Microsoft Visual (Express) C++ 2008 to work under wine. Installing with vcsetup.exe, or installing Visual Studio is pretty hopeless and an overkill anyway. Instead, try this hack:
- Get a working installation under Windows (the express version is available for free, and works fine)
- After booting into Ubuntu, copy cl.exe, c1xx.dll, c1.dll, c2.dll, lib.exe, link.exe, msdp80.dll and clui.dll to .wine/drive_c/windows/system32/ or some other location in your PATH
- Get winetricks
- Run winetricks vcrun2008
- Override msvcr90.dll with native version in the wine configuration
wine cl, wine link and wine lib should now work from a (Unix) terminal
Install the required libraries and include files somewhere (is there a better/standard location?)
mkdir ~/.wine/drive_c/cl mkdir ~/.wine/drive_c/cl/VC cp -aR /c/Programme/Microsoft Visual Studio 9/VC/lib/ ~/.wine/drive_c/cl/VC cp -aR mvs/VC/include/ ~/.wine/drive_c/cl/VC cd .wine/drive_c/cl/VC/include/ cp time.h sys mkdir ~/.wine/drive_c/cl/SDK cp -aR /c/Programme/Microsoft\ SDKs/Windows/v6.0A/Lib/ ~/.wine/drive_c/cl/SDK cp -aR /c-ro/Programme/Microsoft\ SDKs/Windows/v6.0A/Include/ ~/.wine/drive_c/cl/SDK
Libtool version 2.4 claims to be able to deal with MSVC. I have not been able to confirm this, but if you want to try, you can download libtool 2.4 source, run configure, make and make install (which will install into /usr/local/...). Then, to use it e.g. in compiling GiNaC, go to the main GiNaC directory and run env LIBTOOLIZE=/usr/local/bin/libtoolize autoreconf -i
before executing configure
Compiling CLN
CLN still needs a lot of fixes to compile with MSVC.
Compiling GiNaC
Copy libcln.lib into ~/.wine/drive_c/cl/lib and the CLN headers into ~/.wine/drive_c/cl/include/cln
Get the source code from GiNaC MSVC support branch using the download button on the web page.
You can now run ./configure CC="wine cl" CXX="wine cl" LD="wine link" LIBTOOL=/usr/local/bin/libtool CPPFLAGS="-DEBUG -MD -EHsc -IC:/cl/VC/include -IC:/cl/SDK/Include -IC:/cl/include" LIB="C:/cl/VC/lib;C:/cl/SDK/lib;C:/cl/lib" --host=i586-mingw32msvc
(assuming that you are using the libtool installed into /usr/local). There are still a lot of libtool issues, though, which need to be hacked by editing libtool:
- The line starting with
old_archive_cmds
must read"wine lib -OUT:\$oldlib\$oldobjs\$old_deplibs"
. Note that this line occurs twice in the file! - The line starting with LTCFLAGS must read
LTCFLAGS="-g -IC:/cl/VC/include -IC:/cl/SDK/Include"
- Find the line containing
$cwrapper $cwrappersource
and addC:/cl/VC/lib/libcmt.lib C:/cl/VC/lib/oldnames.lib C:/cl/SDK/lib/Kernel32.lib
to the end of it - In the check (and other subdirectories), when linking fails edit the Makefile and add the following to the command starting with CXXLINK:
C:/cl/VC/lib/msvcrt.lib C:/cl/VC/lib/msvcprt.lib C:/cl/VC/lib/oldnames.lib C:/cl/SDK/lib/Kernel32.lib C:/cl/SDK/lib/Uuid.lib C:/cl/lib/libcln.lib
- After compilation, the wrapper created in the source directory does not work, but the .exe created in .libs does. Do
cp .libs/* .
before runningmake check
again.
After hacking away the libtool problems, GiNaC compiles and all 58 tests pass successfully.
Compiling EQC
Copy libginac.lib into ~/.wine/drive_c/cl/lib and the GiNaC headers into ~/.wine/drive_c/cl/include/ginac
Before starting, remove the ccache line in src/Makefile.am. Then, run env LIBTOOLIZE=/usr/local/bin/libtoolize autoreconf -i
and ./configure CC="wine cl" CXX="wine cl" LD="wine link" LIB="C:/cl/VC/lib;c:/cl/SDK/lib" CPPFLAGS="-DEBUG -MD -EHsc -IC:/cl/VC/include -IC:/cl/SDK/include -IC:/cl/include" --host=i586-mingw32msvc
. To get EQC to link successfully, you need to edit the Makefile and add the following to the command starting with CXXLINK C:/cl/VC/lib/msvcrt.lib C:/cl/VC/lib/msvcprt.lib C:/cl/VC/lib/oldnames.lib C:/cl/SDK/lib/Kernel32.lib C:/cl/SDK/lib/Uuid.lib C:/cl/lib/libcln.lib C:/cl/lib/libginac.lib
. If the Makefile has no such line, edit libeqc.la instead and change the line reading dependency_libs
to have these libraries (instead of the ones listed).
Preparing the OOo SDK
- Install Openoffice.org and the Openoffice SDK into wine using the standard Windows installation files.
- In the SDK base directory (e.g. ~/.wine/drive_c/Program Files/OpenOffice.org 3/Basis/sdk), put a file config.guess
echo wine; exit 0
. - Edit settings/settings.mk and add a section for wine:
########################################################################### # # Wine specific settings # ########################################################################### ifeq "$(PLATFORM)" "wine" # Settings for Wine cross-compilation using Microsoft compiler/linker # OS=WIN PS=/ ICL=$$ CC=wine cl LINK=wine link BUILDLIB=wine lib echo=echo MKDIR=mkdir -p MV=mv CAT=cat OBJ_EXT=obj EXE_EXT=.exe COPY=cp SHAREDLIB_EXT=dll SHAREDLIB_OUT=$(OUT_BIN) PACKAGE_LIB_DIR=windows.plt UNOPKG_PLATFORM=Windows # OSEP=\< CSEP=\> QUOTE= QM= SQM= ECHOLINE=echo. P2BG= # DEL=rm DELRECURSIVE=rm -r URLPREFIX=file:/// # SALLIB=isal.lib CPPULIB=icppu.lib CPPUHELPERLIB=icppuhelper.lib SALHELPERLIB=isalhelper.lib REGLIB=ireg.lib STORELIB=istore.lib STLPORTLIB=stlport_vc71$(STLDEBUG).lib # BLANK= EMPTYSTRING= PATH_SEPARATOR=; # use this for release version CC_FLAGS=-c -MT -Zm500 -Zc:forScope,wchar_t- -wd4251 -wd4275 -wd4290 -wd4675 -wd4786 -wd4800 -Zc:forScope -GR -EHa ifeq "$(CPP_MANIFEST)" "true" LINK_MANIFEST=mt -manifest $@.manifest "-outputresource:$@;2" else LINK_MANIFEST= endif ifeq "$(DEBUG)" "yes" CC_FLAGS+=-Zi endif # CC_INCLUDES=-I. -I$(OUT)/inc -I$(OUT)/inc/examples -I$(PRJ)/include -I"$(CPP_WINDOWS_VC)/include" -I"$(BASE)/cl/include" STL_INCLUDES=-I"$(OO_SDK_HOME)/include/stl" SDK_JAVA_INCLUDES = -I"$(OO_SDK_JAVA_HOME)/include" -I"$(OO_SDK_JAVA_HOME)/include/win32" # # define for used compiler necessary for UNO # -DCPPU_ENV=msci -- windows msvc 4.x - 7.x # CC_DEFINES=-DWIN32 -DWNT -D_DLL -DCPPU_ENV=msci CC_OUTPUT_SWITCH=-Fo # LIBRARY_LINK_FLAGS=/NODEFAULTLIB /DLL /DEBUGTYPE:cv COMP_LINK_FLAGS=$(LIBRARY_LINK_FLAGS) /DEF:$(PRJ)/settings/component.uno.def EXE_LINK_FLAGS=/MAP /OPT:NOREF /SUBSYSTEM:CONSOLE /BASE:0x1b000000 /DEBUGTYPE:cv /NODEFAULTLIB msvcrt.lib kernel32.lib ifeq "$(DEBUG)" "yes" LIBRARY_LINK_FLAGS+=/DEBUG EXE_LINK_FLAGS+=/DEBUG endif
- Go to sdk/bin and create an executable cppumaker
LD_LIBRARY_PATH=/usr/lib/ure/lib /usr/lib/openoffice/basis3.2/sdk/bin/cppumaker.bin "$@"
- Go to URE/bin and do
ln -s /usr/lib/ure/bin/regmerge .
. - We probably don't want to use regcomp, but anyway
ln -s /usr/lib/ure/bin/regcomp . ln -s /usr/lib/ure/bin/regcomp.bin .
- Install the OOo DLLs where wine can find them, e.g.
cp -i "~/.wine/drive_c/Program Files/OpenOffice.org 3/URE/bin/"*.dll ~/.wine/drive_c/windows/system32
- Before starting work, source this file (csh version)
# Created from setsdkenv_windows.bat of a Windows installation setenv BASE "/home/resap/.wine/drive_c" setenv OFFICE_HOME "$BASE/Program Files/OpenOffice.org 3" setenv OO_SDK_NAME "openoffice.org3.2_sdk" setenv OO_SDK_HOME "$BASE/Program Files/OpenOffice.org 3/Basis/sdk" setenv OFFICE_BASE_HOME "$BASE/Program Files/OpenOffice.org 3/Basis" setenv OO_SDK_URE_HOME "$BASE/Program Files/OpenOffice.org 3/URE" setenv OO_SDK_MAKE_HOME "/usr/bin" setenv OO_SDK_ZIP_HOME "/usr/bin" setenv OO_SDK_CPP_HOME "$BASE/windows/system32" setenv CPP_MANIFEST true setenv CPP_WINDOWS_SDK "$BASE/cl/SDK" setenv CPP_WINDOWS_VC "$BASE/cl/VC" setenv OO_SDK_OUT "." setenv SDK_AUTO_DEPLOYMENT NO # Set library path. setenv LIB "$OO_SDK_HOME/lib;$OO_SDK_URE_HOME/bin;$CPP_WINDOWS_SDK/lib;$CPP_WINDOWS_VC/lib" setenv OFFICE_PROGRAM_PATH "$OFFICE_HOME/program" setenv OFFICE_BASE_PROGRAM_PATH "$OFFICE_BASE_HOME/program" setenv UNO_PATH "$OFFICE_PROGRAM_PATH" setenv OO_SDK_URE_BIN_DIR "$OO_SDK_URE_HOME/bin" setenv OO_SDK_URE_LIB_DIR "$OO_SDK_URE_HOME/bin" setenv OO_SDK_URE_JAVA_DIR "$OO_SDK_URE_HOME/java" setenv OO_SDK_OFFICE_BIN_DIR "$OFFICE_PROGRAM_PATH" setenv OO_SDK_OFFICE_LIB_DIR "$OFFICE_BASE_PROGRAM_PATH" setenv OO_SDK_OFFICE_JAVA_DIR "$OFFICE_BASE_PROGRAM_PATH/classes"
Compiling iMath
Copy libeqc.lib into ~/.wine/drive_c/cl/lib and the headers into ~/.wine/drive_c/cl/include/libeqc.
Copy autosprintf.h from a MinGW installation into ~/.wine/drive_c/cl/include
./configure CC="wine cl" CXX="wine cl" LD="wine link" LIB="C:/cl/VC/lib;c:/cl/SDK/lib" CPPFLAGS="-DEBUG -MD -EHsc -IC:/cl/VC/include -IC:/cl/SDK/include -IC:/cl/include" --host=i586-mingw32msvc --build=i686-pc-linux-gnu
Edit src/Makefile and chnage the line starting with PRJ to the value of OO_SDK_HOME with spaces escaped (if there are no spaces in the path then you are fine).