Author Topic: Compile CodeBlocks by Cygwin  (Read 41182 times)

Offline PetrPetrov

  • Multiple posting newcomer
  • *
  • Posts: 25
Compile CodeBlocks by Cygwin
« on: November 05, 2013, 06:34:00 pm »
I want to build CB in Cygwin environment.

In particular I use latest x86_64 Cygwin.
I installed gcc, g++, make in Cygwin.
Also I installed x11 libraries and installed local X11 server on my Windows host.
So, many GUI X11 programs work fine in my Cygwin environment (like git gui, gitk, text editors etc.)

I want to run in the same manner CB.
First, CB requires wxWidgets.
Cygwin does not have wxWidgets from the box.
I downloaded the latest 2.8.12 version of wxWidgets sources and build it:
./configure --build=x86_64-pc-cygwin --without-msw --without-gtk --with-x11

which means that I want to build wxWidgets by using X11 libraries (instead of MSW by default).
Then I type, "make", "make install".
Here was a small compilation error, I fixed it, and wxWidgets libraries were installed successfully into my Cygwin env.

Second step is to build CB.
I downloaded "codeblocks-12.11release8629" sources.
./configure steps passed fine.

Then I type "make" and give the following error  (not just immediately after start, error becomes after some long time of compilation):

/bin/sh ../../../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I.                                                        ./../../src/include -I/usr/local/lib/wx/include/x11univ-ansi-release-2.8 -I/usr/                                                        local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -DWXUSINGDLL -D__WXUN                                                        IVERSAL__ -D__WXX11__  -I./include -I./src/scintilla/include -I./src/scintilla/l                                                        exlib -I./src/scintilla/src -DSCI_LEXER -DLINK_LEXERS -DGTK -D__WX__ -Ulinux -Uu                                                        nix  -O2 -ffast-math -DCB_AUTOCONF  -DCB_PRECOMP -Winvalid-pch -fPIC -DPIC -fexc                                                        eptions -w -MT wxscintilla.lo -MD -MP -MF .deps/wxscintilla.Tpo -c -o wxscintill                                                        a.lo `test -f 'src/wxscintilla.cpp' || echo './'`src/wxscintilla.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../../../src/include -I/usr/local/l                                                        ib/wx/include/x11univ-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSE                                                        T_BITS=64 -D_LARGE_FILES -DWXUSINGDLL -D__WXUNIVERSAL__ -D__WXX11__ -I./include                                                         -I./src/scintilla/include -I./src/scintilla/lexlib -I./src/scintilla/src -DSCI_L                                                        EXER -DLINK_LEXERS -DGTK -D__WX__ -Ulinux -Uunix -O2 -ffast-math -DCB_AUTOCONF -                                                        DCB_PRECOMP -Winvalid-pch -fPIC -DPIC -fexceptions -w -MT wxscintilla.lo -MD -MP                                                         -MF .deps/wxscintilla.Tpo -c src/wxscintilla.cpp  -DDLL_EXPORT -DPIC -o .libs/w                                                        xscintilla.o
In file included from /usr/local/include/wx-2.8/wx/window.h:1537:0,
                 from /usr/local/include/wx-2.8/wx/wx.h:36,
                 from src/ScintillaWX.h:51,
                 from src/wxscintilla.cpp:44:
/usr/local/include/wx-2.8/wx/univ/window.h:19:19: note: attribute for 'class wxControlRenderer' must follow the 'class' keyword
 class WXDLLEXPORT wxControlRenderer;
                   ^
In file included from /usr/local/include/wx-2.8/wx/wx.h:25:0,
                 from src/ScintillaWX.h:51,
                 from src/wxscintilla.cpp:44:
src/wxscintilla.cpp:141:19: error: definition of static data member 'wxScintilla::sm_eventTable' of dllimport'd class
 BEGIN_EVENT_TABLE(wxScintilla, wxControl)
                   ^
/usr/local/include/wx-2.8/wx/event.h:2721:24: note: in definition of macro 'BEGIN_EVENT_TABLE'
     const wxEventTable theClass::sm_eventTable = \
                        ^
src/wxscintilla.cpp:141:19: error: definition of static data member 'wxScintilla::sm_eventHashTable' of dllimport'd class
 BEGIN_EVENT_TABLE(wxScintilla, wxControl)
                   ^

Could advise how to fix this compilation error?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Compile CodeBlocks by Cygwin
« Reply #1 on: November 05, 2013, 06:44:15 pm »
./configure --build=x86_64-pc-cygwin --without-msw --without-gtk --with-x11
C::B requires wxGTK and it cannot work with wxX11, sorry.
Also I'm sure you're the first trying to build C::B inside cygwin and also I'm not sure why you want to inflict this pain to yourself:)
(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 PetrPetrov

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Compile CodeBlocks by Cygwin
« Reply #2 on: November 05, 2013, 06:53:01 pm »
Thank you for answer.

I will try to build wxWidgets version which is based on GTK library.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Compile CodeBlocks by Cygwin
« Reply #3 on: November 05, 2013, 07:43:23 pm »
./configure --build=x86_64-pc-cygwin --without-msw --without-gtk --with-x11
C::B requires wxGTK and it cannot work with wxX11, sorry.
Also I'm sure you're the first trying to build C::B inside cygwin and also I'm not sure why you want to inflict this pain to yourself:)

Not the first, I have tried it twice. But, its been about two years since last try.

Tim S.


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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Compile CodeBlocks by Cygwin
« Reply #4 on: November 05, 2013, 08:13:51 pm »
stahta01: Why? What is the benefit of running a cygwin version of 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 PetrPetrov

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Compile CodeBlocks by Cygwin
« Reply #5 on: November 05, 2013, 08:16:59 pm »
Now I have build wxWidgets-2.8.12 by using GTK+ 2.0 library.

Note that I used "all port" source package for wxWidgets (http://prdownloads.sourceforge.net/wxwindows/wxWidgets-2.8.12.tar.gz), wxGTK only had configuration/compilation problem.

I used
./configure --build=x86_64-pc-cygwin --with-gtk --without-msw --without-x11

line to configure wxWdigets.
After this, wxWidgets was build fine and installed successfully.
Note I was need to install additionally 'pkg-config' package for Cygwin, otherwise wxWidget configuration script did not find installed GTK 2.0 development libraries into my Cygwin.

However, I have the same error during compilation of C::B
src/wxscintilla.cpp:169:17: error: definition of static data member 'wxScintilla::ms_classInfo' of dllimport'd class
 IMPLEMENT_CLASS(wxScintilla, wxControl)
src/wxscintilla.cpp:170:25: error: definition of static data member 'wxScintillaEvent::ms_classInfo' of dllimport'd class
 IMPLEMENT_DYNAMIC_CLASS(wxScintillaEvent, wxCommandEvent)



Offline PetrPetrov

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Compile CodeBlocks by Cygwin
« Reply #6 on: November 05, 2013, 08:31:58 pm »
It seems that class that causes problem is wxScintilla.
This class defines some custom wxWidget control which is used insude C::B.

Source file of this class is here:
C:\cygwin64\usr\src\codeblocks-12.11release8629\src\sdk\wxscintilla\src\wxscintilla.cpp
and header file is here:
C:\cygwin64\usr\src\codeblocks-12.11release8629\src\sdk\wxscintilla\include\wx\wxscintilla.h

Code into header file:
class WXDLLIMPEXP_SCI wxScintilla : public wxControl {
public:
..... methods

It seems that wxScintilla or its parent class should define sm_eventTable member and some other members.
Also I see that problem is related to dllimport's class. I guess that wxControl is dll-imported class (this is because it is located into another library - wxWidget).
As workaround I can try to build wxWidget as a static library.

But I guess that problem is in WXMAKINGDLL_SCI macro.

wxscintilla.cpp is being compiled with -DWXUSINGDLL symbol which means to use wxWidget library as a shared library.
Also I see (in begin of wxscintilla.h):
#ifdef WXMAKINGDLL_SCI
    #define WXDLLIMPEXP_SCI WXEXPORT
#elif defined(WXUSINGDLL_SCI) || defined(WXUSINGDLL)
    #define WXDLLIMPEXP_SCI WXIMPORT
#else // not making nor using DLL
    #define WXDLLIMPEXP_SCI
#endif
And in such a case I think that  #define WXDLLIMPEXP_SCI WXIMPORT will be used!

wxscintilla class is part of C::B, not it is not part of wxWidget library, I think.
So, it uses wrong WXDLLIMPEXP_SCI macro.


Offline PetrPetrov

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Compile CodeBlocks by Cygwin
« Reply #7 on: November 05, 2013, 08:43:22 pm »
It seems that I have fixed above compilation error and build is going ahead now...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Compile CodeBlocks by Cygwin
« Reply #8 on: November 05, 2013, 08:46:02 pm »
Patches welcome...
(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 PetrPetrov

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Compile CodeBlocks by Cygwin
« Reply #9 on: November 05, 2013, 08:47:38 pm »
Another compilation error:
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../../src/include -I/usr/local/lib/wx/include/gtk2univ-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -DWXUSINGDLL -D__WXUNIVERSAL__ -D__WXGTK__ -I../../src/include -I../../src/sdk/wxscintilla/include -I../../src/sdk/wxpropgrid/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 -Ulinux -Uunix -O2 -ffast-math -DCB_AUTOCONF -DCB_PRECOMP -Winvalid-pch -fPIC -DPIC -fexceptions -w -MT cbauibook.lo -MD -MP -MF .deps/cbauibook.Tpo -c cbauibook.cpp  -DDLL_EXPORT -DPIC -o .libs/cbauibook.o
In file included from /usr/local/include/wx-2.8/wx/window.h:1537:0,
                 from /usr/local/include/wx-2.8/wx/wx.h:36,
                 from /usr/local/include/wx-2.8/wx/wxprec.h:68,
                 from ../../src/include/sdk_common.h:37,
                 from ../../src/include/sdk_precomp.h:13,
                 from cbauibook.cpp:11:
/usr/local/include/wx-2.8/wx/univ/window.h:19:19: note: attribute for 'class wxControlRenderer' must follow the 'class' keyword
 class WXDLLEXPORT wxControlRenderer;
                   ^
cbauibook.cpp: In member function 'void cbAuiNotebook::OnMotion(wxMouseEvent&)':
cbauibook.cpp:414:39: error: 'class wxAuiTabCtrl' has no member named 'GetToolTip'
         wxToolTip* tooltip = tabCtrl->GetToolTip();
                                       ^
cbauibook.cpp:415:32: error: invalid use of incomplete type 'class wxToolTip'         if (!tooltip || tooltip->GetTip() != text)
                                ^
In file included from /usr/local/include/wx-2.8/wx/wx.h:36:0,
                 from /usr/local/include/wx-2.8/wx/wxprec.h:68,
                 from ../../src/include/sdk_common.h:37,
                 from ../../src/include/sdk_precomp.h:13,
                 from cbauibook.cpp:11:
/usr/local/include/wx-2.8/wx/window.h:65:28: error: forward declaration of 'class wxToolTip' class WXDLLIMPEXP_FWD_CORE wxToolTip;


It seems that C::B tries to use GetToolTip() method which is absent. Missing included header file? Any ideas?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Compile CodeBlocks by Cygwin
« Reply #10 on: November 05, 2013, 09:02:12 pm »
The wx/tooltip.h header is included at the top of the cbauibook.cpp file.

It's most likely a wxWidgets configuration problem.

Configuring and compiling wxWidgets in a way you get all defines correctly is surely a hard way. And without good knowledge of wxWidgets (and surely C::B) it will be really hard and I doubt there will be much help from the community.
Not because nobody wants to help, but because nobody ever did it.

And I personally see no reason not to use a standard windows build.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Compile CodeBlocks by Cygwin
« Reply #11 on: November 05, 2013, 09:21:41 pm »
stahta01: Why? What is the benefit of running a cygwin version of C::B?

When I was doing a lot of CB Patches; I thought building CB under CygWin would mostly test the Linux CB Build stuff.

I was also thinking of making a CB version to do better debugging of programs under CygWin;
that is the only reason I can think of to run a CygWin built CB.

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

Offline PetrPetrov

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Compile CodeBlocks by Cygwin
« Reply #12 on: November 05, 2013, 11:07:48 pm »
It seems that wxWidgets library was configured incorrectly.
I.e. It is required that wxWidgets should be compiled with --enable-tooltips flag.
However, if I set --enable-tooltips option for ./configure script then setup.h will anyway #define wxUSE_TOOLTIPS 0 ,
i.e. something goes wrong.
I manually edited this file after configuration step to enable wxUSE_TOOLTIPS to 1:
C:\cygwin64\usr\src\wxWidgets-2.8.12\lib\wx\include\gtk2univ-ansi-release-static-2.8\wx\setup.h

Also I used static configuration to avoid problem with wxScintilla class.
My full configuration line is:
./configure --build=x86_64-pc-cygwin --without-msw --without-x11 --with-gtk --enable-tooltips --enable-monolithic --enable-dnd --disable-shared --enable-universal

Offline PetrPetrov

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Compile CodeBlocks by Cygwin
« Reply #13 on: November 05, 2013, 11:30:21 pm »
Just have noticed from configure's log:
configure: WARNING: wxTooltip not supported yet in wxUniversal... disabled

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Compile CodeBlocks by Cygwin
« Reply #14 on: November 05, 2013, 11:55:32 pm »
Quote
gtk2univ-ansi-release-static-2.8

I would NOT use Universal.
I might try Unicode instead of ANSI; but, you are likely right in trying ANSI because the last time I tried CygWin did NOT support Unicode.
I would NOT use static because I think CB requires wxWidgets be in a DLL.

Tim S.


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