PDA

View Full Version : how to corss compile for windows in Linux



safknw
10th May 2006, 13:10
I have developed an application using kdeveloper in linux, Now I want ot port it to windows. What changes I have to made it to port to windows.

e8johan
10th May 2006, 13:46
As long as you stick to Qt, none. There can be issues with filenames (drives, / or \, etc), header files, focusing on advanced pop-ups (such as IntelliType), but a normal app should be portable as it is.

safknw
10th May 2006, 16:08
I have ceate project using kdevelop.
I compiled it on windows, I have appropriate changes in make file (I changed path ). and compile. Copmiler shows followin error.

======================
makefile:168: warning: overriding commands for target `.'
makefile:165: warning: ignoring old commands for target `.'
g++ -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo
-reloc -mthreads -Wl,-s -Wl,-subsystem,windows -e __Z19QtWinMainCRTStartupv -o m
ymplayer .obj/main.o .obj/myform.o .obj/playlist.o .obj/fileinfo.o .obj/equilize
r.o .obj/previewmp.o .obj/mplayerprocess.o .obj/importwiz.o .obj/mpfileinfo.o .o
bj/passwordform.o .obj/mainform.o .obj/PlayList.o .obj/EquilizerForm.o .obj/Prev
iewForm.o .obj/ImportForm.o .obj/InfoDiag.o .obj/passwordDiag.o .obj/moc_myform.
o .obj/moc_playlist.o .obj/moc_equilizer.o .obj/moc_previewmp.o .obj/moc_mplayer
process.o .obj/moc_importwiz.o .obj/moc_mpfileinfo.o .obj/moc_passwordform.o .ob
j/moc_mainform.o .obj/moc_PlayList.o .obj/moc_EquilizerForm.o .obj/moc_PreviewFo
rm.o .obj/moc_ImportForm.o .obj/moc_InfoDiag.o .obj/moc_passwordDiag.o -L"C:\qt-
3\lib" -lqtmain -lqt-mt -lkernel32 -luser32 -lgdi32 -lcomdlg32 -ladvapi32 -lshel
l32 -lole32 -loleaut32 -luuid -limm32 -lwinmm -lwsock32 -lwinspool
.obj/PlayList.o(.text+0x0): In function `ZN12PlayListForm6removeEv':
/usr/lib/qt-3.3/include/qglist.h:150: multiple definition of `ZN12PlayListForm6r
emoveEv'
.obj/playlist.o(.text+0x0):/usr/lib/qt-3.3/include/qglist.h:150: first defined h
ere
.obj/PlayList.o(.text+0x10): In function `ZN12PlayListForm3addEv':
.ui/PlayList.cpp:102: multiple definition of `ZN12PlayListForm3addEv'
.obj/playlist.o(.text+0x10):.ui/PlayList.cpp:102: first defined here
.obj/PlayList.o(.text+0x20): In function `ZN12PlayListFormD0Ev':
.ui/PlayList.cpp:80: multiple definition of `ZN12PlayListFormD0Ev'
.obj/playlist.o(.text+0x20):.ui/PlayList.cpp:80: first defined here
.obj/PlayList.o(.text+0x50): In function `ZN12PlayListFormD1Ev':
.ui/PlayList.cpp:80: multiple definition of `ZN12PlayListFormD1Ev'
.obj/playlist.o(.text+0x50):.ui/PlayList.cpp:80: first defined here
.obj/PlayList.o(.text+0x70): In function `ZN12PlayListFormD2Ev':
.ui/PlayList.cpp:80: multiple definition of `ZN12PlayListFormD2Ev'
.obj/playlist.o(.text+0x70):.ui/PlayList.cpp:80: first defined here
.obj/PlayList.o(.text+0x90): In function `ZN12PlayListForm14languageChangeEv':
.ui/PlayList.cpp:89: multiple definition of `ZN12PlayListForm14languageChangeEv'

.obj/playlist.o(.text+0x90):.ui/PlayList.cpp:89: first defined here
.obj/PlayList.o(.text+0x420): In function `ZN12PlayListFormC1EP7QWidgetPKcbj':
.ui/PlayList.cpp:27: multiple definition of `ZN12PlayListFormC1EP7QWidgetPKcbj'
.obj/playlist.o(.text+0x420):.ui/PlayList.cpp:27: first defined here
.obj/PlayList.o(.text+0x970): In function `ZN12PlayListFormC2EP7QWidgetPKcbj':
.ui/PlayList.cpp:27: multiple definition of `ZN12PlayListFormC2EP7QWidgetPKcbj'
.obj/playlist.o(.text+0x970):.ui/PlayList.cpp:27: first defined here
.obj/moc_PlayList.o(.text+0x0): In function `ZNK12PlayListForm9classNameEv':
/usr/lib/qt-3.3/include/qglist.h:150: multiple definition of `ZNK12PlayListForm9
classNameEv'
.obj/moc_playlist.o(.text+0x0):/usr/lib/qt-3.3/include/qglist.h:150: first defin
ed here
.obj/moc_PlayList.o(.text+0x10): In function `ZN12PlayListForm18qt_static_proper
tyEP7QObjectiiP8QVariant':
.moc/moc_PlayList.cpp:106: multiple definition of `ZN12PlayListForm18qt_static_p
ropertyEP7QObjectiiP8QVariant'
.obj/moc_playlist.o(.text+0x10):.moc/moc_PlayList.cpp:106: first defined here
.obj/moc_PlayList.o(.text+0x160): In function `ZN12PlayListForm16staticMetaObjec
tEv':
.moc/moc_PlayList.cpp:50: multiple definition of `ZN12PlayListForm16staticMetaOb
jectEv'
.obj/moc_playlist.o(.text+0x160):.moc/moc_PlayList.cpp:50: first defined here
.obj/moc_PlayList.o(.text+0xa0): In function `ZN12PlayListForm11qt_propertyEiiP8
QVariant':
.moc/moc_PlayList.cpp:101: multiple definition of `ZN12PlayListForm11qt_property
EiiP8QVariant'
.obj/moc_playlist.o(.text+0xa0):.moc/moc_PlayList.cpp:101: first defined here
.obj/moc_PlayList.o(.text+0xd0): In function `ZN12PlayListForm7qt_emitEiP8QUObje
ct':
.moc/moc_PlayList.cpp:95: multiple definition of `ZN12PlayListForm7qt_emitEiP8QU
Object'
.obj/moc_playlist.o(.text+0xd0):.moc/moc_PlayList.cpp:95: first defined here
.obj/moc_PlayList.o(.text+0x100): In function `ZN12PlayListForm7qt_castEPKc':
.moc/moc_PlayList.cpp:76: multiple definition of `ZN12PlayListForm7qt_castEPKc'
.obj/moc_playlist.o(.text+0x100):.moc/moc_PlayList.cpp:76: first defined here
.obj/moc_PlayList.o(.bss+0x0): multiple definition of `ZN12PlayListForm7metaObjE
'
.obj/moc_playlist.o(.bss+0x0): first defined here
.obj/moc_PlayList.o(.text+0x200): In function `ZN12PlayListForm9qt_invokeEiP8QUO
bject':
.moc/moc_PlayList.cpp:83: multiple definition of `ZN12PlayListForm9qt_invokeEiP8
QUObject'
.obj/moc_playlist.o(.text+0x200):.moc/moc_PlayList.cpp:83: first defined here
.obj/moc_PlayList.o(.text+0x2a0): In function `ZN12PlayListForm6trUtf8EPKcS1_':
.moc/moc_PlayList.cpp:39: multiple definition of `ZN12PlayListForm6trUtf8EPKcS1_
'
.obj/moc_playlist.o(.text+0x2a0):.moc/moc_PlayList.cpp:39: first defined here
.obj/moc_PlayList.o(.text+0x310): In function `ZN12PlayListForm2trEPKcS1_':
.moc/moc_PlayList.cpp:31: multiple definition of `ZN12PlayListForm2trEPKcS1_'
.obj/moc_playlist.o(.text+0x310):.moc/moc_PlayList.cpp:31: first defined here
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\ mingw32\bin\ld.exe: cannot fin
d -lqtmain
collect2: ld returned 1 exit status
mingw32-make: *** [mymplayer] Error 1
=================
make file atteched.
I have renamed make for atteching.

jacek
10th May 2006, 16:16
I have ceate project using kdevelop.
I compiled it on windows, I have appropriate changes in make file (I changed path ). and compile.
Don't edit the Makefile --- just generate a new one from the .pro file.

hardgeus
10th May 2006, 17:22
I have developed an application using kdeveloper in linux, Now I want ot port it to windows. What changes I have to made it to port to windows.

Well, I wrote a little blurb on how I develop QT applications across Windows and Linux. Here it is:

http://www.hardgeus.com/index.php?ndailyupdateid=685

First, a couple of notes: I don't use KDevelop...I use vim for editing my code. I do, however use QT Designer to design dialogs etc. My build environment is a tad specific to what I'm doing (QT 4 only). Finally, I don't use qmake or anything, I use the Scons tool, which is dependent on Python. Don't panic, Python and Scons are extremely easy to install on both Linux and Windows.

safknw
10th May 2006, 19:06
i recreated make file and compile it shows following error.
=========
D:\saf\myMplayer0.8>mingw32-make
makefile:415: warning: overriding commands for target `.ui\PlayList.h'
makefile:403: warning: ignoring old commands for target `.ui\PlayList.h'
makefile:418: warning: overriding commands for target `.ui\PlayList.cpp'
makefile:406: warning: ignoring old commands for target `.ui\PlayList.cpp'
makefile:421: warning: overriding commands for target `.ui\EquilizerForm.h'
makefile:379: warning: ignoring old commands for target `.ui\EquilizerForm.h'
makefile:424: warning: overriding commands for target `.ui\EquilizerForm.cpp'
makefile:382: warning: ignoring old commands for target `.ui\EquilizerForm.cpp'
makefile:427: warning: overriding commands for target `.ui\PreviewForm.h'
makefile:409: warning: ignoring old commands for target `.ui\PreviewForm.h'
makefile:430: warning: overriding commands for target `.ui\PreviewForm.cpp'
makefile:412: warning: ignoring old commands for target `.ui\PreviewForm.cpp'
makefile:433: warning: overriding commands for target `.ui\ImportForm.h'
makefile:385: warning: ignoring old commands for target `.ui\ImportForm.h'
makefile:436: warning: overriding commands for target `.ui\ImportForm.cpp'
makefile:388: warning: ignoring old commands for target `.ui\ImportForm.cpp'
makefile:439: warning: overriding commands for target `.ui\InfoDiag.h'
makefile:391: warning: ignoring old commands for target `.ui\InfoDiag.h'
makefile:442: warning: overriding commands for target `.ui\InfoDiag.cpp'
makefile:394: warning: ignoring old commands for target `.ui\InfoDiag.cpp'
makefile:445: warning: overriding commands for target `.ui\passwordDiag.h'
makefile:397: warning: ignoring old commands for target `.ui\passwordDiag.h'
makefile:448: warning: overriding commands for target `.ui\passwordDiag.cpp'
makefile:400: warning: ignoring old commands for target `.ui\passwordDiag.cpp'
makefile:471: warning: overriding commands for target `.obj\playlist.o'
makefile:337: warning: ignoring old commands for target `.obj\playlist.o'
makefile:479: warning: overriding commands for target `.obj\playlist.o'
makefile:471: warning: ignoring old commands for target `.obj\playlist.o'
makefile:483: warning: overriding commands for target `.obj\EquilizerForm.o'
makefile:455: warning: ignoring old commands for target `.obj\EquilizerForm.o'
makefile:487: warning: overriding commands for target `.obj\PreviewForm.o'
makefile:475: warning: ignoring old commands for target `.obj\PreviewForm.o'
makefile:491: warning: overriding commands for target `.obj\ImportForm.o'
makefile:459: warning: ignoring old commands for target `.obj\ImportForm.o'
makefile:495: warning: overriding commands for target `.obj\InfoDiag.o'
makefile:463: warning: ignoring old commands for target `.obj\InfoDiag.o'
makefile:499: warning: overriding commands for target `.obj\passwordDiag.o'
makefile:467: warning: ignoring old commands for target `.obj\passwordDiag.o'
makefile:551: warning: overriding commands for target `.obj\moc_playlist.o'
makefile:510: warning: ignoring old commands for target `.obj\moc_playlist.o'
makefile:557: warning: overriding commands for target `.obj\moc_playlist.o'
makefile:551: warning: ignoring old commands for target `.obj\moc_playlist.o'
makefile:560: warning: overriding commands for target `.obj\moc_EquilizerForm.o'

makefile:539: warning: ignoring old commands for target `.obj\moc_EquilizerForm.
o'
makefile:563: warning: overriding commands for target `.obj\moc_PreviewForm.o'
makefile:554: warning: ignoring old commands for target `.obj\moc_PreviewForm.o'

makefile:566: warning: overriding commands for target `.obj\moc_ImportForm.o'
makefile:542: warning: ignoring old commands for target `.obj\moc_ImportForm.o'
makefile:569: warning: overriding commands for target `.obj\moc_InfoDiag.o'
makefile:545: warning: ignoring old commands for target `.obj\moc_InfoDiag.o'
makefile:572: warning: overriding commands for target `.obj\moc_passwordDiag.o'
makefile:548: warning: ignoring old commands for target `.obj\moc_passwordDiag.o
'
makefile:614: warning: overriding commands for target `.moc\moc_playlist.cpp'
makefile:578: warning: ignoring old commands for target `.moc\moc_playlist.cpp'
makefile:620: warning: overriding commands for target `.moc\moc_playlist.cpp'
makefile:614: warning: ignoring old commands for target `.moc\moc_playlist.cpp'
makefile:623: warning: overriding commands for target `.moc\moc_EquilizerForm.cp
p'
makefile:602: warning: ignoring old commands for target `.moc\moc_EquilizerForm.
cpp'
makefile:626: warning: overriding commands for target `.moc\moc_PreviewForm.cpp'

makefile:617: warning: ignoring old commands for target `.moc\moc_PreviewForm.cp
p'
makefile:629: warning: overriding commands for target `.moc\moc_ImportForm.cpp'
makefile:605: warning: ignoring old commands for target `.moc\moc_ImportForm.cpp
'
makefile:632: warning: overriding commands for target `.moc\moc_InfoDiag.cpp'
makefile:608: warning: ignoring old commands for target `.moc\moc_InfoDiag.cpp'
makefile:635: warning: overriding commands for target `.moc\moc_passwordDiag.cpp
'
makefile:611: warning: ignoring old commands for target `.moc\moc_passwordDiag.c
pp'
g++ -c -mthreads -Wall -O2 -fexceptions -frtti -DUNICODE -DQT_DLL -DQT_THREAD_S
UPPORT -DQT_NO_DEBUG -I"C:\qt-3\include" -I".ui" -I"." -I"." -I".moc" -I"C:\qt-3
\mkspecs\win32-g++" -o .obj\main.o main.cpp
In file included from C:/qt-3/include/qiconset.h:43,
from C:/qt-3/include/qpushbutton.h:43,
from myform.h:21,
from main.cpp:2:
C:/qt-3/include/qpixmap.h:249: warning: 'void bitBlt(QPaintDevice*, int, int, co
nst QPaintDevice*, int, int, int, int, Qt::RasterOp, bool)' redeclared without d
llimport attribute after being referenced with dllimport linkage
In file included from myform.h:27,
from main.cpp:2:
playlist.h:21: error: expected class-name before '{' token
mingw32-make: *** [.obj\main.o] Error 1
===========

jacek
10th May 2006, 19:13
Could you post your .pro file?

hardgeus
10th May 2006, 19:14
I would assume that your Linux project is using QT 3, and I would further assume that your Windows install of QT is QT4? I couldn't get even a "Hello World" example to compile under Windows when the .cpp files were generated with the QT3 tools. Hell, I couldn't even get it to work when only my .ui files were generated with QT3!

I know you probably don't want to hear this, but you're probably better off starting from scratch and first trying to get a simple "Hello world" example cross compiling on both Windows and Linux rather than taking an existing large codebase generated in KDevelop and trying to get it working under Windows.

safknw
10th May 2006, 22:34
Here is my project (.pro) file

jacek
10th May 2006, 23:14
Here is my project (.pro) file
You add all forms (except mainform.ui) twice to the FORMS variable.

safknw
11th May 2006, 10:07
I successfully compiled my project in windows.
Now the problem is that while I run the application and click on a button in response of which I start a process. (process->start). It crashes and shows following error.

AppName: mymplayer.exe AppVer: 0.0.0.0 ModName: msvcrt.dll
ModVer: 7.0.2600.2180 Offset: 000323e4

jacek
11th May 2006, 16:02
Now the problem is that while I run the application and click on a button in response of which I start a process. (process->start). It crashes
Compile your application in debug mode, run it from the debugger and see where exactly it crashes.

safknw
11th May 2006, 18:55
Compile your application in debug mode, run it from the debugger and see where exactly it crashes.
How to compile in debug mode.:confused:

jacek
11th May 2006, 19:19
How to compile in debug mode.:confused:
Make sure you have built Qt in debug mode, then add "CONFIG += debug" to your .pro file. Although, AFAIR, in windows qmake builds applications by default in both release and debug mode at once.

safknw
12th May 2006, 14:24
I have complied in debug mode and run the application and it shows access violation in msvcrt.dll.
What does this means and how solve it .

jacek
12th May 2006, 14:33
Could you post the backtrace?

safknw
12th May 2006, 14:51
Could you post the backtrace?
sorry.
I didn't show the backtrace .
Can I debug this application using gnu debugger on windows. If yes How? Is there any gui based debugger for qt applications.

jacek
12th May 2006, 15:00
Can I debug this application using gnu debugger on windows. If yes How?
Download gdb from www.mingw.org.


Is there any gui based debugger for qt applications.
You can use any debugger you want.

GreyGeek
12th May 2006, 19:09
I successfully compiled my project in windows.
Now the problem is that while I run the application and click on a button in response of which I start a process. (process->start). It crashes and shows following error.

AppName: mymplayer.exe AppVer: 0.0.0.0 ModName: msvcrt.dll
ModVer: 7.0.2600.2180 Offset: 000323e4
That's probably the first of possibly several dll's that you'll need.
Go to Microsoft's website and download their free "Dependency Checker". Run it on your exe and it will tell you what your QT app cannot find when it tried to run.
Do a file search for those missing dlls and either copy them to your app directory or add their location to your PATH.

hardgeus
12th May 2006, 19:14
That's probably the first of possibly several dll's that you'll need.


I don't think the problem is a missing dependency...If that were the case, it would have immediately reported the missing DLL and not run the program. He's having a problem after the program runs, i.e. the crash is occurring *in* the DLL, therefore the DLL is there.

safknw
12th May 2006, 20:35
Here is the backtrace.

=======
Starting program: D:\Sharique\win\myMplayer0.9/mymplayer.exe

Program received signal SIGSEGV, Segmentation fault.
0x77c423e4 in _libkernel32_a_iname ()
(gdb) backstrace
Undefined command: "backstrace". Try "help".
(gdb) backtrace
#0 0x77c423e4 in _libkernel32_a_iname ()
#1 0x0022d09c in ?? ()
#2 0x77c3ffb9 in _libkernel32_a_iname ()
#3 0x104e41a3 in qt_mt3_dll_iname ()
#4 0x0040472b in myForm::play_file(QString) ()
#5 0x004065c6 in myForm::stop() ()
#6 0x00402ca5 in myForm::show_playlist() ()
#7 0x00428c63 in mainForm::qt_invoke(int, QUObject*) (this=0x22fdd0, _id=61,
_o=0x22f3fc) at .moc/moc_mainform.cpp:147
#8 0x00426267 in myForm::qt_invoke(int, QUObject*) (this=0x22fdd0, _id=61,
_o=0x22f3fc) at .moc/moc_myform.cpp:175
#9 0x100c3bec in qt_mt3_dll_iname ()
#10 0x100c495f in qt_mt3_dll_iname ()
#11 0x10595120 in qt_mt3_dll_iname ()
#12 0x1011643f in qt_mt3_dll_iname ()
#13 0x1004d381 in qt_mt3_dll_iname ()
#14 0x1004f39d in qt_mt3_dll_iname ()
#15 0x100093e7 in qt_mt3_dll_iname ()
#16 0x1000aa89 in qt_mt3_dll_iname ()
#17 0x77d48709 in _libkernel32_a_iname ()
#18 0x77d487eb in _libkernel32_a_iname ()
#19 0x77d489a5 in _libkernel32_a_iname ()
#20 0x77d489e8 in _libkernel32_a_iname ()
#21 0x100169a7 in qt_mt3_dll_iname ()
#22 0x1006d4f1 in qt_mt3_dll_iname ()
#23 0x1006d446 in qt_mt3_dll_iname ()
#24 0x0040137e in main ()
=========

jacek
12th May 2006, 20:45
What does myForm::play_file(QString) do?

safknw
12th May 2006, 21:09
What does myForm::play_file(QString) do?
Play the file specied as argument in mplayer in slave mode.

jacek
12th May 2006, 22:41
Play the file specied as argument in mplayer in slave mode.
It calls some function from Qt which leads to a crash. Do you know which one? If not, compile Qt in debug mode and try again (make sure you have "CONFIG += console" to your .pro file and check whether there are any messages on the console).

georgie
13th May 2006, 05:23
if it crashes at a point when you are accessing a file, did you make sure to change these filenames to windows format too? or is it a user input/file dialog kinda situation