Author Topic: Compiling C::B using Msys2  (Read 9996 times)

Offline alle_meije

  • Multiple posting newcomer
  • *
  • Posts: 29
Compiling C::B using Msys2
« on: August 19, 2015, 01:47:51 pm »
For some reason the C::B binaries often crash on my Win7 laptop.
For development on this laptop I use a combination of C::B and Msys2
(https://sourceforge.net/p/msys2/wiki/MSYS2 installation)

I am now trying to compile C::B in the Msys2 envioronment.
The Linux installation instructions (http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Linux) seem most suitable for building in Msys2.

Compiling wxwidgets was easy:
1. wget --no-check-certificate https://github.com/wxWidgets/wxWidgets/archive/master.zip && unzip master.zip && mv wxWidgets-master wxWidgets-dev
2. cd wxWidgets-dev
3. configure --prefix=/mingw64; make; make install ## prefix for the 64bit compiler environment

The wxWidgets tests described on the linux page all work (i.e. return useful info):
$ wx-config --prefix
/mingw64
$ wx-config --libs
-L/mingw64/lib   -Wl,--subsystem,windows -mwindows -lwx_mswu_xrc-3.1 -lwx_mswu_html-3.1 -lwx_mswu_qa-3.1 -lwx_mswu_adv-3.1 -lwx_mswu_core-3.1 -lwx_baseu_xml-3.1 -lwx_baseu_net-3.1 -lwx_baseu-3.1
$ which wx-config
/mingw64/bin/wx-config

Then I continue with C::B:
a) svn checkout http://svn.code.sf.net/p/codeblocks/code/trunk codeblocks-dev
b) cd codeblocks-dev/
c) ./bootstrap
d) ./configure --with-wx-config=`which wx-config`; ## no errors/warnings, wxwidgets 3.1 found, advised to issue 'make'
e) make

follows with the output below.

The warnings and errors all seem to relate to DLLexport and DLLimport.
Is this something that should be set explicitly when (in Windows) it's not possible to use C::B to build C::B?

Thanks for the help, really hoping to use C::B also in Msys2 for Windows binaries!



`make` output:

Code: [Select]
/bin/sh ../../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../src/include  -I/mingw64/lib/wx/include/msw-unicode-3.1 -I/mingw64/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMSW__   -I../../src/include -I../../src/sdk/wxscintilla/include  -I../../src/include/tinyxml -I../../src/include/scripting/include -I../../src/include/scripting/bindings -I../../src/include/scripting/sqplus -I../../src/include/mozilla_chardet -I../../src/include/mozilla_chardet/mfbt -I../../src/include/mozilla_chardet/nsprpub/pr/include -I../../src/include/mozilla_chardet/xpcom -I../../src/include/mozilla_chardet/xpcom/base -I../../src/include/mozilla_chardet/xpcom/glue -ansi -DTIXML_USE_STL  -O2 -ffast-math -DCB_AUTOCONF -g -O2 -DCB_PRECOMP -Winvalid-pch -fPIC -DPIC -fexceptions -MT annoyingdialog.lo -MD -MP -MF $depbase.Tpo -c -o annoyingdialog.lo annoyingdialog.cpp &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../../src/include -I/mingw64/lib/wx/include/msw-unicode-3.1 -I/mingw64/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMSW__ -I../../src/include -I../../src/sdk/wxscintilla/include -I../../src/include/tinyxml -I../../src/include/scripting/include -I../../src/include/scripting/bindings -I../../src/include/scripting/sqplus -I../../src/include/mozilla_chardet -I../../src/include/mozilla_chardet/mfbt -I../../src/include/mozilla_chardet/nsprpub/pr/include -I../../src/include/mozilla_chardet/xpcom -I../../src/include/mozilla_chardet/xpcom/base -I../../src/include/mozilla_chardet/xpcom/glue -ansi -DTIXML_USE_STL -O2 -ffast-math -DCB_AUTOCONF -g -O2 -DCB_PRECOMP -Winvalid-pch -fPIC -DPIC -fexceptions -MT annoyingdialog.lo -MD -MP -MF .deps/annoyingdialog.Tpo -c annoyingdialog.cpp  -DDLL_EXPORT -DPIC -o .libs/annoyingdialog.o
annoyingdialog.cpp:1:0: warning: -fPIC ignored for target (all code is position independent)
 /*
 ^
 
 
 
annoyingdialog.cpp:10:25: warning: ../../src/include/sdk_precomp.h.gch: not used because `DLL_EXPORT' is defined [-Winvalid-pch]
In file included from C:/tools/msys2/mingw64/include/wx-3.1/wx/window.h:18:0,
                 from C:/tools/msys2/mingw64/include/wx-3.1/wx/msw/private.h:26,
                 from C:/tools/msys2/mingw64/include/wx-3.1/wx/wxprec.h:33,
                 from ../../src/include/sdk_common.h:37,
                 from ../../src/include/sdk_precomp.h:13,
                 from annoyingdialog.cpp:10:
C:/tools/msys2/mingw64/include/wx-3.1/wx/event.h:3983:34: warning: 'AnnoyingDialog::sm_eventTable' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
     const wxEventTable theClass::sm_eventTable = \
                                  ^
C:/tools/msys2/mingw64/include/wx-3.1/wx/event.h:4397:56: note: in expansion of macro 'wxBEGIN_EVENT_TABLE'
 #define BEGIN_EVENT_TABLE(a,b)                         wxBEGIN_EVENT_TABLE(a,b)
                                                        ^
annoyingdialog.cpp:26:1: note: in expansion of macro 'BEGIN_EVENT_TABLE'
 BEGIN_EVENT_TABLE(AnnoyingDialog, wxScrollingDialog)
 ^
annoyingdialog.cpp:26:19: warning: 'virtual const wxEventTable* AnnoyingDialog::GetEventTable() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
 BEGIN_EVENT_TABLE(AnnoyingDialog, wxScrollingDialog)
                   ^
   
   
<<                                                                                  >>
<< loads of warnings about deprecated virtual void functions >>
<<                                                                                             >>
   
   
   ^
In file included from C:/tools/msys2/mingw64/include/wx-3.1/wx/window.h:18:0,
                 from C:/tools/msys2/mingw64/include/wx-3.1/wx/msw/private.h:26,
                 from C:/tools/msys2/mingw64/include/wx-3.1/wx/wxprec.h:33,
                 from ../../src/include/sdk_common.h:37,
                 from ../../src/include/sdk_precomp.h:13,
                 from annoyingdialog.cpp:10:
annoyingdialog.cpp: In member function 'virtual const wxEventTable* AnnoyingDialog::GetEventTable() const':
annoyingdialog.cpp:26:19: error: definition of static data member 'AnnoyingDialog::sm_eventTable' of dllimport'd class
 BEGIN_EVENT_TABLE(AnnoyingDialog, wxScrollingDialog)
                   ^
C:/tools/msys2/mingw64/include/wx-3.1/wx/event.h:3983:24: note: in definition of macro 'wxBEGIN_EVENT_TABLE'
     const wxEventTable theClass::sm_eventTable = \
                        ^
annoyingdialog.cpp:26:1: note: in expansion of macro 'BEGIN_EVENT_TABLE'
 BEGIN_EVENT_TABLE(AnnoyingDialog, wxScrollingDialog)
 ^
annoyingdialog.cpp: In member function 'virtual wxEventHashTable& AnnoyingDialog::GetEventHashTable() const':
annoyingdialog.cpp:26:19: error: definition of static data member 'AnnoyingDialog::sm_eventHashTable' of dllimport'd class
 BEGIN_EVENT_TABLE(AnnoyingDialog, wxScrollingDialog)
                   ^
C:/tools/msys2/mingw64/include/wx-3.1/wx/event.h:3987:22: note: in definition of macro 'wxBEGIN_EVENT_TABLE'
     wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \
                      ^
annoyingdialog.cpp:26:1: note: in expansion of macro 'BEGIN_EVENT_TABLE'
 BEGIN_EVENT_TABLE(AnnoyingDialog, wxScrollingDialog)
 ^
Makefile:948: recipe for target 'annoyingdialog.lo' failed
make[3]: *** [annoyingdialog.lo] Error 1
make[3]: Leaving directory '/home/amwink/codeblocks-dev/src/sdk'
Makefile:969: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/amwink/codeblocks-dev/src/sdk'
Makefile:455: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/amwink/codeblocks-dev/src'
Makefile:495: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
« Last Edit: August 19, 2015, 04:46:35 pm by alle_meije »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6996
    • My Best Post
Re: Compiling C::B using Msys2
« Reply #1 on: August 19, 2015, 02:50:22 pm »
I know you need to build wxWidgets 3.1.x using configure option "--enable-compat28" for Code::Blocks to have a chance of compiling without error.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline alle_meije

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: Compiling C::B using Msys2
« Reply #2 on: August 19, 2015, 03:44:10 pm »
Ah, I did not know that option, many thanks! re-compiling wxWidgets as we speak.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5242
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Compiling C::B using Msys2
« Reply #3 on: August 19, 2015, 04:13:47 pm »
@alle_meije
Please use the code tag or quote tag to wrap you log messages.
For some reason the C::B binaries often crash on my Win7 laptop.
For development on this laptop I use a combination of C::B and Msys2
(https://sourceforge.net/p/msys2/wiki/MSYS2 installation)
...
I don't think build C::B under msys2 can solve your issue. Why not directly build c::b under mingw, and use gdb to debug the crash issue?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline alle_meije

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: Compiling C::B using Msys2
« Reply #4 on: August 19, 2015, 04:44:41 pm »
That's basically what I'm doing in Msys2:

Code: [Select]
$ gcc -v
Using built-in specs.
COLLECT_GCC=C:\tools\msys2\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/tools/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-5.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --with-gxx-include-dir=/mingw64/include/c++/5.2.0 --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=http://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 5.2.0 (Rev3, Built by MSYS2 project)

$ gdb -v
GNU gdb (GDB) 7.9.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".

Offline alle_meije

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: Compiling C::B using Msys2
« Reply #5 on: August 19, 2015, 04:51:59 pm »
Just to report, configuring wxWidgets with
Code: [Select]
--prefix=/mingw64 --enable-compat28 before building did not solve the issue. The build of C::B stops with the same error at the same line.

I'm not sure if the problem is with how wxWidgets was coded / built or C::B?
« Last Edit: August 19, 2015, 04:55:58 pm by alle_meije »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6996
    • My Best Post
Re: Compiling C::B using Msys2
« Reply #6 on: August 19, 2015, 05:30:49 pm »
Just to report, configuring wxWidgets with
Code: [Select]
--prefix=/mingw64 --enable-compat28 before building did not solve the issue. The build of C::B stops with the same error at the same line.

I'm not sure if the problem is with how wxWidgets was coded / built or C::B?

I will try doing this in a week or so.
If in two weeks, I have NOT posted please reply to this post to remind me.

Tim S.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline alle_meije

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: Compiling C::B using Msys2
« Reply #7 on: August 19, 2015, 05:38:08 pm »
Many thanks for that!

In the meantime I am compiling wxWidgets with more options for 'configure':
Code: [Select]
--enable-shared --enable-unicode --enable-opengl --enable-monolithicOptions that are set via a Makefile.gcc in the Windows compilation guide of C::B -- I only have 'configure' though.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6996
    • My Best Post
Re: Compiling C::B using Msys2
« Reply #8 on: August 19, 2015, 05:44:04 pm »
Many thanks for that!

In the meantime I am compiling wxWidgets with more options for 'configure':
Code: [Select]
--enable-shared --enable-unicode --enable-opengl --enable-monolithicOptions that are set via a Makefile.gcc in the Windows compilation guide of C::B -- I only have 'configure' though.

These options are almost positively required
Code: [Select]
--enable-shared --enable-unicode
Note: wxWidgets should default to having "--enable-unicode" as if it was on.

The option "--enable-opengl" is NOT required; but, a very good idea.

No idea on whether "--enable-monolithic" is required; but, I would guess it is NOT required and wxWidgets master tends to be broken from time to time on using that option.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6996
    • My Best Post
Re: Compiling C::B using Msys2
« Reply #9 on: August 19, 2015, 07:43:10 pm »
FYI:

I would guess wxWidgets master is less stable than wxWidgets 3.0.2

But, WX_3_0_BRANCH is likely to be more stable than wxWidgets 3.0.2.

https://github.com/wxWidgets/wxWidgets/archive/WX_3_0_BRANCH.zip

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline alle_meije

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: Compiling C::B using Msys2
« Reply #10 on: August 20, 2015, 10:36:23 am »
I use the '--enable-monolithic' option because on the install-from-source-in-windows page http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Windows it suggests that you set MONOLITHIC=1 in the file Makefile.gcc --which does not seem to be in the distribution any more.

All to no avail... Still exits with the static data member error.

In the meantime I'm using http://downloads.sourceforge.net/project/codeblocks/Binaries/Nightlies/2015/CB_20150604_rev10320_win32_setup.zip and save often (-:

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6996
    • My Best Post
Re: Compiling C::B using Msys2
« Reply #11 on: August 22, 2015, 04:10:54 am »

Is this something that should be set explicitly when (in Windows) it's not possible to use C::B to build C::B?


Yes, you can use CB to build CB in both Windows and Linux.

Edit: The only thing I remember that needs set is the CB Global variable of "cb_release_type" needs set to "-g" or " " (single space) without the double quotes.

Tim S.
« Last Edit: August 23, 2015, 03:43:58 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6996
    • My Best Post
Re: Compiling C::B using Msys2
« Reply #12 on: August 23, 2015, 03:39:00 pm »
I was able to duplicate the error using wxWidgets 3.0 branch and MSys2.

This likely means that there is a problem using MSys2 and Code::Blocks configure/make method of building Code::Blocks.
I might try to find the cause of the problem in the future.

Future problems, I saw during attempt.
  The use of option "-ansi" will cause a windows build to fail once it gets far enough.

Note: I did see a patch in the past to patch the configure/make for Windows (it was before MSys2 likely existed)

The method of Building on Windows has always been using the CB Project file instead of configure/make.
Therefore, it is NOT worth reporting this as a official bug; but, is worth reporting a patch to fix the issue.
I do NOT know enough about the CB configure/make build system to attempt a patch at this time.

There was a CB thread on using Cygwin to build CB using configure/make.
I posted in it; it might have info useful for trying to build under MSys2.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline alle_meije

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: Compiling C::B using Msys2
« Reply #13 on: August 24, 2015, 03:04:46 pm »
Many thanks for the effort! I do much appreciate it.

If I can help in any way to make this work then I'm nore than happy to.

It did not seem to me like a (coding) bug -- most likely a difference in how to fit into the host system.
As mentioned before, Msys2 is a bit of both in that respect. Windows binaries in a Linux-style shell.

My secret hope was that if C::B can be built using regular make, aclocal etc then it can become an Msys2 package
(Msys2 uses the 'arch' linux package management system, which is easier than a windows installer or Chocolatey)

For developing C::B itself, using an already-existing existing copy seems logical, but in Msys2 there is no such copy.

I will read the cygwin thread, thanks!
That would be this one?
http://forums.codeblocks.org/index.php/topic,18525.0.html
The OP also has problems with importdll.
« Last Edit: August 25, 2015, 10:44:48 am by alle_meije »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6996
    • My Best Post
Re: Compiling C::B using Msys2
« Reply #14 on: August 24, 2015, 08:14:50 pm »
I will read the cygwin thread, thanks!
That would be this one?
http://forums.codeblocks.org/index.php/topic,18525.0.html
The OP also has problems with importdll.

Yes that was the thread.

I think a build under cygwin might be a way to boot-strap an CB that works under MSys2; but, this is just a guess.
The clearly better way for CB is for the configure make to work under MSys2.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org