Author Topic: CodeBlocks Compiling  (Read 1361 times)

Offline gagraceffa

  • Single posting newcomer
  • *
  • Posts: 1
CodeBlocks Compiling
« on: November 27, 2017, 02:02:25 pm »
Hi all
I'm trying to compile the latest release of CodeBlocks on Windows but I get errors in compiling. I want to understand which versions of MinGW, WXwidget and CodeBlocks do I need to successfully compile. The error messages are like the following:

||=== Build: tinyXML in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: AutoRevision in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: ConsoleRunner in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: Squirrel in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: Squirrel std lib in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: SqPlus in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: scintilla in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: wxpropgrid in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: sdk in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: src in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: Abbreviations in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: AStyle in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: Autosave in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: Compiler depslib in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: Compiler in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: Debugger in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
||=== Build: Code-completion in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler) ===|
C:\wxMSW-2.8.12\wxMSW-2.8.12\lib\gcc_dll\mswu\wx\setup.h|207|warning: "wxUSE_STL" redefined|
:0|0|note: this is the location of the previous definition|
C:\wxMSW-2.8.12\wxMSW-2.8.12\include\wx\msw\private.h||In destructor 'ClassRegistrar::~ClassRegistrar()':|
C:\wxMSW-2.8.12\wxMSW-2.8.12\include\wx\msw\private.h|695|error: cannot convert 'wxString' to 'LPCSTR {aka const char*}' for argument '1' to 'BOOL UnregisterClassA(LPCSTR, HINSTANCE)'|
C:\wxMSW-2.8.12\wxMSW-2.8.12\include\wx\msw\private.h||In function 'wxString wxGetFullModuleName(HMODULE)':|
C:\wxMSW-2.8.12\wxMSW-2.8.12\include\wx\msw\private.h|781|error: cannot convert 'wxStringBuffer' to 'LPSTR {aka char*}' for argument '2' to 'DWORD GetModuleFileNameA(HINSTANCE, LPSTR, DWORD)'|
||=== Build failed: 2 error(s), 1 warning(s) (0 minute(s), 18 second(s)) ===|

Many thanks

Giacomo

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6318
    • My Best Post
Re: CodeBlocks Compiling
« Reply #1 on: November 27, 2017, 03:18:46 pm »
If you are trying to build Code::Blocks using wxUSE_STL=1 you are likely going to fail no matter what versions you use.

I would suggest wxWidgets version 3.0.3 and what ever GCC mingw compiler version you wish to try that is at least as new as the GCC compiler that was package with CB 16.01. I think it was GCC 4.9.2 TDM 32 bit.

Note: Most MinGW64 GCC compilers have issues building monolithic wxWidgets (except for TDM builds) needed by the Code::Blocks projects under windows OS.

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 riban

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: CodeBlocks Compiling
« Reply #2 on: January 15, 2018, 11:55:57 am »
I am seeing same results with wxUSE_STL = 0.

I worked around it by changing private.h (just for the offending build targets):

Replace line 680 with:
Code: [Select]
m_clsname = wxString::FromUTF8(wc.lpszClassName);Replace line 695 with:
Code: [Select]
if ( !::UnregisterClass(m_clsname.mb_str(), wxhInstance) )Replace wxGetFullModuleName at line 773 with:
Code: [Select]
inline wxString wxGetFullModuleName(HMODULE hmod)
{
    wxString fullname;
    char cName[MAX_PATH];
    if ( !::GetModuleFileName
            (
                hmod,
                cName,
                MAX_PATH
            ) )
    {
        wxLogLastError(_T("GetModuleFileName"));
    }
    fullname = wxString::FromUTF8(cName);
    return fullname;
}

This was rather irksome but allowed me to build the project. We need to resolve this issue. It only affects some build targets even though others use the same private.h file so these functions do work but maybe some configuration difference between the build targets.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6318
    • My Best Post
Re: CodeBlocks Compiling
« Reply #3 on: January 15, 2018, 05:29:28 pm »
@riban: I suggest you post a build log with the issue.
Post the compiler version info.
Post the wxWidgets version info.
Edit: Post the command used to build wxWidgets or your source of the already built wx library.
Post the Code::Blocks source code version info.

Tim S.
« Last Edit: January 15, 2018, 05:36:27 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: 6318
    • My Best Post
Re: CodeBlocks Compiling
« Reply #4 on: January 15, 2018, 08:52:53 pm »
FYI: If you are trying to build [with] an ANSI instead of an Unicode wxWidgets then state that fact!!

Tim S.
« Last Edit: January 15, 2018, 10:51:32 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 riban

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: CodeBlocks Compiling
« Reply #5 on: January 16, 2018, 01:22:04 pm »
I get this issue if I try to build codeblocks from within codeblocks 17.12 on Windows 7 64-bit using minGW32 gcc.

mingw32-gcc (MinGW.org GCC-6.3.0-1) 6.3.0
wxWidgets 2.8.12 built with:

mingw32-make -f makefile.gcc BUILD=release SHARED=1 UNICODE=1 MONOLITHIC=1

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6318
    • My Best Post
Re: CodeBlocks Compiling
« Reply #6 on: January 16, 2018, 02:04:53 pm »
Note: Most MinGW64 GCC compilers have issues building monolithic wxWidgets (except for TDM builds) needed by the Code::Blocks projects under windows OS.

I will try building monolithic  wxWidgets using GCC (MinGW.org GCC-6.3.0-1) 6.3.0; but, that is a very new compiler to build wxWidgets 2.8.12.
I will be using the newest wxWidgets 2.8.12 in version control. Edit3: It built with MinGW.org GCC-6.3.0-1; found the DLLs forgot I canceled the first build.

It will be a while (as in a few days); and, the end answer will be it is likely an wxWidgets issue.

Tim S.
« Last Edit: January 16, 2018, 07:00:19 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: 6318
    • My Best Post
Re: CodeBlocks Compiling
« Reply #7 on: January 16, 2018, 07:32:50 pm »
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: 6318
    • My Best Post
Re: CodeBlocks Compiling
« Reply #8 on: January 16, 2018, 09:03:32 pm »
Find a possible cause in the Code::Blocks source code.
Edit: The patch below is only a possible work around it is *not* a proper fix.

Code: [Select]
diff --git a/src/plugins/codecompletion/selectincludefile.cpp b/src/plugins/codecompletion/selectincludefile.cpp
index a2f62fbef..10adfac3d 100644
--- a/src/plugins/codecompletion/selectincludefile.cpp
+++ b/src/plugins/codecompletion/selectincludefile.cpp
@@ -7,7 +7,7 @@
  * $HeadURL$
  */

-#include "prep.h"
+#include <sdk.h>
 #include "selectincludefile.h"

 #include <wx/xrc/xmlres.h>

I changed several things at the same time; so, the patch may not be the solution.

Tim S.
« Last Edit: January 16, 2018, 09:54:57 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: 6318
    • My Best Post
Re: CodeBlocks Compiling
« Reply #9 on: January 17, 2018, 01:57:02 am »
Link to PCH patch that should fix your issues building with mingw.org 6.3.0 and wxWidgets 2.8.12
https://sourceforge.net/p/codeblocks/tickets/601/
Edit: https://sourceforge.net/p/codeblocks/tickets/604/

Tim S.
« Last Edit: January 18, 2018, 12:24:58 am 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 riban

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: CodeBlocks Compiling
« Reply #10 on: January 17, 2018, 12:13:08 pm »
I confirm that the patch provided by stahta01 resolves the build issue with minGW32. I had separately discovered that removing precompiled header definitions helped.

I have found similar issue with the following plugins that may be worked-around by removing WX_PRECOMP and CB_PRECOMP from the defines
  • wxSmith - Contrib Items
  • AutoVersioning
  • Games
  • Code Snippets wx2.8.x
  • SpellChecker wx2.8.x
Should these plugin failures be reported separately or managed within this ticket?

FYI The installation of minGW32 on my Windows 7 Professional machine reports WINVER=0x0500 and _WIN32_WINNT=0x0500 which causes the build to fail due to various dependencies on >=0x0501. I resolved this by adding
Code: [Select]
WINVER=0x0601
_WIN32_WINNT=0x0601
to defines of the project. I will report this separately.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6318
    • My Best Post
Re: CodeBlocks Compiling
« Reply #11 on: January 17, 2018, 12:32:34 pm »
When I have time, I will create a separate patch for each plugin.

I suggest you report all of the problem plugins in one report on sf.net.

I will the reference your report of bug in my patch files.

edit: I am testing with these compiler defines; these defines should be added to the compiler; I consider this a mingw.org compiler bug/WAD.
WAD = works as designed. I may need to up WINVER to match your value later in testing.
Code: [Select]
WINVER=0x0501
_WIN32_IE=0x0601

Tim S.
« Last Edit: January 17, 2018, 12:37:36 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: 6318
    • My Best Post
Re: CodeBlocks Compiling
« Reply #12 on: January 17, 2018, 01:49:11 pm »
Partial build log showing error; before I try to fix it. The build log was too long so edited it down.
Code: [Select]
-------------- Build: default in AutoVersioning (compiler: GNU GCC 6.3.0 mingw.org Compiler)---------------

mingw32-g++.exe -Wall -g -std=gnu++11 -g -pipe -mthreads -fmessage-length=0 -fexceptions -Winvalid-pch -DBUILDING_PLUGIN -DHAVE_W32API_H -D__WXMSW__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE -DWINVER=0x0501 -D_WIN32_IE=0x0601 -I..\..\..\include -I..\..\..\include\tinyxml -I..\..\..\sdk\wxscintilla\include -IC:\Users\stahta01\devel\open_source_code\version_control\git_repos\wxWidgets_2_8_branch\include -IC:\Users\stahta01\devel\open_source_code\version_control\git_repos\wxWidgets_2_8_branch\lib\gcc_dll\mswu -c C:\Users\stahta01\devel\open_source_code\version_control\git_repos\codeblocks_PCH_fixes\src\plugins\contrib\AutoVersioning\AutoVersioning.cpp -o ..\..\..\.objs\plugins\contrib\AutoVersioning\AutoVersioning.o

SNIP

C:\Users\stahta01\devel\open_source_code\version_control\git_repos\wxWidgets_2_8_branch\include/wx/msw/private.h:680:28: error: ambiguous overload for 'operator=' (operand types are 'wxString' and 'const LPCSTR {aka const char* const}')
             m_clsname = wc.lpszClassName;
                            ^~~~~~~~~~~~~
« Last Edit: January 18, 2018, 12:39:15 am 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