[Solved] wx.mod working with tdm-gcc-4.8.1-3.exe

BlitzMax Forums/MaxGUI Module/[Solved] wx.mod working with tdm-gcc-4.8.1-3.exe

MOBii(Posted 2014) [#1]
This is Secret no #1:
https://github.com/maxmods

Secret no #2:
https://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/
tdm-gcc-4.8.1-3.exe
Brucey: Win32 BlitzMax with GCC 4.x - HowTo

Secret no #3:
Build
(BLIDE is very good in Building module's)

Secret no #4:
I chose to Remark this line:
; import "../lib/win32/wx_rc.o"
In those files:
C:\BlitzMax\mod\wx.mod\wx.mod\wx.debug.win32.x86.i
C:\BlitzMax\mod\wx.mod\wx.mod\wx.release.win32.x86.i
C:\BlitzMax\mod\wx.mod\wx.mod\.bmx\common.bmx.debug.win32.x86.i
C:\BlitzMax\mod\wx.mod\wx.mod\.bmx\common.bmx.release.win32.x86.i

If you remark: import "../lib/win32/wx_rc.o" Then you get Error ReBuild the wx.mod
So if you still want to use: C:\BlitzMax\mod\wx.mod\lib\win32\wx_rc.o
You can always use ResHacker on your .exe and alter alter the first line of ICONGROUP:
WXICON_AAA ICON "Icon_1.ico"
I don't know HOWTO make changes on a binary .o file

Secret no #5:
No need to Restart the Computer ^^

Secret no #6:
Copy libpthread_s.dll.a to my project folder and add 2 magical line to the wx.bmx file:
Import "-lgcc"
Import "libpthread_s.dll.a"

END of Secret's


I go up in the middle of the night so I could Download: https://github.com/maxmods, and let it build while I go sleep
When I woke up it was ALL done!
I can't describe my happiness when I run my test: absolut.bmx and it actually worked!
Probably my last 100% Happiness moment in Life!

READABLE Links:
wxMax help


Thank thee munch for showing: Brucey, Win32 BlitzMax with GCC 4.x - HowTo
for guiding me to right, MinGW path

and Finally thanks you Brucey for all your mods that is far better than I ever could expected!
I only chose BlitzMax MaxGUI over Monkey X, so with wxWidgets, BlitzMax become even more better now.
Maybe wxWidgets is someday coming to Monkey X, who know?
Maybe someday I going to buy Monkey X, who know?
BlitzMax is faster and can make smaller application than Monkey X and it have wx.mod try beat that Monkey X!
And Don't forget BlitzMax has MySQL support *and the crowd go wild*


and Last thank thee all for NOT complaining over my bad writing/spelling, thank thee very much


markcw(Posted 2014) [#2]
Glad you got it working.

Just wondering, are you using Brucey's patched versions of brl.mod and pub.mod?


MOBii(Posted 2014) [#3]
I download all of Brucey:
https://github.com/maxmods

The Downloaded Brucey: bah, brl, ifsogui, pub and wx is only source code so I rebuild all with gcc 4.7.1

Is gcc 4.7.1 really the one I shall use, or did I misunderstand something?

Downside when I downgrade the MinGW is that BLIDE don't include the .exe .ico (the file icon) when Publish current Program.

My MaxGUI project stop working I dunno why yet, (I don't put time into this at the moment)

This is a bigger problem for me:
I get this Compile Error: Duplicate identifier 'luaL_newstate' in modules 'zeke.luajit2' and 'pub.lua' after I reBuild all the modules to 4.7.1


MOBii(Posted 2014) [#4]
I am thinking to drop MaxGUI even if the .exe is smaller than 500Kb (that is impressive)
the smallest wx.mod .exe is now when wx.mod is baked into the .exe around 3100Kb
I now try learn wx.mod and it's pure joy, I feel young again!
I say: wx.mod can make Windows Applications as easy as PHP make webpages, and how cool is that?


markcw(Posted 2014) [#5]
I've read that the latest (4.8) gcc is 64-bit only but haven't tested this myself.

Your lua compile error seems to be that you can't have both pub.lua and zeke.luajit2 installed at the same time. So try this: rename the pub lua.mod folder to say lua or move it out of pub.mod and then rebuild modules or in cmd type cd c:\blitzmax\bin and .\bmk makemods -a zeke

I don't know about the icon issue.


Brucey(Posted 2014) [#6]
I've read that the latest (4.8) gcc is 64-bit only but haven't tested this myself.

That's not the first time you've said that. TDM is not. I can't speak for any others though.
The 64-bit TDM builds for both 64-bit and 32-bit. Binaries are all 32-bit, so you can build for 64-bit on your 32-bit machine, if you like. Of course, you can't test it then ;-)


MOBii(Posted 2014) [#7]
tdm-gcc-4.8.1-3.exe
29.3 MB · GCC 4.8.1
Bundle installer for the TDM32 MinGW edition. Includes C, C++, and OpenMP support, SJLJ exception handling, other GNU toolchain programs (binutils), Windows API libraries (MinGW WSL), GNU make (mingw32-make), and the GNU debugger (GDB).

I test tdm-gcc-4.8.1-3.exe, but it didn't build the wx.mod for me..

Edit: When I think about it I use 4.8.1 on wxmax_1_01_win32_bin.rar
(I shall test rebuild with 4.8.1 once more)


the Assembly Information and the Icon from BLIDE don't get included when I use 4.7.1
I am lazy so I like when BLIDE do it that automatically for me.
ResHack don't work when BLIDE use the Ultimate Packer for eXecutables.


What gcc version I use, so wx.mod and BLIDE can include the icon and the Assembly Information?


Sorry for asking this too:
manifest file configuration is that the .res xml file?


Henri(Posted 2014) [#8]
Maybe this is what you are looking for ?

-Henri


MOBii(Posted 2014) [#9]
I reinstall: tdm-gcc-4.8.1-3.exe and this time it Build all wx.mod's
But when I Build a sample I get back the sjlj Error's again
C:/BlitzMax/lib/libgcc.a(unwind-sjlj.o): In function `_gthread_key_create':
C:/BlitzMax/lib/libgcc.a(unwind-sjlj.o): In function `_gthread_once':
c:\crossdev\gccmaster\build-tdm32\gcc\mingw32\libgcc/./gthr-default.h:699: undefined reference to `pthread_once'

Thanks Henri for teaching me how to use windres, I am going to try Google more about that..

I think
Import "iconBLL.o"
is how BLIDE is doing when Building a Solution and it's not working in 4.7.1-2

It's little funny thou, when I Build a wx.mod.bmx it set the fileIcon to the wxWidgets Icon.
(That mean it is possible to set the fileIcon somehow)

This is only set the Application Frame Icon:
setIcon(wxIcon.CreateFromFile("incbin::data/BLHTML.png", wxBITMAP_TYPE_PNG))


My question is still if there are any newer TDM I can use or I am stuck with 4.7.1-2 if I want to use wx.mod?
Edited: [Solved] tdm-gcc-4.8.1-3.exe is OK


Derron(Posted 2014) [#10]
Just use GCC 4.8.1 ... and check if you copied all needed files (/lib, /bin/ar.exe, /bin/ld.exe) then recompile EVERY module.

If ensured you did this:

pthread_once missing? Maybe you need to state to import "-lpthread" somewhere in the module.
According to "This Post" an "-lgcc" will help (was for GCC 4.4).


Last time I checked wxMax, it compiled with 4.8.1 but not with 4.7.1 (while maxmod2.mod or more specific rtaudio.mod works with 4.7.1 but not with 4.8.1). Maybe there were changes making it not compiling anylonger. But as the last googlecode-changes were done in end of 2013 ... i really doubt it.


Ok so what I have done now:
- startet my XP VM having TDM 4.8.1 installed

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/lto-wrapper.exe
Target: mingw32
Configured with: ../../../src/gcc-4.8.1/configure 
--build=mingw32 
--enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-libgomp --enable-lto --enable-graphite
--enable-libstdcxx-debug --enable-threads=posix --enable-version-specific-runtime-libs 
--enable-fully-dynamic-string --enable-libstdcxx-threads --enable-libstdcxx-time --with-gnu-ld
--disable-werror --disable-nls --disable-win32-registry --disable-symvers 
--enable-cxx-flags='-fno-function-sections -fno-data-sections -DWINPTHREAD_STATIC'
--prefix=/mingw32tdm --with-local-prefix=/mingw32tdm --with-pkgversion=tdm-2
--enable-sjlj-exceptions --with-bugurl=http://tdm-gcc.tdragon.net/bugs
Thread model: posix
gcc version 4.8.1 (tdm-2)


so it is TDM-2, maybe this makes some difference.


- checked I have BlitzMax installed
- did an svn-checkout with TortoiseSVN (alternatively do "svn checkout http://wxmax.googlecode.com/svn/trunk/ wxmax")
- waited 14 minutes to download the thing from SVN (slow googlecode.com server)
- moved "wx.mod" out of "wxmax" into the blitzmax-mod folder (it stays to be an svn-repo, but without the parental folder)
- run "bmk makemods -r wx"
- waited a while
- waited a while longer (virtual machines ... i only give them 1gb of ram and 1 core as I often run multiple machines simultaneously)
- waited 34min while playing a game

- tried to compile samples: same error like you

"undefined reference to `pthread_getspecific'" etc.


So what to do?

add this to your imports (eg. on top of the samples file):

Import "-lgcc"
Import "-lpthread_s.dll"


What is "lpthread_s.dll" ?? Seems there is a "libpthread.a" in the lib-folder of blitzmax, but also a "libpthread_s.dll.a" -- and THIS file does compile your samples then.

Maybe someone with more knowledge could explain how to "automate" this then.


bye
Ron


MOBii(Posted 2014) [#11]
First off Derron, I am really in our debt, thank you really for helping
(My wife getting cranky when all my effort is going to make wx.mod to work)


Installed: tdm-gcc-4.8.1-3.exe
gcc --version
gcc (tdm-2) 4.8.1
So it look that I have the same.

It work for me when I copy libpthread_s.dll.a to my folder and:
Import "-lgcc"
Import "libpthread_s.dll.a"


But I got same problem with the program icons, so I reinstall BlitzMax
That didn't help at all and I had to reBuild all again..

While rebuilding I found Ziggy's secret in Life: UPX: the Ultimate Packer for eXecutables
UPX is in my toolbox forever now (Totally cool program)!

RUNUPX.bat:
C:\BlitzMax\ResHack\ResHacker.exe -script C:\BlitzMax\MOBii\BLL\build\ResHack.script
del BLL.exe
upx -6 -oMOBii.exe tmp.exe --compress-icons=2
rem move BLL2.exe BLL.exe
del tmp.exe


build\ResHack.script:
[FILENAMES]
Exe=C:\BlitzMax\MOBii\BLL\BLL.exe
SaveAs=C:\BlitzMax\MOBii\BLL\tmp.exe
Log=build/Log.txt

[COMMANDS]
//-delete ICONGROUP, WXICON_AAA,
-delete ICONGROUP, WXICON_SMALL_CDROM,
-delete ICONGROUP, WXICON_SMALL_CLOSED_FOLDER,
-delete ICONGROUP, WXICON_SMALL_COMPUTER,
-delete ICONGROUP, WXICON_SMALL_DRIVE,
-delete ICONGROUP, WXICON_SMALL_FILE,
-delete ICONGROUP, WXICON_SMALL_FLOPPY,
-delete ICONGROUP, WXICON_SMALL_OPEN_FOLDER,
-delete ICONGROUP, WXICON_SMALL_REMOVEABLE,

-addoverwrite C:\BlitzMax\MOBii\BLL\icon.ico, ICONGROUP, WXICON_AAA,
// I can't Write to: 1, 1033
//-add C:\BlitzMax\MOBii\BLL\icon.ico, ICONGROUP, 1, 1033     // 1:1033 Not Working
//-add C:\BlitzMax\MOBii\BLL\icon.ico, ICONGROUP, 1,
// icon.ico :: stored in: ICON GROUP + 1 + 0
If I rename to original filename:
move MOBii.exe BLL.exe
Then the wxWidget's Icon get back hehe
(Something magic with that wxWidget Icon)

Otherwise the Application Icon is WORKING OK NOW with the ResHacker.script!!! Cheers


Derron(Posted 2014) [#12]
To get an Icon in the top left border when the app is running:

	Local Icon:wxIcon = New wxIcon.Create()
	Icon.LoadFile("win32_icon.ico", wxBITMAP_TYPE_ICO)
	If Not Icon.IsOk() Then Throw("Can't load 'win32_icon.ico'")
	'frame is your "AppFrame"
	frame.SetIcon(Icon)


But this does not get rid of the icon used in the explorer, somehow wxwidget changes it, so a normal "import "bla.o" is not enough).


bye
Ron


MOBii(Posted 2014) [#13]
Think this is more or less the same:
Import brl.RamStream
IncBin "data/BLHTML.png"
setIcon(wxIcon.CreateFromFile("incbin::data/BLHTML.png", wxBITMAP_TYPE_PNG))
As you say it's only the Frame Icon

Somewhere in the wx.mod is setting that magical wxWidgets icon ^^

I learn that all the Application Icon is blinking when Repeating Pressing F5 (Refresh)
My world view must be really small when I didn't even know that!


Henri(Posted 2014) [#14]
Any help from this ?

-Henri


Derron(Posted 2014) [#15]
Think this would do it ... (I did not test it).

I knew that there is a .rc somewhere - and as this is defined BEFORE our file ... this is then the icon which Windows uses.


In our case it might be better to replace that file with an "empty" one (not containing any icon-definition in the .rc file we compile to ".o" later on).
So we could apply a custom one in each of our wx-projects.


EDIT:
// First wx icon in alphabetical order, so it will be used by Explorer if the
// application doesn't have any icons of its own
wxICON_AAA                      ICON "wx/msw/std.ico"


That was copied from the .rc-file and somehow this sounds like we should be able to "override" this setting with adding custom icons... hmm and this is done exactly HOW ?


bye
Ron


markcw(Posted 2014) [#16]
That's not the first time you've said that. TDM is not. I can't speak for any others though.

Yeah, sorry about that. I'll really have to check my facts out in future. Don't want to be misleading folks.


MOBii(Posted 2014) [#17]
The Magic wxIcon:
http://www.blitzmax.com/Community/posts.php?topic=101279#1207287
Brucey:
There's a wx_rc.o in the lib/win32

windres -iBLL.rc -owx_rc.o
BLL.rc:
AppIcon ICON "BLHTML.ico"
copy wx_rc.o C:\BlitzMax\mod\wx.mod\lib\win32\wx_rc.o /Y


MOBii(Posted 2014) [#18]
Even better, delete this line:
import "../lib/win32/wx_rc.o"
In those files:
C:\BlitzMax\mod\wx.mod\wx.mod\wx.debug.win32.x86.i
C:\BlitzMax\mod\wx.mod\wx.mod\wx.release.win32.x86.i
C:\BlitzMax\mod\wx.mod\wx.mod\.bmx\common.bmx.debug.win32.x86.i
C:\BlitzMax\mod\wx.mod\wx.mod\.bmx\common.bmx.release.win32.x86.i

Then the Publish function is working again in BLIDE


Derron(Posted 2014) [#19]
If you remove that "wx_rc.o" file you also remove the other settings done there (cursors, use manifest or not, ...).

It is better to just remove the line I posted above ... so it does not set a custom icon at all.

In your app you then just could 'import "myicon.o"' to have a custom icon in your app ... no need to have a custom publish function... or need "BLIDE" at all (although you seem to have it already :D).

Another option is to use "post.bmk" (needs bruceys BMK) and a call to some commandline tools to replace the icon ... just execute your ResHack-Script or so.



bye
Ron


MOBii(Posted 2014) [#20]
If I Remark this line:
; import "../lib/win32/wx_rc.o"
In those files:
C:\BlitzMax\mod\wx.mod\wx.mod\wx.debug.win32.x86.i
C:\BlitzMax\mod\wx.mod\wx.mod\wx.release.win32.x86.i
C:\BlitzMax\mod\wx.mod\wx.mod\.bmx\common.bmx.debug.win32.x86.i
C:\BlitzMax\mod\wx.mod\wx.mod\.bmx\common.bmx.release.win32.x86.i

Then I can't ReBuild wx.wx.mod, and if I replace wx_rc.o with a own made: wx_rc.o
I can't add my own:
Import "data/BLHTML.o"
(the wx_rc.o write over my Imported rc.o)

Is it possible to write: MuOwnRC.o to my already .exe file?

I didn't see that I can reWrite a .rc file to a exe with ResHacker
and the only other solution I found is:
gcc -o EDii.exe BLHTML.o EDii.o

But I don't know howto get the EDii.o


Derron(Posted 2014) [#21]
If you add multiple icons, windows will still use the first one - which in our case is the wxwidgets one.


you will have to remove the icon-entry from the ".rc"-file, recompile the .o file out of it - and after this, you should be able to use your own "bla.o" file in your projects (as no other icon definition was made then).


bye
Ron


MOBii(Posted 2014) [#22]
Is it possible to rcfile.o ---> rcfile.rc?


I can:
-addoverwrite data\icon.ico, ICONGROUP, WXICON_AAA,
width the ResHacker.script

But then I don't know howto Write a new:
1 VERSIONINFO
FILEVERSION     1,0,0,0
PRODUCTVERSION  1,0,0,0
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "041D04E2"
    BEGIN
      VALUE "CompanyName", "My Company Name"
      VALUE "FileDescription", "My excellent application"
      VALUE "FileVersion", "1.0"
      VALUE "InternalName", "my_app"
      VALUE "LegalCopyright", "My Name"
      VALUE "OriginalFilename", "my_app.exe"
      VALUE "ProductName", "My App"
      VALUE "ProductVersion", "1.0"
    END
  END

  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x041D, 1250
  END
END
I can't write new this with ResHacker

If I could write a .rc file to the exe then I wouldn't mind the wx_rc.o and I live happily ever after?


MOBii(Posted 2014) [#23]
I try add the: VERSIONINFO as I do in the rc script
1 24 "BLHTML.bin":
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
   manifestVersion="1.0">
<description>Windows forms common control manifest</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32"
   name="Microsoft.Windows.Common-Controls"
   version="6.0.0.0" processorArchitecture="x86"
   publicKeyToken="6595b64144ccf1df" language="*" />
</dependentAssembly>
</dependency>
</assembly>


I try experiment like this:
-add VERSIONINFO.bin, "Version Info", 1,
This create a "VERSION INFO", 1 and the VERSIONINFO.bin is there

CAPITAL: "VERSION INFO" don't work
I give up this for now..


Derron(Posted 2014) [#24]
It is up to you to give up.


".rc"-files are "resource configuration files" -- so they are editable with notepad etc.

with the "windres"-thing you could create new ".o"-files out of it (see the batchfile yous quoted in this thread).

this ".o"-file is automatically used when importing "wx.mod"-packages into your project. They are linked before YOUR code ... so they include the first icon windows will find in the binary.

You could now open that .rc-file, comment out the icon-part, recompile the ".o"-file of it using windres -> replace the existing one (somewhere in the wx.mod folder). From now on you should be able to do

import "myicon.o" in your app (myicon.o is then an object file of your OWN .rc-file ...like you posted above) and it should get displayed.


I am not testing this -- I am on linux and we do not have "icons in binaries" so I am only assuming it.

bye
Ron


MOBii(Posted 2014) [#25]
To change icon with ResHacker:
-addoverwrite data\icon.ico, ICONGROUP, WXICON_AAA,
My problem is howto add:
-add VERSIONINFO.bin, "Version Info", 1,
This write "VERSION INFO" with CAPITAL and that doesn't Work

I do it wrong!


Derron(Posted 2014) [#26]
I cannot follow what you want to do.

do not mix things ...first try to get icon working, then other things.

Try the things I described, if they do not work ... feel unlucky. Mixing in other subjects just adds confusion.


bye
Ron


MOBii(Posted 2014) [#27]
I am Sorry Derron, I never really learn Forum etiquette.
I was ashamed so I try ask in another Programming forum if it was possible to split a exe so I could rebuild it:
gcc -o EDii.exe rc.o EDii.o
I get no answer

In the beginning I put many question in same post and then people answer one question and the other questions got ignored!
I need to learn NOT to put out to many question in same threads/post, I am still learning so please forgive my childish behavior.

I Remark the:
; import "../lib/win32/wx_rc.o"
Because of that I can't ReBuild wx.mod.
I didn't like any of the resources in wx_rc.o and I could not build any wxProgram properly. That's why I chose to give up and exclude: wx_rc.o once again.

I am just happy wx.mod is finally working for me, the wx code is truly beautiful, again thank thee all for helping me


Derron(Posted 2014) [#28]
I played a bit with it.

as soon as I remove that "wxICON aaa ..." part of the rc-file, I get the "drive folder icon" as application icon (it is the next in the file).

To compile the ".rc" file just copy it to two folders above (wx.mod/include)
afterwards rename it to "wx_rc.o" and copy that .o-file to "wx.mod/lib/win32".

Even if removing everything from the .rc-file (except something like the menu definition) it does not use my custom icon.

When then removing the ".o"-file out of the .i-files you mentioned (common and wx.mod.release..." it accepts my icon again.

Dunno what causes this.


What works too (and is confusing):

I prepended my custom file in the .i-file


wx.release.win32.x86.i
import "-lwsock32"
import "-lodbc32"
import "-lgdiplus"
import "../lib/win32/wx_rc.o"


to
import "-lwsock32"
import "-lodbc32"
import "-lgdiplus"
import "win32_icon.o"
import "../lib/win32/wx_rc.o"


Of course I copied "win32_icon.o" into the WX-directory.


Maybe Brucey can answer how to manually "prepend" a custom line within our blitzmax source files.

I mean something like 'ImportFirst "myicon.o"' which is then used as the first one. Maybe it is doable with something in the lines of the .bmk-files (there is "post.bmk" so there will be "pre.bmk" too).


bye
Ron