Cross compiling page in techbase
Alexander Neundorf
neundorf at kde.org
Wed Mar 12 18:31:23 CET 2008
Hi,
On Wednesday 12 March 2008, Carlo wrote:
> On Tue, Mar 11, 2008 at 9:47 PM, Alexander Neundorf <neundorf at kde.org>
wrote:
> > On Tuesday 11 March 2008, Carlo wrote:
> > > On Tue, Mar 11, 2008 at 7:45 PM, Alexander Neundorf <neundorf at kde.org>
> >
> > wrote:
> > > > On Tuesday 11 March 2008, Carlo wrote:
> > > > > Hi, i've added a page in techbase with instruction to
> > > > > crosscompile kde for windows from linux
> > > > > http://techbase.kde.org/index.php?title=Getting_Started/Build/KDE
> > > > >4/Win dows/ CrossCompiling and i've linked it to
> > > >
> > > > Wow, _very_ cool ! :-)
> > > >
> > > > Some questions:
> > > >
> > > > Why do you need to preset all the variables starting with
> > > > KDE4_INSTALL_DIR, especially the KDE4_XXX_LIBRARY variables ?
> > >
> > > KDE4_INSTALL_DIR is just for convenience so you don't have to modify
> >
> > Why do you have to set CMAKE_MODULE_PATH ? This really shouldn't be
> > necessary. It is set at the top of kdelibs/CMakeLists.txt. What doesn't
> > work there ?
> >
> > Why do you set the KDE4_xxx_LIBRARY variables ? They also really
> > shouldn't be necessary. What are the errors ?
>
> Yeah that's unnecessary, i set that because i've seen this line when
> running cmake
> -- Adding /home/kdeuser/kde/share/apps/cmake/modules to CMAKE_MODULE_PATH
> and that's the linux kde4 modules dir so i tought that it could
> conflict with the windows one and cant' automatically find
> KDE4_xxx_LIBRARY for that reason but it adds that line anyway in
> FindQt4 iirc
>
> if I don't set KDE4_KDECORE_LIBRARY cmake gives this error
> CMake Error: ERROR: could NOT find everything required for compiling
> KDE 4 programs
>
> while for other libraries it says something like this
> KDE4_PHONON_LIBRARY
> linked by target "knotify" in directory
> /home/kdeuser/kde/src/KDE/kdebase/runtime/knotify
> linked by target "konq_sound" in directory
> /home/kdeuser/kde/src/KDE/kdebase/apps/lib/konq
Ahh, so this is already in kdebase.
I have split your file into two parts:
Toolchain-mingw32.cmake which has to be used as toolchain file for every KDE
module (i.e. also kdelibs) and mingw32-kdelibs.cmake which contains settings
which should come from the installed kdelibs (i.e. it must not be used for
kdelibs).
The problem here was that FindKDE4.cmake runs kde4-config and checks what this
returns.
I attached a modified FindKDE4.cmake file which only executes kde4-config if
KDE4_DATA_DIR is not set.
So by setting KDE4_DATA_DIR in mingw32-kdelibs.cmake this FindKDE4.cmake
should work as expected for cross compiling.
I forgot, so you have to use Toolchain-mingw32.cmake
with -DCMAKE_TOOLCHAIN_FILE=..., and the other file to preload the cmake
cache, which is done using -C <filename>.
So for kdebase you would need something like:
cmake -DCMAKE_TOOLCHAIN_FILE=<path>/Toolchain-mingw32.cmake -C
<path>/mingw32-kdelibs.cmake <src dir>
> > > the path for all set, I have to specify some kde/qt library because
> > > cmake can't find them itself and
> > > i have disabled dnssd/avahi etc..
> >
> > That's ok.
> >
> > > because cmake find the linux one and think that it's good
> >
> > This shouldn't happen.
> > For which packages does it find the wrong versions ?
> > Can you please post the complete list, with the location of the windows
> > versions and what cmake found ?
> > (maybe these are packages where pkg-config is used...)
>
> the problem is GSSAPI, this is what cmake found
> GSSAPI_FLAVOR MIT
> GSSAPI_INCS
> GSSAPI_LIBS -L/usr/lib -lgssapi_krb5 -lkrb5
> -lk5crypto -lcom_err
>
> i don't have gssapi and the other libraries that i've disabled on
> windows(and they don't exist in the kdewin installer either)
The problem here is that FindGSSAPI.cmake runs krb5-config and querys this for
information. Problem is that when cross compiling in general the executables
from the target cannot be executed.
We'll care for this one later.
> > > > Some comments:
> > > > > you have to make a link to your kde4automoc for linux in the bin
> > > > >
> > > > > directory
> > > >
> > > > we should be able to fix that...
> > > >
> > > > > since linux is case sensitive you have to make symbolic links for
> > > > > some headers
> > > >
> > > > Can't this be corrected in the source files where the headers are
> > > > included ?
> > >
> > > yeah this can be fixed in the source file too(maybe soprano would
> > > require an ifdef since there are both soprano and Soprano on linux),
> > > but link was easier to do
> >
> > We should definitely fix it.
> > Can you commit or do you have to create a patch ?
>
> Yes i can commit i will change that includes later
Yes, please do :-)
> > > > > You will get a linker error on kjsembed so from the build
> > > > > directory cd into kjsembed/kjsembed and make VERBOSE=1
> > > > > 2>/dev/null
> > > >
> > > > what's the problem here with linking ?
> > > > This shouldn't happen, we have to fix it.
> > >
> > > it's a long linker error about QtUiTools it can't find anything
> > > related to qt(QString, QDataStream etc..)
> >
> > Can you please post the linker command and the complete error message ?
>
> this is the linker command:
> Linking CXX shared library ../../bin/libkjsembed.dll
> cd /home/kdeuser/kde/src/KDE/kdelibs/build/kjsembed/kjsembed &&
> /usr/local/bin/cmake -E cmake_link_script
> CMakeFiles/kjsembed.dir/link.txt --verbose=1
> /usr/bin/i586-mingw32msvc-g++ -Wl,--export-all-symbols
> -Wl,--disable-auto-import -shared -o ../../bin/libkjsembed.dll
> -Wl,--out-implib,../../bin/libkjsembed.dll.a
> -Wl,--major-image-version,4,--minor-image-version,1
> CMakeFiles/kjsembed.dir/kjsembed_automoc.cpp.obj
> CMakeFiles/kjsembed.dir/kjseglobal.cpp.obj
> CMakeFiles/kjsembed.dir/binding_support.cpp.obj
...
> CMakeFiles/kjsembed.dir/quiloader_binding.cpp.obj -L/windows/kde4/lib
> ../../bin/libkdecore.dll.a /windows/kde4/lib/libQtCore4.a
> /windows/kde4/lib/libQtUiTools.a /windows/kde4/lib/libQtGui4.a
> /windows/kde4/lib/libQtSvg4.a ../../bin/libkjs.dll.a
> /windows/kde4/lib/libQtNetwork4.a /windows/kde4/lib/libQtDBus4.a
> /windows/kde4/lib/libz.dll.a /windows/kde4/lib/libkdewin32.dll.a
> -luser32 -lshell32 -lws2_32 -lnetapi32 -luserenv
> /windows/kde4/lib/libQtXml4.a /windows/kde4/lib/libbzip2.dll.a
> /windows/kde4/lib/libintl.dll.a /windows/kde4/lib/libpcre.dll.a
> /windows/kde4/lib/libpcreposix.dll.a
>
>
> and this is the long error message http://kde.pastebin.com/f3aa4d4f6
Ok. This is as far as I see always undefined references from QtUiTools to
QtCore:
> /windows/kde4/lib/libQtUiTools.a(quiloader.o):quiloader.cpp:(.text+0x7fd):
> undefined reference to `__imp___ZNK7QString6toUtf8Ev'
Which value does QT_QTUITOOLS_LIBRARY have ?
> > > > > You will get another error in klauncher.moc about slotKDEInitData
> > > > > so go into kinit and do something like this(you need wine)
> > > >
> > > > What's the exact problem here ?
> > > > Does the Windows moc have to be used ? Why ?
> > >
> > > slotKDEInitData doesn't exist on windows
> > > http://lxr.kde.org/source/KDE/kdelibs/kinit/klauncher.h#179 but
> > > kde4automoc thinks that we are on linux maybe, so maybe we should use
> > > the windows version for everything
> >
> > Hmm, if we are cross compiling to Windows Q_WS_WIN should be defined.
> > Can you find out why it isn't ?
>
> Q_WS_WIN is defined when compiling but not in moc, probably it has
> hardcoded parameters from the platform where it was compiled
Hmm, that sounds bad. Let's care about this later.
> > > > > Another error in kdewidgets because wine doesn't find some dll to
> > > > > run makekdewidgets.exe so either run the linux version manually
> > > > > like this
> > > >
> > > > So you run the generated executables using wine ? Interesting. The
> > > > idea was to use "native" executables if cross compiling. But if it
> > > > works, ok.
> > > >
> > > > Alex
> > >
> > > for some strange reason for kde4automoc it calls ../bin/kde4automoc
> > > instead of ../bin/kde4automoc.exe one that's why i made the link in
Is the .exe extension really required to run the executable ?
Under Windows it isn't. Is this a wine speciality ?
I'd really like to get this working cleanly, it's still time to fix things in
cmake for cross compiling, 2.6.0 hasn't been released yet.
Alex
-------------- next part --------------
# Find KDE4 and provide all necessary variables and macros to compile software for it.
# It looks for KDE 4 in the following directories in the given order:
# CMAKE_INSTALL_PREFIX
# KDEDIRS
# /opt/kde4
#
# Please look in FindKDE4Internal.cmake and KDE4Macros.cmake for more information.
# They are installed with the KDE 4 libraries in $KDEDIRS/share/apps/cmake/modules/.
#
# Author: Alexander Neundorf <neundorf at kde.org>
FILE(TO_CMAKE_PATH "$ENV{KDEDIRS}" _KDEDIRS)
# For KDE4 kde-config has been renamed to kde4-config
FIND_PROGRAM(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config
PATH_SUFFIXES bin # the suffix is for the paths coming from KDEDIRS
PATHS
${CMAKE_INSTALL_PREFIX}/bin
${_KDEDIRS}
/opt/kde4/bin
NO_DEFAULT_PATH
)
FIND_PROGRAM(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config )
IF (NOT KDE4_KDECONFIG_EXECUTABLE)
IF (KDE4_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "ERROR: Could not find KDE4 kde4-config")
ENDIF (KDE4_FIND_REQUIRED)
ENDIF (NOT KDE4_KDECONFIG_EXECUTABLE)
# when cross compiling, it may be already preset
IF(NOT KDE4_DATA_DIR)
# then ask kde4-config for the kde data dirs
EXECUTE_PROCESS(COMMAND "${KDE4_KDECONFIG_EXECUTABLE}" --path data OUTPUT_VARIABLE _data_DIR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
FILE(TO_CMAKE_PATH "${_data_DIR}" _data_DIR)
# then check the data dirs for FindKDE4Internal.cmake
FIND_PATH(KDE4_DATA_DIR cmake/modules/FindKDE4Internal.cmake ${_data_DIR})
ENDIF(NOT KDE4_DATA_DIR)
# if it has been found...
IF (KDE4_DATA_DIR)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${KDE4_DATA_DIR}/cmake/modules)
IF (KDE4_FIND_QUIETLY)
SET(_quiet QUIET)
ENDIF (KDE4_FIND_QUIETLY)
IF (KDE4_FIND_REQUIRED)
SET(_req REQUIRED)
ENDIF (KDE4_FIND_REQUIRED)
# use FindKDE4Internal.cmake to do the rest
FIND_PACKAGE(KDE4Internal ${_req} ${_quiet})
ELSE (KDE4_DATA_DIR)
IF (KDE4_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "ERROR: cmake/modules/FindKDE4Internal.cmake not found in ${_data_DIR}")
ENDIF (KDE4_FIND_REQUIRED)
ENDIF (KDE4_DATA_DIR)
-------------- next part --------------
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)
# which compilers to use for C and C++
SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc /windows/kde4 )
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# FindQt4.cmake querys qmake to get information, this doesn't work when crosscompiling
set(QT_BINARY_DIR /home/kdeuser/kde/src/qt-copy/bin)
set(QT_LIBRARY_DIR ${KDE4_INSTALL_DIR}/lib)
set(QT_QTCORE_LIBRARY ${KDE4_INSTALL_DIR}/lib/libQtCore4.a)
set(QT_QTCORE_INCLUDE_DIR ${KDE4_INSTALL_DIR}/include/QtCore)
set(QT_MKSPECS_DIR ${KDE4_INSTALL_DIR}/mkspecs)
set(QT_MOC_EXECUTABLE ${QT_BINARY_DIR}/moc)
set(QT_QMAKE_EXECUTABLE ${QT_BINARY_DIR}/qmake)
set(QT_UIC_EXECUTABLE ${QT_BINARY_DIR}/uic)
-------------- next part --------------
# this one is used by FindKDE4.cmake to load FindKDE4Internal.cmake:
set(KDE4_DATA_DIR /windows/kde4/share/apps CACHE PATH "points to the apps directory of installed kdelibs")
# not sure about this one:
set(KDEWIN_DIR ${KDE4_INSTALL_DIR} CACHE PATH "what is it ?")
# disable some things:
set(WITH_AVAHI OFF CACHE BOOL "Disabled")
set(WITH_DNSSD OFF CACHE BOOL "Disabled")
set(WITH_ENCHANT OFF CACHE BOOL "Disabled")
set(WITH_FAM OFF CACHE BOOL "Disabled")
set(WITH_GSSAPI OFF CACHE BOOL "Disabled")
set(WITH_HSPELL OFF CACHE BOOL "Disabled")
set(WITH_OpenEXR OFF CACHE BOOL "Disabled")
More information about the Kde-windows
mailing list