emerge is unreliable for Windows x64

Pedro Lopez-Cabanillas pedro.lopez.cabanillas at gmail.com
Sun Feb 26 18:54:08 UTC 2012


Hi,

I am trying to setup a development environment for KDE in a
Windows7-64bit machine, without success so far. I've configured my
"kdesettings.bat" with KDECOMPILER=mingw4 and EMERGE_ARCHITECTURE=x64.

The problem is that some libraries have the wrong architecture. To
check the architecture of each DLL I've used the python script
included at the bottom of this message that parses and inspects the PE
file header. My first attempt was to compile kde-4.8, but failed
linking Qt, because some dependent libraries (from openssl) had the
wrong architecture:

C:\kde48>python pearch.py
C:\kde48\build\win32libs-bin\openssl-1.0.0d\image\bin\*.*
C:\kde48\build\win32libs-bin\openssl-1.0.0d\image\bin\libeay32.dll x86
C:\kde48\build\win32libs-bin\openssl-1.0.0d\image\bin\openssl.exe x86
C:\kde48\build\win32libs-bin\openssl-1.0.0d\image\bin\ssleay32.dll x86


I've tried also kde-4.7, but the problems were similar. This time, the
expat library was the problem when linking dbus:


entering: r:\build\win32libs-sources\dbus-src-1.4.10-20110302\work\mingw4-Debug-1.4.6
emerge debug: cmake -G "MinGW Makefiles"  -DDBUS_BUILD_TESTS=OFF
-DDBUS_ENABLE_XML_DOCS=OFF -DDBUS_USE_EXPAT=ON
-DDBUS_REPLACE_LOCAL_DIR=O
N -DDBUS_SESSION_BUS_DEFAULT_ADDRESS:STRING=autolaunch:scope=install-path
-DDBUS_USE_OUTPUT_DEBUG_STRING=ON  -DCMAKE_INSTALL_PREFIX="r:/"
-DCMAKE_INCLUDE_PATH="r:/include" -DCMAKE_LIBRARY_PATH="r:/lib"
-DCMAKE_PREFIX_PATH="r:/" -DCMAKE_BUILD_TYPE=Debug
"q:\dbus-src-git\cmake"

-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: r:/mingw64/bin/gcc.exe
-- Check for working C compiler: r:/mingw64/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: r:/mingw64/bin/g++.exe
-- Check for working CXX compiler: r:/mingw64/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- FIXME set DBUS_BUILD_TIMESTAMP to current date or fix current time
stamp generation for having actual build date in version file info
-- Could NOT find LibXml2 (missing:  LIBXML2_INCLUDE_DIR)
-- Found libexpat: r:/lib/libexpat.dll.a
[...]
Linking C executable ..\bin\dbus-daemon.exe
CMakeFiles\dbus-daemon.dir/objects.a(config-loader-expat.obj): In
function `bus_config_load':
q:/dbus-src-git/bus/config-loader-expat.c:199: undefined reference to
`XML_ParserCreate_MM'
q:/dbus-src-git/bus/config-loader-expat.c:220: undefined reference to
`XML_SetUserData'
q:/dbus-src-git/bus/config-loader-expat.c:221: undefined reference to
`XML_SetElementHandler'
q:/dbus-src-git/bus/config-loader-expat.c:224: undefined reference to
`XML_SetCharacterDataHandler'
q:/dbus-src-git/bus/config-loader-expat.c:245: undefined reference to
`XML_Parse'
q:/dbus-src-git/bus/config-loader-expat.c:252: undefined reference to
`XML_GetErrorCode'
q:/dbus-src-git/bus/config-loader-expat.c:256: undefined reference to
`XML_ErrorString'
q:/dbus-src-git/bus/config-loader-expat.c:256: undefined reference to
`XML_GetCurrentColumnNumber'
q:/dbus-src-git/bus/config-loader-expat.c:256: undefined reference to
`XML_GetCurrentLineNumber'
q:/dbus-src-git/bus/config-loader-expat.c:279: undefined reference to
`XML_ParserFree'
q:/dbus-src-git/bus/config-loader-expat.c:290: undefined reference to
`XML_ParserFree'
collect2: ld returned 1 exit status
gmake[2]: *** [bin/dbus-daemon.exe] Error 1
gmake[1]: *** [bus/CMakeFiles/dbus-daemon.dir/all] Error 2
gmake: *** [all] Error 2
emerge fatal error: while running make cmd: gmake
emerge fatal error: running python
r:\emerge\portage\win32libs-sources\dbus-src\dbus-src-1.4.10-20110302.py
compile
emerge debug: Task: Emerge stopped after: 0:03:39.680000

And indeed, the expat DLL placed at R:\bin has the wrong architecture:

R:\>python pearch.py R:\bin\*.dll
R:\bin\libexpat.dll x86

But there are more libexpat*.dll files at the system:

R:\bin\libexpat.dll x86
R:\build\dev-util\git-1.7.4\image\bin\libexpat-0.dll x86
R:\>python pearch.py
R:\build\dev-util\mingw-w64-20111031\image\mingw64\bin\libexpat-1.dll
(correct, it is x86_64!)
R:\build\win32libs-bin\expat-2.0.1\image\bin\libexpat.dll x86
R:\dev-utils\git\bin\libexpat-0.dll x86
R:\>python pearch.py R:\mingw64\bin\libexpat-1.dll  (correct, it is x86_64!)

So, there are two DLL with the correct architecture, and four incorrect ones.

If anybody wants to check his DLLs, the Python script depends on this module:
	http://code.google.com/p/pefile/

The PE format documentation is available here: Microsoft PE and COFF
Specification
	http://msdn.microsoft.com/en-us/windows/hardware/gg463119

Regards,
Pedro

--8<--

import sys
import glob
import pefile

arch = {
	0x0: 'Unknown',
	0x1d3: 'AM33',
	0x8664: 'x86_64',
	0x1c0: 'ARM',
	0xebc: 'EFI',
	0x14c: 'x86',
	0x200: 'IA64',
	0x9041: 'M32R',
	0x266: 'MIPS16',
	0x366: 'MIPS_FPU',
	0x466: 'MIPS16_FPU',
	0x1f0: 'PowerPC',
	0x1f1: 'PowerPC_FPU',
	0x166: 'MIPS',
	0x1a2: 'SH3',
	0x1a3: 'SH3_DSP',
	0x1a6: 'SH4',
	0x1a8: 'SH5',
	0x1c2: 'Thumb',
	0x169: 'MIPS_WCEv2'
}

def parseFile(fileName):
	if fileName.lower().endswith(".dll") or fileName.lower().endswith(".exe"):
		pe =  pefile.PE(fileName)
		if 0x8664 != pe.FILE_HEADER.Machine:
			print fileName, arch[pe.FILE_HEADER.Machine]

for arg in sys.argv:
	for f in glob.glob(arg):
		parseFile(f)


More information about the Kde-windows mailing list