Author Topic: Howto - Cross Compiling in Linux using MingW32  (Read 353066 times)

Offline RagnarDa

  • Single posting newcomer
  • *
  • Posts: 4
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #90 on: March 23, 2012, 05:07:19 pm »
Hi guys!

I have tried to follow the guide http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux doing it multiple times over. I don't think I've missed anything. I created a new wxWidget project in C::B and have done nothing to it, except whats in the guide. When I compile the Debug/Release targets (for Linux) it compiles and runs fine, but my "WinRelease" - target generates the following build error:

Code: [Select]
/home/christoffer/Projekt/wxLinux/wxLinuxApp.h|13|fel: wx/app.h: Filen eller katalogen finns inte|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|14|fel: wx/menu.h: Filen eller katalogen finns inte|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|15|fel: wx/statusbr.h: Filen eller katalogen finns inte|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|16|fel: wx/frame.h: Filen eller katalogen finns inte|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp|14|fel: wx/image.h: Filen eller katalogen finns inte|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.h|16|error: expected class-name before ‘{’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|20|error: expected class-name before ‘{’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|23|error: expected `)' before ‘*’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|29|error: ‘wxCommandEvent’ has not been declared|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|30|error: ‘wxCommandEvent’ has not been declared|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|40|error: ISO C++ forbids declaration of ‘wxStatusBar’ with no type|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|40|error: expected ‘;’ before ‘*’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|43|error: ISO C++ forbids declaration of ‘DECLARE_EVENT_TABLE’ with no type|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|44|error: expected ‘;’ before ‘}’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|44|error: expected `;' before ‘}’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp|17|error: expected constructor, destructor, or type conversion before ‘;’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp||In member function ‘virtual bool wxLinuxApp::OnInit()’:|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp|23|error: ‘wxInitAllImageHandlers’ was not declared in this scope|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp|26|error: no matching function for call to ‘wxLinuxFrame::wxLinuxFrame(int)’|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|20|note: candidates are: wxLinuxFrame::wxLinuxFrame()|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|20|note:                 wxLinuxFrame::wxLinuxFrame(const wxLinuxFrame&)|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp|27|error: ‘class wxLinuxFrame’ has no member named ‘Show’|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp|28|error: ‘SetTopWindow’ was not declared in this scope|
||=== Build finished: 20 errors, 0 warnings ===|

"Filen eller katalogen finns inte" means "File or folder doesnt exist".

Im using Ubuntu 11.10, C::B 10.05, wxMSW-2.8.12 (wxWidget) and mingw32 is latest (from apt-get).

I've searched the forum the best I could but I'm new to this, and Linux in general...

EDIT:
When i execute wx-config --list i get:

Code: [Select]
  Default config is gtk2-unicode-release-2.8

  Default config will be used for output

  Alternate matches:
    base-unicode-release-2.8

But when i execute /usr/i586-mingw32msvc/lib/wx/config/i586-mingw32msvc-msw-unicode-release-static-2.8 --list i get

Code: [Select]
  Default config is i586-mingw32msvc-msw-unicode-release-static-2.8

  Default config will be used for output

  Also available in /usr/i586-mingw32msvc:
    i586-mingw32msvc-msw-unicode-static-2.9
« Last Edit: March 23, 2012, 05:35:42 pm by RagnarDa »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9592
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #91 on: March 23, 2012, 05:51:50 pm »
target generates the following build error:
Always the full build log, please...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline RagnarDa

  • Single posting newcomer
  • *
  • Posts: 4
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #92 on: March 23, 2012, 09:50:46 pm »
Always the full build log, please...

Rgr.

Code: [Select]
-------------- Build: WinRelease in wxLinux ---------------

Linking executable: bin/Release/wxLinux.exe
obj/Release/wxLinuxApp.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
 

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12362
    • Travis build status
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline RagnarDa

  • Single posting newcomer
  • *
  • Posts: 4
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #94 on: March 23, 2012, 10:55:18 pm »
This is not the full log.
See here for details: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

OK.

Code: [Select]
-------------- Build: WinRelease in wxLinux ---------------

i586-mingw32msvc-g++ -L/usr/i586-mingw32msvc/lib/ -L/usr/i586-mingw32msvc/lib  -o bin/Release/wxLinux.exe obj/Release/wxLinuxApp.o obj/Release/wxLinuxMain.o   -s  -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid 
obj/Release/wxLinuxApp.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
 

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9592
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #95 on: March 23, 2012, 11:20:42 pm »
obj/Release/wxLinuxApp.o: file not recognized: File format not recognized
...I don't know why, but that's the cause. Help yourself and find out what you are doing there...

In addition, you only show the linking process. What we are asking for is the full build process, so do a clean before or a complete new re-build.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline RagnarDa

  • Single posting newcomer
  • *
  • Posts: 4
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #96 on: March 23, 2012, 11:44:10 pm »
I uninstalled mingw32 and sudo apt-get install'ed it again, did a clean and a rebuild the project and this is what i got:

Code: [Select]
-------------- Clean: WinRelease in wxLinux ---------------

Cleaned "wxLinux - WinRelease"

-------------- Build: WinRelease in wxLinux ---------------

i586-mingw32msvc-g++ -Wall  -O2      -I/usr/i586-mingw32msvc/include -I/usr/i586-mingw32msvc/include  -c /home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp -o obj/Release/wxLinuxApp.o
I fil inkluderad från /home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:10:
/home/christoffer/Projekt/wxLinux/wxLinuxApp.h:13:20: fel: wx/app.h: Filen eller katalogen finns inte
I fil inkluderad från /home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:13:
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:14:21: fel: wx/menu.h: Filen eller katalogen finns inte
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:15:25: fel: wx/statusbr.h: Filen eller katalogen finns inte
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:16:22: fel: wx/frame.h: Filen eller katalogen finns inte
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:14:22: fel: wx/image.h: Filen eller katalogen finns inte
In file included from /home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:10:
/home/christoffer/Projekt/wxLinux/wxLinuxApp.h:16: error: expected class-name before ‘{’ token
In file included from /home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:13:
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:20: error: expected class-name before ‘{’ token
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:23: error: expected `)' before ‘*’ token
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:29: error: ‘wxCommandEvent’ has not been declared
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:30: error: ‘wxCommandEvent’ has not been declared
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:40: error: ISO C++ forbids declaration of ‘wxStatusBar’ with no type
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:40: error: expected ‘;’ before ‘*’ token
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:43: error: ISO C++ forbids declaration of ‘DECLARE_EVENT_TABLE’ with no type
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:44: error: expected ‘;’ before ‘}’ token
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:44: error: expected `;' before ‘}’ token
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:17: error: expected constructor, destructor, or type conversion before ‘;’ token
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp: In member function ‘virtual bool wxLinuxApp::OnInit()’:
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:23: error: ‘wxInitAllImageHandlers’ was not declared in this scope
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:26: error: no matching function for call to ‘wxLinuxFrame::wxLinuxFrame(int)’
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:20: note: candidates are: wxLinuxFrame::wxLinuxFrame()
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:20: note:                 wxLinuxFrame::wxLinuxFrame(const wxLinuxFrame&)
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:27: error: ‘class wxLinuxFrame’ has no member named ‘Show’
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:28: error: ‘SetTopWindow’ was not declared in this scope
Process terminated with status 1 (0 minutes, 0 seconds)
20 errors, 0 warnings

Thank you for your quick response!

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9592
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #97 on: March 23, 2012, 11:53:41 pm »
I uninstalled mingw32 and sudo apt-get install'ed it again, did a clean and a rebuild the project and this is what i got:
Code: [Select]
i586-mingw32msvc-g++ -Wall  -O2      -I/usr/i586-mingw32msvc/include -I/usr/i586-mingw32msvc/include  -c /home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp -o obj/Release/wxLinuxApp.o
See, and finally we got all information we need. ::)

As you see from the compiler step, you are missing to provide the full set of required wxWidgets flags to compile your wxWidgets app, like include folders, and #defines. So the compiler doesn't not know where to search for the include files as shown in the error messages. Adjust your project settings accordingly and it will work. Inspect the instruction of the wxWidgets library to now how to do so. This is no longer a Code::Blocks issue -> please don't post in this thread again therefore.

Next time, to speed up things, read the forum rules (you agreed to when registering with the forum btw) and post the right stuff in the first place. Also note this (again):
http://forums.codeblocks.org/index.php/topic,9996.0.html
Thank you.

Edit: Typos.
« Last Edit: March 23, 2012, 11:56:17 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Leshyk

  • Single posting newcomer
  • *
  • Posts: 4
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #98 on: November 20, 2012, 11:12:10 pm »
Thank you very much for this review! It works fine but debuging...

More precisely:
My system is ubuntu. The goal is to compile dll as a plugin for some windows application.
Following the instructions I was able to compile, link and to begin debugging. For debugging mingw32-gdb.exe under wine was used.

The C::B was able to put breakpoint but when the programm stops I have the following error in the debugger window: "The program has stopped on a breakpoint but the breakpoint format is not recognized".

In the source code (http://fossies.org/dox/codeblocks-10.05-src/gdb__driver_8cpp_source.html) I found that this error message appears when the result output doesn't coincide with regexp either reBreak or reBreak_or32 (*). Manually I would say that this string should coincide with reBreak_or32 and, so, there is two cases why the error appears 1) somehow reBreak instead of reBreak_or32 is applied (I tried to change development flower in the C::B settings to 'or32' but nothing changed) 2) there are some invisible symbols which don't coincide with regexp

1) The further way of searching for the solution is to rebuild debuggergdb but how can I rebuild only that module and where should I put the rebuilt module?
2) What else can I do to make the debugger working?

(*) To the developers of debuggergdb, Just a curiosity:
Why you use this kind of code
Code: [Select]
  43 #ifdef __WXMSW__
   44     static wxRegEx reBreak(_T("([A-Za-z]*[:]*)([^:]+):([0-9]+):[0-9]+:[begmidl]+:(0x[0-9A-Fa-f]+)"));
   45     static wxRegEx reBreak_or32(_T("\032\032([A-Za-z]:)([^:]+):([0-9]+):[0-9]+:[begmidl]+:(0x[0-9A-z]+)"));
   46 #else
   47     static wxRegEx reBreak(_T("\032\032([^:]+):([0-9]+):[0-9]+:[begmidl]+:(0x[0-9A-Fa-f]+)"));
   48     static wxRegEx reBreak_or32(_T("")); // not used on linux, but make sure it exists otherwise compilation fails on linux (if (platform::windows) blabla)
   49 #endif
and then trying to select the right version of reBreak or reBreake_or32 while it is mush more understandable to use one regex like this
Code: [Select]
static wxRegEx reBreak(_T("\{\032\032\}?(\{[A-Za-z]*[:]*\}?)([^:]+):([0-9]+):[0-9]+:[begmidl]+:(0x[0-9A-Fa-f]+)"));
The performance here seems to be not so much important...
« Last Edit: November 20, 2012, 11:24:41 pm by Leshyk »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12362
    • Travis build status
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #99 on: November 20, 2012, 11:21:15 pm »
Because we're not regex masters and the wxregex is not that powerful (I suppose your regex would work, though).
Try it and tell us what is the result...

To rebuild, if I were you I'd use the autotools system with a prefix to modify and rebuild C::B.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Leshyk

  • Single posting newcomer
  • *
  • Posts: 4
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #100 on: November 20, 2012, 11:40:45 pm »
Thank you,
Quote
autotools system with a prefix to modify
I am not familiar with autotools, and as far as I understand, prefix is used to give the install directory?
So I will still need to rebuild the whole C::B? Is it save to modify Makefile.am/SUBDIRS to limit the number of built projects?
By default where the new plugin should be placed or "make install" will do everything?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12362
    • Travis build status
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #101 on: November 21, 2012, 12:39:49 am »
If you're on a current machine the rebuild will take around 10 minutes and you would have finished with it.

Code: [Select]
checkout lastest svn version
./bootstrap
./configure --prefix=full_path_to_install --with-contrib-plugins=all
make jN && make install
If you don't want to build contrib plugins you can skip the last part of the configure command, then it will be even faster.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Leshyk

  • Single posting newcomer
  • *
  • Posts: 4
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #102 on: November 21, 2012, 03:13:22 pm »
Quote
If you don't want to build contrib plugins you can skip the last part of the configure command, then it will be even faster.
I have expected that I should rebuild all the C::B after a small modification. However it saves the result of previous builds, so 10 minutes is just for the first time and it is not a problem.

I have corrected the file, which I took from the svn/trunk. I have opportunity to test it only in linux -- native linux and crosscompiling. In both cases the code works fine. I add some comments of what I have changed.

Edit: typos
« Last Edit: November 21, 2012, 03:17:21 pm by Leshyk »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12362
    • Travis build status
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #103 on: November 21, 2012, 03:21:26 pm »
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Leshyk

  • Single posting newcomer
  • *
  • Posts: 4
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #104 on: November 21, 2012, 03:56:57 pm »
Quote
How about providing a patch?
Done. Patch 003373.