Cross compiling libwebsockets with cmake - c++

I am trying to cross-compile libwebsockets with cmake, but I am getting the below errors:
root#ubuntu-Latitude-E5450:/home/ubuntu/Downloads/libwebsockets/build# cmake .. -DCMAKE_INSTALL_PREFIX_PATH=/home/ubuntu/toolchain/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/ -DCMAKE_LIBRARY_PATH=/home/ubuntu/toolchain/sysroots/aarch64-oe-linux/usr/lib/ -DCMAKE_SYSROOT=/ubuntu/home/das_toolchain/sysroots/aarch64-oe-linux/ -DCMAKE_TOOLCHAIN_FILE=../cross-arm-oe-linux-gnueabi.cmake -DLWS_WITHOUT_EXTENSIONS=1 -DLWS_WITH_SSL=0 -DLWS_WITH_ZIP_FOPS=0 -DLWS_WITH_ZLIB=0
-- The C compiler identification is GNU 4.9.3
-- Check for working C compiler: /home/ubuntu/das_toolchain/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc
-- Check for working C compiler: /home/ubuntu/das_toolchain/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc -- broken
CMake Error at /usr/local/share/cmake-3.8/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler
"/home/ubuntu/das_toolchain/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/ubuntu/Downloads/libwebsockets/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_515b7/fast"
/usr/bin/make -f CMakeFiles/cmTC_515b7.dir/build.make
CMakeFiles/cmTC_515b7.dir/build
make[1]: Entering directory
`/home/ubuntu/Downloads/libwebsockets/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_515b7.dir/testCCompiler.c.o
/home/ubuntu/das_toolchain/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc
--sysroot=/ubuntu/home/das_toolchain/sysroots/aarch64-oe-linux/ -o
CMakeFiles/cmTC_515b7.dir/testCCompiler.c.o -c
/home/ubuntu/Downloads/libwebsockets/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_515b7
/usr/local/bin/cmake -E cmake_link_script
CMakeFiles/cmTC_515b7.dir/link.txt --verbose=1
/home/ubuntu/das_toolchain/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc
--sysroot=/ubuntu/home/das_toolchain/sysroots/aarch64-oe-linux/ -rdynamic
CMakeFiles/cmTC_515b7.dir/testCCompiler.c.o -o cmTC_515b7
/home/ubuntu/toolchain/sysroots/x86_64-oesdk-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.9.3/real-ld:
error: cannot open crt1.o: No such file or directory
/home/ubuntu/toolchain/sysroots/x86_64-oesdk-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.9.3/real-ld:
error: cannot open crti.o: No such file or directory
/home/ubuntu/toolchain/sysroots/x86_64-oesdk-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.9.3/real-ld:
error: cannot open crtbegin.o: No such file or directory
/home/ubuntu/toolchain/sysroots/x86_64-oesdk-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.9.3/real-ld:
error: cannot open crtend.o: No such file or directory
/home/ubuntu/toolchain/sysroots/x86_64-oesdk-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.9.3/real-ld:
error: cannot open crtn.o: No such file or directory
/home/ubuntu/toolchain/sysroots/x86_64-oesdk-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.9.3/real-ld:
error: cannot find -lgcc
/home/ubuntu/toolchain/sysroots/x86_64-oesdk-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.9.3/real-ld:
error: cannot find -lgcc_s
/home/ubuntu/toolchain/sysroots/x86_64-oesdk-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.9.3/real-ld:
error: cannot find -lc
/home/ubuntu/toolchain/sysroots/x86_64-oesdk-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.9.3/real-ld:
error: cannot find -lgcc
/home/ubuntu/toolchain/sysroots/x86_64-oesdk-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.9.3/real-ld:
error: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
make[1]: *** [cmTC_515b7] Error 1
make[1]: Leaving directory
`/home/ubuntu/Downloads/libwebsockets/build/CMakeFiles/CMakeTmp'
make: *** [cmTC_515b7/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:146 (project)
-- Configuring incomplete, errors occurred!
See also "/home/ubuntu/Downloads/libwebsockets/build/CMakeFiles/CMakeOutput.log".
See also "/home/ubuntu/Downloads/libwebsockets/build/CMakeFiles/CMakeError.log".
I have specified the CMAKE_SYSROOT in the toolchain file and also specified the same in my command line while building. Where am I going wrong with this?
Your help would be appreciated.
Below is my toolchain file:
#
# CMake Toolchain file for crosscompiling on ARM.
#
# This can be used when running cmake in the following way:
# cd build/
# cmake .. -DCMAKE_TOOLCHAIN_FILE=../cross-arm-oe-linux-gnueabi.cmake
#
set(CROSS_COMPILER_PATH /home/ubuntu/das_toolchain/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/)
set(CROSS_PATH /ubuntu/home/das_toolchain/sysroots/aarch64-oe-linux/)
set(TOOLCHAIN_PREFIX arm-oe-linux-gnueabi-)
#set(SYSROOT --sysroot=/ubuntu/home/das_toolchain/sysroots/aarch64-oe-linux/)
set(CMAKE_SYSROOT /ubuntu/home/das_toolchain/sysroots/aarch64-oe-linux/)
# Target operating system name.
#set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_NAME Arm)
# Name of C compiler.
#set(CMAKE_C_COMPILER "${CROSS_PATH}/bin/arm-linux-gnueabihf-gcc")
#set(CMAKE_CXX_COMPILER "${CROSS_PATH}/bin/arm-linux-gnueabihf-g++")
#set(CMAKE_C_COMPILER "${CROSS_PATH}${TOOLCHAIN_PREFIX}gcc ${SYSROOT}")
#set(CMAKE_CXX_COMPILER "${CROSS_PATH}${TOOLCHAIN_PREFIX}g++ ${SYSROOT}")
set(CMAKE_C_COMPILER "${CROSS_COMPILER_PATH}${TOOLCHAIN_PREFIX}gcc")
set(CMAKE_CXX_COMPILER "${CROSS_COMPILER_PATH}${TOOLCHAIN_PREFIX}g++")
#set(CMAKE_C_FLAGS ${SYSROOT})
#set(CMAKE_CXX_FLAGS ${SYSROOT})
# Where to look for the target environment. (More paths can be added here)
set(CMAKE_FIND_ROOT_PATH "${CROSS_PATH}")
# Adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment only.
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Search headers and libraries in the target environment only.
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

In my experience, using CMAKE_SYSROOT can cause issues like this sometimes since it passes the --sysroot flag to the compiler, which can confuse it. To tell CMake where to find libraries, without affecting the actual compiler options, just set CMAKE_PREFIX_PATH instead of CMAKE_SYSROOT.

Related

ld.lld: error: could not open 'libLIBCMTD.a': No such file or directory

I recently installed vspkg and tried to build my c++ application with libcurl using command vcpkg.exe install curl:x64-windows-static
After i tried to compile it, i got an error on linking stage
ld.lld: error: could not open 'libLIBCMTD.a': No such file or directory
ld.lld: error: could not open 'libOLDNAMES.a': No such file or directory
collect2.exe: error: ld returned 1 exit status
mingw32-make[3]: *** [CMakeFiles\testEnv.dir\build.make:140: C:/Users/Administrator/libtestEnv.dll] Error 1
mingw32-make[2]: *** [CMakeFiles\Makefile2:82: CMakeFiles/testEnv.dir/all] Error 2
mingw32-make[1]: *** [CMakeFiles\Makefile2:89: CMakeFiles/testEnv.dir/rule] Error 2
mingw32-make: *** [Makefile:123: testEnv] Error 2
I also tried to install curl library non-static and everything went successfully but i want to have everything linked as one libary so it's not a good solution
My CMakeLists.txt
cmake_minimum_required(VERSION 3.20)
project(testEnv)
# remove names of functions and optimize
set(CMAKE_CXX_FLAGS "-nolibc -s -O3 -Os -fdata-sections -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -fuse-ld=lld")
set(CMAKE_CXX_STANDARD 17)
find_package(CURL CONFIG REQUIRED)
add_library(testEnv SHARED main.cpp)
target_link_libraries(testEnv CURL::libcurl)
#collect all needed libraries to run
target_link_libraries(testEnv -static)
Any ideas how to fix that problem with linking? Maybe there is any solutions which would allow to exclude those problematic libs?
mingw32-make
looks like you are using mingw. Consider using the correct vcpkg triplet, e.g. x64-mingw-static.cmake.
x64-windows-static will use an installed VS toolchain.
Be aware that you also need to set -DVCPKG_TARGET_TRIPLET=x64-mingw-static and -DVCPKG_HOST_TRIPLET=x64-mingw-static in your cmake call. Also make sure cmake does clean configure.

Building a simple C++ project on Windows, using CMake and clang

I'm trying to get a simple 'Hello World' program to build on Windows 10, preferably using CMake and clang. I can successfully compile, link and run the same project if I use the g++ compiler from MinGW, but have problems when I try using clang++.
I have CMake, MinGW and LLVM already installed and accessible in my path:
clang++
clang++: error: no input files
cmake --version
cmake version 3.16.0-rc1
I have set up environment variables for CMake to use clang:
echo %CC%
C:\Program Files\LLVM\bin\clang.exe
echo %CXX%
C:\Program Files\LLVM\bin\clang++.exe
Now when I run cmake with my simple "Hello World" C++ project, cmake complains about not being able to use clang:
cmake -G "MinGW Makefiles" ..
-- The CXX compiler identification is Clang 9.0.0 with GNU-like command-line
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake:53 (message):
The C++ compiler
"C:/Program Files/LLVM/bin/clang++.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/pball/git/bchest/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/mingw32-make.exe cmTC_838da/fast && C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/mingw32-make.exe -f CMakeFiles\cmTC_838da.dir\build.make CMakeFiles/cmTC_838da.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/pball/git/bchest/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_838da.dir/testCXXCompiler.cxx.obj
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -o CMakeFiles\cmTC_838da.dir\testCXXCompiler.cxx.obj -c C:\Users\pball\git\bchest\build\CMakeFiles\CMakeTmp\testCXXCompiler.cxx
Linking CXX executable cmTC_838da.exe
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_838da.dir\link.txt --verbose=1
C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -fuse-ld=lld-link -nostartfiles -nostdlib -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd #CMakeFiles\cmTC_838da.dir\objects1.rsp -o cmTC_838da.exe -Xlinker /implib:cmTC_838da.lib -Xlinker /pdb:C:\Users\pball\git\bchest\build\CMakeFiles\CMakeTmp\cmTC_838da.pdb -Xlinker /version:0.0 #CMakeFiles\cmTC_838da.dir\linklibs.rsp
lld-link: error: could not open 'kernel32.lib': no such file or directory
lld-link: error: could not open 'user32.lib': no such file or directory
lld-link: error: could not open 'gdi32.lib': no such file or directory
lld-link: error: could not open 'winspool.lib': no such file or directory
lld-link: error: could not open 'shell32.lib': no such file or directory
lld-link: error: could not open 'ole32.lib': no such file or directory
lld-link: error: could not open 'oleaut32.lib': no such file or directory
lld-link: error: could not open 'uuid.lib': no such file or directory
lld-link: error: could not open 'comdlg32.lib': no such file or directory
lld-link: error: could not open 'advapi32.lib': no such file or directory
lld-link: error: could not open 'oldnames.lib': no such file or directory
lld-link: error: could not open 'msvcrtd.lib': no such file or directory
CLANG_~1: error: linker command failed with exit code 1 (use -v to see invocation)
mingw32-make.exe[1]: *** [CMakeFiles\cmTC_838da.dir\build.make:88: cmTC_838da.exe] Error 1
mingw32-make.exe[1]: Leaving directory 'C:/Users/pball/git/bchest/build/CMakeFiles/CMakeTmp'
mingw32-make.exe: *** [Makefile:120: cmTC_838da/fast] Error 2
This is a freshly installed Windows 10 PC. It has no Visual Studio nor any Microsoft development tool installed on it. If possible I would prefer not having to install the Visual Studio for example to get the msvcrtd.lib. I am using VS Code at the moment, but this should be independent of the IDE being used.
My question is, what exactly do I have to install apart from LLVM, CMake and MinGW to make my first simple C++ project to build?
You are missing the libraries in the linker flag. These libraries may be found in the following location:
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17134.0\um\x86
The exact path on your system may vary depending on the OS version etc., but you get the idea i believe. After finding the location you can add the path to the compiler flag in the CMakeLists.txt file e.g.,
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xlinker /libpath:path_to_library")
See related answers:
https://software.intel.com/en-us/forums/intel-fortran-compiler/topic/784047
https://stackoverflow.com/a/48576249/811335
How /libpath flag is used:
https://learn.microsoft.com/en-us/cpp/build/reference/libpath-additional-libpath?view=vs-2019
To force Clang to use its own libraries instead of MSVC's, add "-target x86_64-w64-mingw32" to CMAKE_C(XX)_FLAGS.
Beware: you have to do this before CMake identifies the compiler, e.g. either before the first C or C++ project definition in CMake (e.g. before the project() call):
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -target x86_64-w64-mingw32")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -target x86_64-w64-mingw32")
project(MyProject ...)
Alternatively, you can pass it with "-D" to CMake on the command line.
Tested with clang 10.0
If I remember correctly, Clang attempts to use MSVC's standard library on Windows by default, since Clang's own standard library doesn't work on Windows yet.
If you don't have MSVC installed, this causes problems.
The easiest solution is to install MSYS2 and use MSYS2's patched Clang, which uses GCC's libraries by default. As a nice bonus, MSYS2 also comes with an up-to-date GCC version.
Alternatively, you can use -target flag to tell Clang to use GCC's libraries. If I remember correctly, this is done by adding -target x86_64-w64-mingw32 to both compiler and linker flags.
(If it doesn't work, try -target x86_64-w64-windows-gnu, I can't remember which one it is. Replace x86_64 with i686 if you're using a 32-bit compiler.)
Your Clang compiler is probably built to target the MSVC ABI. If I try your scenario, this is my error message:
-- The CXX compiler identification is Clang 9.0.0
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/CMakeDetermineCompilerId.cmake:802 (message): The Clang compiler tool
"C:/Program Files/LLVM/bin/clang++"
targets the MSVC ABI but has a GNU-like command-line interface. This is not supported. Use 'clang-cl' instead, e.g. by setting 'CXX=clang-cl' in the environment. Furthermore, use the MSVC command-line environment.
This was with CMake 3.13 and LLVM 9.0, and trying to use -G "MinGW Makefiles". It works using this:
SET CXX="C:/Program Files/LLVM/bin/clang-cl.exe"
cmake -G "NMake Makefiles" ..
You probably don't need to install Visual Studio, but if you want to use nmake and the MSVC libraries, you definitely need the Windows 10 SDK which is a big download, and it will be installed as well if you decide to install Visual Studio.
On the other hand, The problem seems to be related to the CMake 3.16 version. The above unsucessful tests were made with cmake 3.13, but after that I've upgraded to CMake 3.15.5 and it works perfectly. Here are the exact versions:
> cmake -version
cmake version 3.15.5
> clang++ --version
clang version 9.0.0 (tags/RELEASE_900/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
My build.cmd script:
SET CXX="C:/Program Files/LLVM/bin/clang++.exe"
cmake -G "MinGW Makefiles" ..
So the problem may be with your CMake version, or the MinGW libraries, as your error message is suggesting.

Cross compiling with clang on cmake, linker does not support armelf_linux_eabi

Here's my cmake toolchain file to cross compile for arm linux:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CLANG_TARGET_TRIPLE arm-linux-gnueabihf)
set(GCC_ARM_TOOLCHAIN_PREFIX ${CLANG_CLANG_TARGET_TRIPLE})
set(CMAKE_C_COMPILER clang)
set(CMAKE_C_COMPILER_TARGET ${CLANG_TARGET_TRIPLE})
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_CXX_COMPILER_TARGET ${CLANG_TARGET_TRIPLE})
set(CMAKE_ASM_COMPILER clang)
set(CMAKE_ASM_COMPILER_TARGET ${CLANG_TARGET_TRIPLE})
Here's the problem when I execute cmake with it:
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/usr/bin/clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/lz/orwell/gtk/build/armlinux/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_8132a/fast"
/usr/bin/make -f CMakeFiles/cmTC_8132a.dir/build.make CMakeFiles/cmTC_8132a.dir/build
make[1]: Entering directory '/home/lz/orwell/gtk/build/armlinux/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_8132a.dir/testCCompiler.c.o
/usr/bin/clang --target=arm-linux-gnueabihf -o CMakeFiles/cmTC_8132a.dir/testCCompiler.c.o -c /home/lz/orwell/gtk/build/armlinux/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_8132a
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_8132a.dir/link.txt --verbose=1
/usr/bin/clang --target=arm-linux-gnueabihf -rdynamic CMakeFiles/cmTC_8132a.dir/testCCompiler.c.o -o cmTC_8132a
/usr/bin/ld: unrecognised emulation mode: armelf_linux_eabi
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386linux elf_l1om elf_k1om i386pep i386pe
clang: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/cmTC_8132a.dir/build.make:97: recipe for target 'cmTC_8132a' failed
make[1]: *** [cmTC_8132a] Error 1
make[1]: Leaving directory '/home/lz/orwell/gtk/build/armlinux/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_8132a/fast' failed
make: *** [cmTC_8132a/fast] Error 2
It looks like it's trying to use /bin/ld instead of clang's linker (is there one?). I know that there exists CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN but I don't know the path to include and preferably I didn't want to include any paths, I'd like to make it work without path specification.
So, how to specify a compatible linker?

Unable to Change Default Linker in CMake

I am trying to change my linker to ld.gold so that I can build LLVM and
CLANG faster. I have changed my environment variable with:
export LD=ld.gold
and I have changed CMAKE_LINKER in ccmake to /usr/bin/ld.gold. However,
when I generate the files, my linker is detected as GNU ld. Running top
during compilation confirms that ld is running rather than gold.
When editing the CMake Link Executable variable to:
cmake -DCMAKE_LINKER=/usr/bin/ld.gold -DCMAKE_CXX_LINK_EXECUTABLE="<CMAKE_LINKER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" -G "Unix Makefiles" ../llvm
I receive the following error:
/usr/bin/ld.gold: -Werror=date-time: unknown option
/usr/bin/ld.gold: use the --help option for usage information
utils/PerfectShuffle/CMakeFiles/llvm-PerfectShuffle.dir/build.make:94: recipe for target 'bin/llvm-PerfectShuffle' failed
make[2]: *** [bin/llvm-PerfectShuffle] Error 1
CMakeFiles/Makefile2:13983: recipe for target 'utils/PerfectShuffle/CMakeFiles/llvm-PerfectShuffle.dir/all' failed
I'm on Ubuntu 16.04, but I have had the same problem on Arch Linux.
Thank You.
CMAKE_EXE_LINKER_FLAGS=-fuse-ld=gold will pass -fuse-ld=gold to the compiler, which will properly use the gold linker.

Compiling Qt 4.8.5 using mingw32 on windows7: "no such file or directory"

I'm trying to build qt-4.8.5 (opensource) from source using mingw32 compiler on windows 7.
"configure" works fine, but compilation (mingw32-make) fails with this output:
D:\development\qt-4.8.5-mingw>mingw32-make
cd src/tools/bootstrap/ && D:/development/MinGW/bin/mingw32-make.EXE -f Makefile
mingw32-make.EXE[1]: Entering directory 'd:/development/qt-4.8.5-mingw/src/tools/bootstrap'
D:/development/MinGW/bin/mingw32-make.EXE -f Makefile.Release
mingw32-make.EXE[2]: Entering directory 'd:/development/qt-4.8.5-mingw/src/tools/bootstrap'
g++ -c -pipe -fno-keep-inline-dllexport -O2 -frtti -fexceptions -mthreads -Wall -Wextra -DUNICODE -DQT_BOOTSTRAPPED -DQT_LITE_UNICODE -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_CODECS -DQT_NO_DATASTREAM -DQT_NO_GEOM_VARIANT -DQT_NO_LIBRARY -DQT_NO_QOBJECT -DQT_NO_STL -DQT_NO_SYSTEMLOCALE -DQT_NO_TEXTSTREAM -DQT_NO_THREAD -DQT_NO_UNICODETABLES -DQT_NO_USING_NAMESPACE -DQT_NO_DEPRECATED -DQT_NODLL -I'../../../include' -I'../../../include/QtCore' -I'../../../include/QtXml' -I'../../3rdparty/zlib' -I'd:/development/MSVS2008EXP/VC/INCLUDE' -I'd:/development/Microsoft SDKs/Windows/v6.1/include' -I'd:/development/MSVS2008EXP/VC/lib/' -I'd:/development/MS_SDKs/Windows/v6.1/Lib' -I'd:/DXSDK/Lib/x86' -I'../../../mkspecs/win32-g++-4.6' -o tmp/obj/release_shared/qisciicodec.o ../../corelib/codecs/qisciicodec.cpp
g++: error: CreateProcess: No such file or directory
Makefile.Release:333: recipe for target 'tmp/obj/release_shared/qisciicodec.o' failed
mingw32-make.EXE[2]: *** [tmp/obj/release_shared/qisciicodec.o] Error 1
mingw32-make.EXE[2]: Leaving directory 'd:/development/qt-4.8.5-mingw/src/tools/bootstrap'
Makefile:34: recipe for target 'release' failed
mingw32-make.EXE[1]: *** [release] Error 2
mingw32-make.EXE[1]: Leaving directory 'd:/development/qt-4.8.5-mingw/src/tools/bootstrap'
Makefile:68: recipe for target 'sub-tools-bootstrap-make_default-ordered' failed
mingw32-make.EXE: *** [sub-tools-bootstrap-make_default-ordered] Error 2
I.e.:
g++: error: CreateProcess: No such file or directory
Because g++ DOESN'T print which file it can't find, I'm not certain what could be causing this.
I can call g++, gcc and mingw32-make from command line and they're in Path.
I've removed VC directories, MS SDK directories, and this doesn't fix the problem either.
This is a clean "install", I extracted tar.gz contents, and run configure without modifying anything. Adding mingw include path via -I switch to configure doesn't fix the problem.
How do I fix this?
Additional info:
g++ version: 4.7.1
mingw32-make version: 3.82.90
Figured it out. (Well, I still don't know what was causing this, but I know how to make it work).
Solution:
Place qt.conf into qt "bin" directory.
[Paths]
Prefix = d:/development/qt-4.8.5-mingw
Prefix is path of your qt installation (notice forward slashes).
Configure and compile using bat files:
To configure:
set QTDIR=D:\development\qt-4.8.5-mingw
set QMAKESPEC=win32-g++
set PATH=D:\development\MinGW\bin;D:\development\tools\Perl32\bin;D:\development\qt-4.8.5-mingw\bin
set PATH=%PATH%;c:\Windows\system32
set INCLUDE=
set LIB=
set CPATH=
set CPLUS_INCLUDE_PATH=
set LANG=en
configure -opensource -openssl
You should put into path bin directory of 32bit perl, bin directory of mingw32 installation, and bin directory of qt installation. -openssl key is optional (I need this one).
To compile:
set QTDIR=D:\development\qt-4.8.5-mingw
set QMAKESPEC=win32-g++
set PATH=D:\development\MinGW\bin;D:\development\tools\Perl32\bin;D:\development\qt-4.8.5-mingw\bin
set PATH=%PATH%;c:\Windows\system32
set INCLUDE=
set LIB=
set CPATH=
set CPLUS_INCLUDE_PATH=
set LANG=en
mingw32-make