Cross Compile LInux Host for Windows Help Please

Help Please,
I am trying to cross compile for windows I am using a Linux Ubuntu Host system, I installed mingw 32 bit headers and librarys are under
/usr/i686-w64-mingw32 and 64 bit headers and librarys are under /usr/x86_64-w64-mingw32 the binarys were automatically installed
under /usr/bin, but I copied all i686 Mingw binarys under the /usr/i686-w64-mingw32/bin , and all x86_64 Mingw binarys under /usr/x86_64-w64-mingw32/bin
also copied the direct headers downloaded into both include directories and librarys into lib directories so. Basically I have bin, lib and include structure
under each directory i686-w64-mingw32 for 32 bit windows and x86_64-w64-mingw32 for 64 bit windows. I installed Urho3D-1.5 Source,
now I succesuffly compiled and make 64 bit and 32 bit linux excuteables already, so I wanted to compile for Windows.

So I use the command Below But never works, any one got this working cross compiling please help
./cmake_mingw.sh $URHO3D_HOME -DWIN32=1 -DURHO3D_64BIT=0 -DURHO3D_ANGELSCRIPT=0 -DURHO3D_SAMPLES=1 -DURHO3D_TOOLS=0 -DURHO3D_PACKAGING=1 -DURHO3D_LOGGING=0 -DCMAKE_BUILD_TYPE=Release -DMINGW_PREFIX=i686-w64-mingw32 -DMINGW_SYSROOT=/usr/i686-w64-mingw32

But I get error below
CMake Error at CMake/Toolchains/mingw.toolchain.cmake:40 (message):
Could not find MinGW cross compilation tool. Use MINGW_PREFIX environment
variable or build option to specify the location of the toolchain.
Call Stack (most recent call first):
/UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/cmake-3.5.0-rc1-Linux-x86_64/share/cmake-3.5/Modules/CMakeDetermineSystem.cmake:98 (include)
CMakeLists.txt:24 (project)

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
– Configuring incomplete, errors occurred!

Hey mcra3005,

Welcome to the forums! :slight_smile: First off, you could try setting up using CMake GUI, as it would be so much easier getting rid of those path and environment errors and check again.

Hi Raston

I tried CMAKE GUI it always gave errors and complain about paths and similar errors also.
Have you done this in CMAKE GUI what steps did you do just in case I am doing it wrong .

Thanks

May be problem is here?

[quote=“mcra3005”]-DMINGW_PREFIX=i686-w64-mingw32

Use MINGW_PREFIX environment variable or build option to specify the location of the toolchain.
[/quote]

[quote=“mcra3005”]Hi Raston

I tried CMAKE GUI it always gave errors and complain about paths and similar errors also.
Have you done this in CMAKE GUI what steps did you do just in case I am doing it wrong .

Thanks[/quote]

I’m also taking a crack at it… used to build mingw for windows only with urho. btw, have you also tried the cmake_mingw.sh script? You can also check with 1vanK’s suggestion.

Hi Ivan,

From urho3d.github.io/documentation/1 … lding.html it said Prefix path to MinGW cross-compiler tools (MinGW cross-compiling build only)
i.e A prefix instaed of gcc it will run i686-w64-mingw32-gcc and attach the i686-w64-mingw32 as a prefix ??
but that waht I thought.

I also thought /usr/i686-w64-mingw32 is MINGW_SYSROOT since that is where the bin, lib, include for the MInGW was??

But anyway I tried Now and did -DMINGW_PREFIX=/usr/i686-w64-mingw32 and -DMINGW_PREFIX=/usr/i686-w64-mingw32/bin and still got the same
error or Their another value I should set it to.

Any IDeas how to get this to work??

Do not doubt the error message given by the CMake error. The message is quite clear to me that the MINGW_PREFIX build option is not being set correctly. MINGW_PREFIX is not a path. It contains a prefix string for the GCC compiler toolchain. In my Linux box, I do not have to make any manual correction to the binary installation location. Basically I just did a yum/dnf install of the MinGW64 packages and all set to go. So, another possibility is you have a borked installation. Here is what I have, just for your comparison.

[code]$ echo $MINGW_PREFIX
/usr/bin/x86_64-w64-mingw32

$ ls /usr/bin/x86_64-w64-mingw32*
/usr/bin/x86_64-w64-mingw32-addr2line /usr/bin/x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-nm
/usr/bin/x86_64-w64-mingw32-ar /usr/bin/x86_64-w64-mingw32-gcc-5.2.0 /usr/bin/x86_64-w64-mingw32-objcopy
/usr/bin/x86_64-w64-mingw32-as /usr/bin/x86_64-w64-mingw32-gcc-ar /usr/bin/x86_64-w64-mingw32-objdump
/usr/bin/x86_64-w64-mingw32-c++ /usr/bin/x86_64-w64-mingw32-gcc-nm /usr/bin/x86_64-w64-mingw32-ranlib
/usr/bin/x86_64-w64-mingw32-c++filt /usr/bin/x86_64-w64-mingw32-gcc-ranlib /usr/bin/x86_64-w64-mingw32-readelf
/usr/bin/x86_64-w64-mingw32-cpp /usr/bin/x86_64-w64-mingw32-gcov /usr/bin/x86_64-w64-mingw32-size
/usr/bin/x86_64-w64-mingw32-dlltool /usr/bin/x86_64-w64-mingw32-gcov-tool /usr/bin/x86_64-w64-mingw32-strings
/usr/bin/x86_64-w64-mingw32-dllwrap /usr/bin/x86_64-w64-mingw32-gprof /usr/bin/x86_64-w64-mingw32-strip
/usr/bin/x86_64-w64-mingw32-elfedit /usr/bin/x86_64-w64-mingw32-ld /usr/bin/x86_64-w64-mingw32-windmc
/usr/bin/x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-ld.bfd /usr/bin/x86_64-w64-mingw32-windres[/code]
You can set MINGW_PREFIX as build option or as environment variable. I like the latter approach because I don’t have to retype the prefix again and again. I nuke and recreate my MinGW build tree quite frequently when modifying and testing Urho3D build system.

Thanks

I Tried the new MINGW_PREFIX my output did change I also have the binarys in /usr/bin also but I made a copy to the same directorys under /usr
where mingw installed the /include and /lib.

I also noticed it was refering to comiplers in /usr/lib/ccache so I removed the links their.

I also set my environment variable but when that did not work I tried the option also

Anyway what is your MINGW_SYSROOT set to ?

When I rerun with the new MINGW_PREFIX I get the following errors below any ideas?
Thanks.

– The C compiler identification is unknown
– The CXX compiler identification is unknown
– Check for working C compiler: /UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/BUrho3D/i686-w64-mingw32-gcc
– Check for working C compiler: /UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/BUrho3D/i686-w64-mingw32-gcc – broken
CMake Error at /UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/cmake-3.5.0-rc1-Linux-x86_64/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler
"/UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/BUrho3D/i686-w64-mingw32-gcc"
is not able to compile a simple test program.

It fails with the following output:

Change Dir: /UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/BUrho3D/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" “cmTC_4f2bc/fast”

/usr/bin/make -f CMakeFiles/cmTC_4f2bc.dir/build.make
CMakeFiles/cmTC_4f2bc.dir/build

make[1]: Entering directory
`/UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/BUrho3D/CMakeFiles/CMakeTmp’

Building C object CMakeFiles/cmTC_4f2bc.dir/testCCompiler.c.obj

/UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/BUrho3D/i686-w64-mingw32-gcc -o
CMakeFiles/cmTC_4f2bc.dir/testCCompiler.c.obj -c
/UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/BUrho3D/CMakeFiles/CMakeTmp/testCCompiler.c

i686-w64-mingw32-gcc: error trying to exec ‘cc1’: execvp: No such file or
directory

make[1]: *** [CMakeFiles/cmTC_4f2bc.dir/testCCompiler.c.obj] Error 1

make[1]: Leaving directory
`/UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/BUrho3D/CMakeFiles/CMakeTmp’

make: *** [cmTC_4f2bc/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:24 (project)

– Configuring incomplete, errors occurred!
See also “/UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/BUrho3D/CMakeFiles/CMakeOutput.log”.
See also “/UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/BUrho3D/CMakeFiles/CMakeError.log”.

Ok, I got it configured and build with win32 on my ubuntu 32bit vbox, copied and ran some tools/examples to windows 7 and works ok.

I use /usr/x86_64-w64-mingw32

Thats Great you got it compiled your SYSROOT variable looks the same but I have the /usr/i686-w64-mingw32
what steps did you do I guess if you used the CMAKE GUI what option did you pick and what did you put in your boxes.

But I am trying to compile 32 bit windows on 64 bit Linux Ubuntu real system.
Hopefully your settings and CMAKEGUI Directions can help me.

Thanks.

[quote=“mcra3005”]Thats Great you got it compiled your SYSROOT variable looks the same but I have the /usr/i686-w64-mingw32
what steps did you do I guess if you used the CMAKE GUI what option did you pick and what did you put in your boxes.

But I am trying to compile 32 bit windows on 64 bit Linux Ubuntu real system.
Hopefully your settings and CMAKEGUI Directions can help me.

Thanks.[/quote]

Sure thing. I did not use CMake GUI at this time as the console stuff looks fairly straightforward following the docs. OS emulation is as good as the real system, even in this case with default or dummy graphic setup/acceleration for 3D apps. I only used OPENGL for quick testing. Some key stuff that I did:

export MINGW_SYSROOT=/usr/x86_64-w64-mingw32
./cmake_mingw.sh ./mingw -DMINGW_PREFIX=/usr/bin/x86_64-w64-mingw32 -DURHO3D_OPENGL=1

I think your setup just got messed up somewhere or try the above with the 64bit equivalent.

Hope that helps and good luck :slight_smile:

EDIT: I did a 64bit exe build with this test when I recalled using the URHO3D_64BIT=1 if it is of any help

Well I got Urho to crosscompile and generate the files now but I have a issue when I try to make shown below any Ideas??

I found that after setting the fully qualified path for the prefix it almost worked but complain about cc1, it appears that ccache does not like cross compiling
I disabled it and it almost worked due to 32 bit version I had to disable PCH option and due to gcc version I had to disable SSE.
Then it configured the make files.
But when I tried to make I get below error which is why I disabled the PCH option?

Any Ideas

make
Scanning dependencies of target FreeType
[ 1%] Building C object Source/ThirdParty/FreeType/CMakeFiles/FreeType.dir/src/autofit/autofit.c.obj
i686-w64-mingw32-gcc: error: unrecognized command line option ?-fno-tree-loop-vectorize?
make[2]: *** [Source/ThirdParty/FreeType/CMakeFiles/FreeType.dir/src/autofit/autofit.c.obj] Error 1
make[1]: *** [Source/ThirdParty/FreeType/CMakeFiles/FreeType.dir/all] Error 2
make: *** [all] Error 2

[quote=“mcra3005”]Well I got Urho to crosscompile and generate the files now but I have a issue when I try to make shown below any Ideas??

I found that after setting the fully qualified path for the prefix it almost worked but complain about cc1, it appears that ccache does not like cross compiling
I disabled it and it almost worked due to 32 bit version I had to disable PCH option and due to gcc version I had to disable SSE.
Then it configured the make files.
But when I tried to make I get below error which is why I disabled the PCH option?

Any Ideas

make
Scanning dependencies of target FreeType
[ 1%] Building C object Source/ThirdParty/FreeType/CMakeFiles/FreeType.dir/src/autofit/autofit.c.obj
i686-w64-mingw32-gcc: error: unrecognized command line option ?-fno-tree-loop-vectorize?
make[2]: *** [Source/ThirdParty/FreeType/CMakeFiles/FreeType.dir/src/autofit/autofit.c.obj] Error 1
make[1]: *** [Source/ThirdParty/FreeType/CMakeFiles/FreeType.dir/all] Error 2
make: *** [all] Error 2[/quote]

Hey, great to hear you got some progress! As for that ?-fno-tree-loop-vectorize? specific error, I ran into the same but with mingw windows, see here: github.com/urho3d/Urho3D/issues/1124

Upgrade your mingw gcc and it should get rid of that issue :wink:

PostPosted by rasteron ? 23 Feb 2016, 20:10

mcra3005 wrote:
Thats Great you got it compiled your SYSROOT variable looks the same but I have the /usr/i686-w64-mingw32
what steps did you do I guess if you used the CMAKE GUI what option did you pick and what did you put in your boxes.

But I am trying to compile 32 bit windows on 64 bit Linux Ubuntu real system.
Hopefully your settings and CMAKEGUI Directions can help me.

Thanks.

Sure thing. I did not use CMake GUI at this time as the console stuff looks fairly straightforward following the docs. OS emulation is as good as the real system, even in this case with default or dummy graphic setup/acceleration for 3D apps. I only used OPENGL for quick testing. Some key stuff that I did are:

CODE: SELECT ALL
export MINGW_SYSROOT=/usr/x86_64-w64-mingw32
./cmake_mingw.sh ./mingw -DMINGW_PREFIX=/usr/bin/x86_64-w64-mingw32 -DURHO3D_OPENGL=1

I think your setup just got messed up somewhere or try the above with the 64bit equivalent.

Hope that helps and good luck :slight_smile:

EDIT: I did a 64bit exe build with this test when I recalled using the URHO3D_64BIT=1 if it is of any help

Image
Raster Games | G+ github.com/rasteron | StrikeForce
User avatar
rasteron
Most active user
Most active user

Posts: 311
Joined: 07 Mar 2014, 17:46
Location: web
Top
Re: Cross Compile LInux Host for Windows Help Please
PostPosted by mcra3005 ? 23 Feb 2016, 22:01

Well I got Urho to crosscompile and generate the files now but I have a issue when I try to make shown below any Ideas??

I found that after setting the fully qualified path for the prefix it almost worked but complain about cc1, it appears that ccache does not like cross compiling
I disabled it and it almost worked due to 32 bit version I had to disable PCH option and due to gcc version I had to disable SSE.
Then it configured the make files.
But when I tried to make I get below error which is why I disabled the PCH option?

Any Ideas

make
Scanning dependencies of target FreeType
[ 1%] Building C object Source/ThirdParty/FreeType/CMakeFiles/FreeType.dir/src/autofit/autofit.c.obj
i686-w64-mingw32-gcc: error: unrecognized command line option ?-fno-tree-loop-vectorize?
make[2]: *** [Source/ThirdParty/FreeType/CMakeFiles/FreeType.dir/src/autofit/autofit.c.obj] Error 1
make[1]: *** [Source/ThirdParty/FreeType/CMakeFiles/FreeType.dir/all] Error 2
make: *** [all] Error 2

[quote=“mcra3005”]Thanks

I Tried the new MINGW_PREFIX my output did change I also have the binarys in /usr/bin also but I made a copy to the same directorys under /usr
where mingw installed the /include and /lib.

I also noticed it was refering to comiplers in /usr/lib/ccache so I removed the links their.[/quote]
But why? Believe me, using your compiler toolchains via ccache is a very good thing. If ccache is not good then your distro would not have set it up to work with the installed compiler toolchains by default.

This is not true. ccache works with any GCC and Clang compiler toolchains, native or cross-compile one. All our CI build jobs on Travis CI linux boxes are in fact using ccache to shorten the build time. Our typical build time for MinGW CI build jobs are 2 to 3 minutes. We have about 1 minute overhead to prepare the VM at the start of CI job to install MinGW on the fly, git clone the repository, setting up the cache, etc. So, in essence, our MinGW CI jobs only take about 1 to 2 minutes to build from scratch! Thanks to ccache.

We have a section in our online documentation describing the usage of ccache, if you are interested. Also use ‘man ccache’ to learn more.

rasteron has nailed it down correctly on this one.

Thanks everyone, I can generate the files now but weather I do a 64 bit windows build or 32 windows build using cross compiling
I have the following errors below.

I was advised that a version of gcc i.e. i686-w64-mingw32-gcc or x86_64-w64-mingw32-gcc at 4.9.1 should fix this ?
I am on ubuntu 14.04 any idea where I could get updated versions of these or do I need to look for sources and compile ???

Or do I need a new OS??

Thanks

64 bit
SDL_dxjoystick_c.h:133:5: error: unknown type name ?LPDIRECTINPUTDEVICE8?
make[2]: *** [Source/ThirdParty/SDL/CMakeFiles/SDL.dir/src/haptic/windows/SDL_syshaptic.c.obj] Error 1
32 bit
Building C object Source/ThirdParty/FreeType/CMakeFiles/FreeType.dir/src/autofit/autofit.c.obj
i686-w64-mingw32-gcc: error: unrecognized command line option ?-fno-tree-loop-vectorize?

For compiler toolchain, later version is always the better one, generally speaking. So I would always go for the latest provided by my distro package manager. GCC 4.9.1 is ancient when measured in computer time. Try to upgrade and come back here if you still encountering error despite of that. Good luck.

EDIT: My Linux distro is 64-bit Fedora. Currently the latest Fedora release is 23. In this release, the GCC compiler toolchain version is 5.3.1 and MinGW version is 5.2.0. The Clang version is 4.2.1 which is quite recent also. This is why I like about Fedora. Cutting edge software. Besides, “blue” is my favorite color :wink: . If you use Ubuntu then try to upgrade to the latest Ubuntu you can find and if even after that still it does not work then try to enable the ubuntu-toolchain-r-test PPA to your Ubuntu system in order to upgrade to the latest compiler version available for your distro. See how this is done in our .travis.yml file.

Hi all,

It took a while but.

I rebuilt my Linux envirnoment to Ubuntu 15.10, and have a more upgraded version of mingw gcc and I have all my
Prefix and Sysroot variables correct I can Cmake the files for windows 32 bit or windows 64 bit using cross compiling
but when I do make. I get the current error weather I try to compile for 64 bit windows or 32 bit Below.

Of course i am doing this on a Linux 64 bit OS i.e. Ubuntu

Any Ideas ??

[ 16%] Building C object Source/ThirdParty/SDL/CMakeFiles/SDL.dir/src/haptic/windows/SDL_syshaptic.c.obj
In file included from /UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/Urho3D-1.5/Source/ThirdParty/SDL/src/haptic/windows/SDL_syshaptic.c:34:0:
/UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/Urho3D-1.5/Source/ThirdParty/SDL/src/haptic/windows/…/…/joystick/windows/SDL_dxjoystick_c.h:133:5: error: unknown type name ?LPDIRECTINPUTDEVICE8?
LPDIRECTINPUTDEVICE8 InputDevice;
^
/UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/Urho3D-1.5/Source/ThirdParty/SDL/src/haptic/windows/SDL_syshaptic.c:58:5: error: unknown type name ?LPDIRECTINPUTDEVICE8?
LPDIRECTINPUTDEVICE8 device;
^
/UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/Urho3D-1.5/Source/ThirdParty/SDL/src/haptic/windows/SDL_syshaptic.c:85:8: error: unknown type name ?LPDIRECTINPUT8?
static LPDIRECTINPUT8 dinput = NULL;
^
/UBUNENV/MIKEDOCUMENTS/TAKEHOME/BUILDURHO3D/Urho3D-1.5/Source/ThirdParty/SDL/src/haptic/windows/SDL_syshaptic.c:105:42: error: unknown type name ?LPDIRECTINPUTDEVICE8?
LPDIRECTINPUTDEVICE8 device8,

That looks like a Direct X related error. I’m not sure, but since that you’re still using MinGW + DirectX, did you include the directx headers?

[quote]
If using MinGW to compile, DirectX headers may need to be acquired separately. They can be copied to the MinGW installation eg. from the following package: libsdl.org/extras/win32/comm … vel.tar.gz These will be missing some of the headers related to shader compilation, so a MinGW build will use OpenGL by default.[/quote]

libsdl.org/extras/win32/comm … vel.tar.gz

Try with the OpenGL enabled build and see if you’re still having those issues or include those headers for DirectX.

I did use the CMake with -DURHO3D_OPENGL=1 I still got the same error I did download previously the same DirectX headers and I copied the include and lib folder
contents into the /usr/i686-w64-mingw32 and also in the /usr/x86_64-w64-mingw32. But still I have the same error I am using Urho3D-1.5 source from main web site.
It looks like a SDL error possible a definition error but only complains when it looks at the windows source.

Not sure what to do I even did the option like you did minumum ./cmake_mingw.sh $URHO3D_HOME -DURHO3D_OPENGL=1 to do a 64bit windows but when I run the
make command in the Build directory I get the errors I mention weather it is 32 bit or 64 bit.

How does anyone else cross compile ???

Any Ideas ??

Is their a Variable I meant to point to the DirectX ???
Thanks