Author Topic: Build C::B against wx3.02 with gcc 5.2 under Windows  (Read 84610 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #60 on: October 07, 2015, 10:40:55 pm »
FYI: In Windows MinGW GCC a PCH only works inside of a real source file (headers files do NOT count).
In other words, a header can never include a real PCH file.

Edit: If on the command line you include a real PCH file like doing [-incude "sdk.h"] you will get a error normally if a header file in the project also includes that same PCH header of  "sdk.h"; it a weird error message that I forgot what it says.
I didn't see the weird error till now.  :)

Quote
Edit2: You will have to put guards around the includes inside some source files around includes of the PCH; never tried the guards around the includes in header files since they needed to be removed I just removed them. 
Tim S.
As I said, the modified "sdk.h" I use was like below:
Code
#ifndef SDK_H
#define SDK_H
#include "sdk_precomp.h"
#endif // SDK_H
Do you mean, I should wrote something like:
Code
#ifndef SDK_H
#define SDK_H
#ifndef SDK_PRECOMP_H
#include "sdk_precomp.h"
#endif
#endif // SDK_H

Ideally, if we share a single pch file for all dlls and exes, we need only one header file(which is included in source files for all sdk, dll targets), such as "sdk.h", "sdk_precomp.h" is not needed here.
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 stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #61 on: October 08, 2015, 02:41:34 pm »
FYI: In Windows MinGW GCC a PCH only works inside of a real source file (headers files do NOT count).
In other words, a header can never include a real PCH file.

Edit: If on the command line you include a real PCH file like doing [-incude "sdk.h"] you will get a error normally if a header file in the project also includes that same PCH header of  "sdk.h"; it a weird error message that I forgot what it says.
I didn't see the weird error till now.  :)

Quote
Edit2: You will have to put guards around the includes inside some source files around includes of the PCH; never tried the guards around the includes in header files since they needed to be removed I just removed them. 
Tim S.
As I said, the modified "sdk.h" I use was like below:
Code
#ifndef SDK_H
#define SDK_H
#include "sdk_precomp.h"
#endif // SDK_H
Do you mean, I should wrote something like:
Code
#ifndef SDK_H
#define SDK_H
#ifndef SDK_PRECOMP_H
#include "sdk_precomp.h"
#endif
#endif // SDK_H

Ideally, if we share a single pch file for all dlls and exes, we need only one header file(which is included in source files for all sdk, dll targets), such as "sdk.h", "sdk_precomp.h" is not needed here.

I mean you have to put guards in every source file the includes the "sdk.h" (if that is the PCH file) and you are including it on the command line using [-include "sdk.h"]. Or you can removed every include of the PCH file from inside the source files and header files.

Edit: As I have already mentioned; but, it appears you missed it. Using [-include "sdk.h"] when sdk.h is NOT a PCH file is a waste of time because if it is NOT a PCH file it will compile slower that if it was NOT used as an option.

Tim S.
« Last Edit: October 08, 2015, 02:44:42 pm by stahta01 »
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #62 on: October 08, 2015, 04:46:05 pm »
Hi, Tim, I am using "-include "sdk_precomp.h"", not using "-include "sdk.h"", since I have only one pch file named "sdk_precomp.h.gch".
Sent from my phone.(sorry I cannot enter too much words)
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 stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #63 on: October 08, 2015, 07:51:00 pm »
Hi, Tim, I am using "-include "sdk_precomp.h"", not using "-include "sdk.h"", since I have only one pch file named "sdk_precomp.h.gch".
Sent from my phone.(sorry I cannot enter too much words)

Good, that means you will only need to fix the code in the SDK folders instead of all the plugins.
I might try doing the same and see what errors I get when I have the time and energy.

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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #64 on: October 09, 2015, 06:11:56 am »
Hi, Tim, I am using "-include "sdk_precomp.h"", not using "-include "sdk.h"", since I have only one pch file named "sdk_precomp.h.gch".
Sent from my phone.(sorry I cannot enter too much words)

Good, that means you will only need to fix the code in the SDK folders instead of all the plugins.
I might try doing the same and see what errors I get when I have the time and energy.

Tim S.

Glad to hear, and this is the patch I made to use single PCH files. Please note that if you use a release version of wxWidgets 3, you do not need to change the Variable WX_SUFFIX from u to ud.

Code
 src/CodeBlocks_wx30.cbp | 83 +++++++++++++++++++++++++++++++++++++++----------
 src/include/sdk.h       |  8 ++---
 2 files changed, 70 insertions(+), 21 deletions(-)

diff --git a/src/CodeBlocks_wx30.cbp b/src/CodeBlocks_wx30.cbp
index 3f63122..ac09ab1 100644
--- a/src/CodeBlocks_wx30.cbp
+++ b/src/CodeBlocks_wx30.cbp
@@ -168,7 +168,10 @@
  <Option parameters="--debug-log --no-dde --no-check-associations --multiple-instance --no-splash-screen --verbose -p debug" />
  <Option projectLinkerOptionsRelation="2" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add directory="include" />
  <Add directory="include/scripting/include" />
  <Add directory="include/scripting/sqplus" />
@@ -226,7 +229,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add directory="include" />
  <Add directory="include/scripting/include" />
  <Add directory="include/scripting/sqplus" />
@@ -260,7 +266,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add option="-DASTYLE_LIB" />
  <Add directory="include" />
  <Add directory="plugins/astyle/astyle" />
@@ -293,7 +302,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add directory="include" />
  </Compiler>
  <Linker>
@@ -338,7 +350,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add directory="include" />
  <Add directory="plugins/compilergcc/depslib/src" />
  <Add directory="include/scripting/include" />
@@ -377,7 +392,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add directory="include" />
  <Add directory="include/scripting/include" />
  <Add directory="include/scripting/sqplus" />
@@ -410,7 +428,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add option="-DCC_NO_COLLAPSE_ITEM" />
  <Add directory="include" />
  <Add directory="include/mozilla_chardet" />
@@ -448,7 +469,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add directory="include" />
  </Compiler>
  <Linker>
@@ -479,7 +503,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add directory="include" />
  </Compiler>
  <Linker>
@@ -510,7 +537,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add directory="include" />
  </Compiler>
  <Linker>
@@ -541,7 +571,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add directory="include" />
  </Compiler>
  <Linker>
@@ -572,7 +605,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add directory="include" />
  <Add directory="include/mozilla_chardet" />
  <Add directory="include/mozilla_chardet/mfbt" />
@@ -609,7 +645,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add directory="include" />
  <Add directory="include/scripting/include" />
  <Add directory="include/scripting/sqplus" />
@@ -642,7 +681,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add directory="include" />
  <Add directory="include/mozilla_chardet" />
  <Add directory="include/mozilla_chardet/mfbt" />
@@ -679,7 +721,10 @@
  <Option run_host_application_in_terminal="0" />
  <Option projectLinkerOptionsRelation="1" />
  <Compiler>
- <Add option="-DBUILDING_PLUGIN" />
+ <Add option='-include &quot;sdk_precomp.h&quot;' />
+ <Add option="-DEXPORT_LIB" />
+ <Add option="-DEXPORT_EVENTS" />
+ <Add option="-DWXMAKINGDLL_SCI" />
  <Add directory="include" />
  </Compiler>
  <Linker>
@@ -700,7 +745,7 @@
  </Target>
  <Environment>
  <Variable name="WX_CFG" value="" />
- <Variable name="WX_SUFFIX" value="u" />
+ <Variable name="WX_SUFFIX" value="ud" />
  <Variable name="WX_VERSION" value="30" />
  </Environment>
  </Build>
@@ -716,11 +761,14 @@
  <Add option="-mthreads" />
  <Add option="-fmessage-length=0" />
  <Add option="-fexceptions" />
+ <Add option="-Winvalid-pch" />
+ <Add option="-Wno-deprecated-declarations" />
  <Add option="-DHAVE_W32API_H" />
  <Add option="-D__WXMSW__" />
  <Add option="-DWXUSINGDLL" />
  <Add option="-DcbDEBUG" />
- <Add option="-DNOPCH" />
+ <Add option="-DCB_PRECOMP" />
+ <Add option="-DWX_PRECOMP" />
  <Add option="-DwxUSE_UNICODE" />
  <Add directory="$(#WX30.include)" />
  <Add directory="$(#WX30.lib)/gcc_dll$(WX_CFG)/msw$(WX_SUFFIX)" />
@@ -1272,6 +1320,7 @@
  <Option target="sdk" />
  </Unit>
  <Unit filename="include/sdk_precomp.h">
+ <Option compile="1" />
  <Option weight="0" />
  <Option target="sdk" />
  </Unit>
diff --git a/src/include/sdk.h b/src/include/sdk.h
index 46361c7..bfff9f6 100644
--- a/src/include/sdk.h
+++ b/src/include/sdk.h
@@ -10,11 +10,11 @@
 #ifndef SDK_H
 #define SDK_H
 
-#ifdef __WXMSW__
- #include "sdk_common.h"
-#else
+//#ifdef __WXMSW__
+// #include "sdk_common.h"
+//#else
  // for non-windows platforms, one PCH is enough
  #include "sdk_precomp.h"
-#endif
+//#endif
 
 #endif // SDK_H

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 stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #65 on: October 11, 2015, 06:09:15 pm »
I am NOT going to use your patch; because the CBP changes is too complex for what I think you are trying to do.

I think the use of "-Wl,--export-all-symbols" is a bad idea; but, it does have tradeoffs that are worth trying.
So, I am going to make a patch that does what I think you wish to do; and you can look at it and test it.

The bad effects that I think go along with using "-Wl,--export-all-symbols" are:
1. It can increase code coupling by accident. It can result is code you wish to be private/protected being more exposed.
2. It increases the size of the DLL file.
3. It likely results in greater ABI changes than are needed.

The good effect
1. It can make it simpler to make windows DLL.

Tim S.
« Last Edit: October 11, 2015, 06:23:22 pm by stahta01 »
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #66 on: October 12, 2015, 06:35:31 am »
I am NOT going to use your patch; because the CBP changes is too complex for what I think you are trying to do.

I think the use of "-Wl,--export-all-symbols" is a bad idea; but, it does have tradeoffs that are worth trying.
So, I am going to make a patch that does what I think you wish to do; and you can look at it and test it.

The bad effects that I think go along with using "-Wl,--export-all-symbols" are:
1. It can increase code coupling by accident. It can result is code you wish to be private/protected being more exposed.
2. It increases the size of the DLL file.
3. It likely results in greater ABI changes than are needed.

The good effect
1. It can make it simpler to make windows DLL.

Tim S.
Yes, I agree, if all the symbols which need to be exported are marked as "__declspec(dllexport)", we can safely remove the "-Wl,--export-all-symbols" linker option.

BTW: with my patch, I see the built exe and plugin dlls are slightly a little bigger, because I see more functions were in their exported symbol.

I'm looking forward to see your patch.  :)
« Last Edit: October 12, 2015, 06:38:06 am by ollydbg »
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #67 on: October 12, 2015, 04:49:34 pm »
I just did some test, if I remove the "-Wl,--export-all-symbols" option in the SDK target, after build the codeblocks.dll, I try to build the src target, but I get a lot of link errors, it looks like there are many classes which need to add "__declspec(dllexport)" decoration.
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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #68 on: October 12, 2015, 08:57:55 pm »
What are the link errors and why does it work with 2.8?
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #69 on: October 13, 2015, 01:24:47 am »
What are the link errors and why does it work with 2.8?
1, undefined reference to some symbol name.
2, codeblocks.cbp ( for wx2.8 ) has the same "-Wl,--export-all-symbols" in its sdk target.

EDIT: my changes:
Code
 src/CodeBlocks_wx30.cbp        | 1 -
 src/include/cbexception.h      | 2 +-
 src/include/cbstyledtextctrl.h | 2 +-
 src/include/editorcolourset.h  | 2 +-
 src/include/filemanager.h      | 4 ++--
 src/include/manager.h          | 2 +-
 src/include/scrollingdialog.h  | 2 +-
 src/include/xtra_res.h         | 4 ++--
 src/sdk/scrollingdialog.cpp    | 3 ++-
 9 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/CodeBlocks_wx30.cbp b/src/CodeBlocks_wx30.cbp
index ac09ab1..5a304dd 100644
--- a/src/CodeBlocks_wx30.cbp
+++ b/src/CodeBlocks_wx30.cbp
@@ -136,7 +136,6 @@
  </Compiler>
  <Linker>
  <Add option="-Wl,--enable-auto-image-base" />
- <Add option="-Wl,--export-all-symbols" />
  <Add option="-Wl,--add-stdcall-alias" />
  <Add option="-Wl,--enable-auto-import" />
  <Add option="-Wl,--no-undefined" />
diff --git a/src/include/cbexception.h b/src/include/cbexception.h
index 2044dd9..bfa91bc 100644
--- a/src/include/cbexception.h
+++ b/src/include/cbexception.h
@@ -20,7 +20,7 @@ cbThrow() and cbAssert().
 */
 
 /** @brief The base Code::Blocks exception object. */
-class cbException
+class DLLIMPORT cbException
 {
     public:
         cbException(const wxString& msg, const wxString& file, int line);
diff --git a/src/include/cbstyledtextctrl.h b/src/include/cbstyledtextctrl.h
index 55835a3..77c3d78 100644
--- a/src/include/cbstyledtextctrl.h
+++ b/src/include/cbstyledtextctrl.h
@@ -17,7 +17,7 @@ class wxFocusEvent;
 class wxMouseEvent;
 class wxPoint;
 
-class cbStyledTextCtrl : public wxScintilla
+class DLLIMPORT cbStyledTextCtrl : public wxScintilla
 {
     public:
         cbStyledTextCtrl(wxWindow* pParent, int id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0);
diff --git a/src/include/editorcolourset.h b/src/include/editorcolourset.h
index a6573bd..e79ddac 100644
--- a/src/include/editorcolourset.h
+++ b/src/include/editorcolourset.h
@@ -73,7 +73,7 @@ struct OptionSet
 };
 WX_DECLARE_STRING_HASH_MAP(OptionSet, OptionSetsMap);
 
-class EditorColourSet
+class DLLIMPORT EditorColourSet
 {
     public:
         EditorColourSet(const wxString& setName = COLORSET_DEFAULT);
diff --git a/src/include/filemanager.h b/src/include/filemanager.h
index 343c087..6d80f04 100644
--- a/src/include/filemanager.h
+++ b/src/include/filemanager.h
@@ -28,7 +28,7 @@ namespace TinyXML{ bool SaveDocument(const wxString&, TiXmlDocument*); }
 
 
 // ***** class: LoaderBase *****
-class LoaderBase : public AbstractJob
+class DLLIMPORT LoaderBase : public AbstractJob
 {
     wxSemaphore sem;
     bool wait;
@@ -109,7 +109,7 @@ public:
 };
 
 // ***** class: FileManager *****
-class FileManager : public Mgr<FileManager>
+class DLLIMPORT FileManager : public Mgr<FileManager>
 {
     BackgroundThread fileLoaderThread;
     BackgroundThread uncLoaderThread;
diff --git a/src/include/manager.h b/src/include/manager.h
index 7dfe827..cd0cb30 100644
--- a/src/include/manager.h
+++ b/src/include/manager.h
@@ -179,7 +179,7 @@ private:
     cbSearchResultsLog *m_SearchResultLog;
 };
 
-template <class MgrT> class Mgr
+template <class MgrT> class DLLIMPORT Mgr
 {
     static MgrT *instance;
     static bool isShutdown;
diff --git a/src/include/scrollingdialog.h b/src/include/scrollingdialog.h
index 33725fe..072d578 100644
--- a/src/include/scrollingdialog.h
+++ b/src/include/scrollingdialog.h
@@ -159,7 +159,7 @@ protected:
  * A class that makes its content scroll if necessary
  */
 
-class wxScrollingDialog: public wxDialog
+class DLLIMPORT wxScrollingDialog: public wxDialog
 #if !wxCHECK_VERSION(2,9,0)
     , public wxDialogHelper
 #endif
diff --git a/src/include/xtra_res.h b/src/include/xtra_res.h
index b8848d5..35494e3 100644
--- a/src/include/xtra_res.h
+++ b/src/include/xtra_res.h
@@ -13,7 +13,7 @@
 
 class wxXmlResourceHandler;
 
-class wxToolBarAddOnXmlHandler : public wxXmlResourceHandler
+class DLLIMPORT wxToolBarAddOnXmlHandler : public wxXmlResourceHandler
 {
     public:
         wxToolBarAddOnXmlHandler();
@@ -30,7 +30,7 @@ class wxToolBarAddOnXmlHandler : public wxXmlResourceHandler
             wxSize size = wxDefaultSize);
 };
 
-class wxScrollingDialogXmlHandler : public wxDialogXmlHandler
+class DLLIMPORT wxScrollingDialogXmlHandler : public wxDialogXmlHandler
 {
     DECLARE_DYNAMIC_CLASS(wxScrollingDialogXmlHandler)
 
diff --git a/src/sdk/scrollingdialog.cpp b/src/sdk/scrollingdialog.cpp
index e847775..cef22e8 100644
--- a/src/sdk/scrollingdialog.cpp
+++ b/src/sdk/scrollingdialog.cpp
@@ -8,8 +8,9 @@
 // Copyright:   (c) Julian Smart
 // Licence:
 /////////////////////////////////////////////////////////////////////////////
+#include "sdk_precomp.h"
+
 
-#include "wx/wx.h"
 #include "wx/module.h"
 #include "wx/display.h"
 #include "wx/bookctrl.h"


But I still see the undefined reference to wxScintilla when building src target
Code
[100.0%] g++.exe -Lbase\tinyxml -LD:\wx3\lib\gcc_dll -Ldevel30 -Lexchndl\win32\lib -o devel30\codeblocks.exe .objs30\src\app.o .objs30\src\appglobals.o .objs30\src\associations.o .objs30\src\backtracedlg.o .objs30\src\breakpointsdlg.o .objs30\src\compilersettingsdlg.o .objs30\src\cpuregistersdlg.o .objs30\src\crashhandler.o .objs30\src\debugger_interface_creator.o .objs30\src\debuggermenu.o .objs30\src\debuggersettingscommonpanel.o .objs30\src\debuggersettingsdlg.o .objs30\src\debuggersettingspanel.o .objs30\src\disassemblydlg.o .objs30\src\dlgabout.o .objs30\src\dlgaboutplugin.o .objs30\src\editkeywordsdlg.o .objs30\src\editorconfigurationdlg.o .objs30\src\environmentsettingsdlg.o .objs30\src\examinememorydlg.o .objs30\src\find_replace.o .objs30\src\infopane.o .objs30\src\main.o .objs30\src\notebookstyles.o .objs30\src\printdlg.o .objs30\src\projectdepsdlg.o .objs30\src\projectmanagerui.o .objs30\src\projectoptionsdlg.o .objs30\src\recentitemslist.o .objs30\src\scriptconsole.o .objs30\src\scriptingsettingsdlg.o .objs30\src\splashscreen.o .objs30\src\startherepage.o .objs30\src\switcherdlg.o .objs30\src\threadsdlg.o .objs30\src\virtualbuildtargetsdlg.o .objs30\src\watchesdlg.o  .objs30\src\resources\resources.res -Wl,--enable-auto-import -Wl,--no-undefined  -lcodeblocks -lexchndl -lshfolder -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lcomctl32 -lodbc32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lwxmsw30ud -mwindows
.objs30\src\crashhandler.o: In function `Z27CrashHandlerSaveEditorFilesR8wxString':
F:\cb_sf_git\trunk\src/src/crashhandler.cpp:62: undefined reference to `wxScintilla::GetText() const'
.objs30\src\debugger_interface_creator.o: In function `ZN21DebugInterfaceFactory16ShowValueTooltipERKNSt3tr110shared_ptrI7cbWatchEERK6wxRect':
F:\cb_sf_git\trunk\src/src/debugger_interface_creator.cpp:216: undefined reference to `wxScintilla::CallTipActive()'
.objs30\src\debuggermenu.o: In function `ZN19DebuggerMenuHandler13OnRunToCursorER14wxCommandEvent':
F:\cb_sf_git\trunk\src/src/debuggermenu.cpp:631: undefined reference to `wxScintilla::GetCurrentLine()'
F:\cb_sf_git\trunk\src/src/debuggermenu.cpp:631: undefined reference to `wxScintilla::GetLine(int) const'
F:\cb_sf_git\trunk\src/src/debuggermenu.cpp:643: undefined reference to `wxScintilla::GetCurrentLine()'
.objs30\src\debuggermenu.o: In function `ZN19DebuggerMenuHandler18OnSetNextStatementER14wxCommandEvent':
F:\cb_sf_git\trunk\src/src/debuggermenu.cpp:655: undefined reference to `wxScintilla::GetCurrentLine()'
.objs30\src\disassemblydlg.o: In function `ZN14DisassemblyDlgC2EP8wxWindow':
F:\cb_sf_git\trunk\src/src/disassemblydlg.cpp:55: undefined reference to `wxSCINameStr'
F:\cb_sf_git\trunk\src/src/disassemblydlg.cpp:55: undefined reference to `wxScintilla::wxScintilla(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&)'
...
« Last Edit: October 13, 2015, 01:39:14 am by ollydbg »
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #70 on: October 13, 2015, 04:14:43 pm »
OK, I find the reason why I get the error: undefined reference to `wxScintilla::xxxxx

This is because the WXEXPORT is defined to empty!

To find this, I use a method to print the value of WXEXPORT(See here: c - How do I show the value of a #define at compile-time? - Stack Overflow)

Then, I just add those code to the end of the file "sdk\cbstyledtextctrl.cpp".
Code
/* definition to expand macro then apply to pragma message */
#define VALUE_TO_STRING(x) #x
#define VALUE(x) VALUE_TO_STRING(x)
#define VAR_NAME_VALUE(var) #var "="  VALUE(var)

/* Some example here */
#ifdef WXEXPORT
    #pragma message(VAR_NAME_VALUE(WXEXPORT))
#else
    #pragma message("WXEXPORT not defined")
#endif

Then I build the SDK target, I see such message:
Code
-------------- Build: sdk in Code::Blocks wx3.0.x (compiler: GNU GCC Compiler)---------------

[ 50.0%] g++.exe -Wall -g -pipe -mthreads -fmessage-length=0 -fexceptions -Winvalid-pch -Wno-deprecated-declarations -DHAVE_W32API_H -D__WXMSW__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE -Woverloaded-virtual -DEXPORT_LIB -DEXPORT_EVENTS -DWXMAKINGDLL_SCI -iquote.objs30\include -I.objs30\include -I. -ID:\wx3\include -ID:\wx3\lib\gcc_dll\mswud -Isdk\wxscintilla\include -Iinclude\tinyxml -Iinclude -Iinclude\tinyxml -Iinclude\scripting\bindings -Iinclude\scripting\include -Iinclude\scripting\sqplus -Iinclude\mozilla_chardet -Iinclude\mozilla_chardet\mfbt -Iinclude\mozilla_chardet\nsprpub\pr\include -Iinclude\mozilla_chardet\xpcom -Iinclude\mozilla_chardet\xpcom\base -Iinclude\mozilla_chardet\xpcom\glue -c sdk\cbstyledtextctrl.cpp -o .objs30\sdk\cbstyledtextctrl.o
sdk\cbstyledtextctrl.cpp:551:45: note: #pragma message: WXEXPORT=
     #pragma message(VAR_NAME_VALUE(WXEXPORT))
                                             ^

Look, the WXEXPORT is defined as empty string.

Now, we have code in "sdk\wxscintilla\include\wx\wxscintilla.h"
Code
#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
...
...
...
class WXDLLIMPEXP_SCI wxScintilla : public wxControl {
public:

#ifdef SWIG
    %pythonAppend wxScintilla   "self._setOORInfo(self)"
    %pythonAppend wxScintilla() ""

    wxScintilla (wxWindow *parent, wxWindowID id=wxID_ANY,
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize, long style = 0,
                 const wxString& name = wxPySCINameStr);
    %RenameCtor(PreScintilla, wxScintilla());

#else
    wxScintilla (wxWindow *parent, wxWindowID id=wxID_ANY,
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize, long style = 0,
                 const wxString& name = wxSCINameStr);
    wxScintilla() { m_swx = NULL; }
    ~wxScintilla();

#endif
...
As we already defined the "WXMAKINGDLL_SCI", but the bad thing is "WXDLLIMPEXP_SCI" now is actually empty. Thus, this class is not exported from the codeblocks.dll.
We need the  "__declspec(dllexport)" decoration here.
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #71 on: October 13, 2015, 04:27:44 pm »
Let's see where the WXEXPORT comes, it is in D:\wx3\include\wx\dlimpexp.h
Code
#if defined(HAVE_VISIBILITY)
#    define WXEXPORT __attribute__ ((visibility("default")))
#    define WXIMPORT __attribute__ ((visibility("default")))
#elif defined(__WINDOWS__)
    /*
       __declspec works in BC++ 5 and later, Watcom C++ 11.0 and later as well
       as VC++.
     */
#    if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
#        define WXEXPORT __declspec(dllexport)
#        define WXIMPORT __declspec(dllimport)
    /*
        While gcc also supports __declspec(dllexport), it creates unusably huge
        DLL files since gcc 4.5 (while taking horribly long amounts of time),
        see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43601. Because of this
        we rely on binutils auto export/import support which seems to work
        quite well for 4.5+.
     */
#    elif defined(__GNUC__) && !wxCHECK_GCC_VERSION(4, 5)
        /*
            __declspec could be used here too but let's use the native
            __attribute__ instead for clarity.
        */
#       define WXEXPORT __attribute__((dllexport))
#       define WXIMPORT __attribute__((dllimport))
#    endif
#elif defined(__WXPM__)
#    if defined (__WATCOMC__)
#        define WXEXPORT __declspec(dllexport)
        /*
           __declspec(dllimport) prepends __imp to imported symbols. We do NOT
           want that!
         */
#        define WXIMPORT
#    elif defined(__EMX__)
#        define WXEXPORT
#        define WXIMPORT
#    elif (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
#        define WXEXPORT _Export
#        define WXIMPORT _Export
#    endif
#elif defined(__CYGWIN__)
#    define WXEXPORT __declspec(dllexport)
#    define WXIMPORT __declspec(dllimport)
#endif

/* for other platforms/compilers we don't anything */
#ifndef WXEXPORT
#    define WXEXPORT
#    define WXIMPORT
#endif
...

Look at the line
Code
elif defined(__GNUC__) && !wxCHECK_GCC_VERSION(4, 5)
I think we get false value here, so the final active preprocessor is:
Code
/* for other platforms/compilers we don't anything */
#ifndef WXEXPORT
#    define WXEXPORT
#    define WXIMPORT
#endif

So, one solution is re-define WXEXPORT in the sdk\cbstyledtextctrl.cpp.
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #72 on: October 13, 2015, 05:08:25 pm »
OK, linking to the wxScintilla issue is solved by the following test patch:
Code
 src/CodeBlocks_wx30.cbp                 |  1 -
 src/include/cbexception.h               |  2 +-
 src/include/cbstyledtextctrl.h          |  2 +-
 src/include/editorcolourset.h           |  2 +-
 src/include/filemanager.h               |  4 ++--
 src/include/manager.h                   |  2 +-
 src/include/scrollingdialog.h           |  2 +-
 src/include/xtra_res.h                  |  4 ++--
 src/sdk/cbstyledtextctrl.cpp            | 25 +++++++++++++++++++++++++
 src/sdk/scrollingdialog.cpp             |  3 ++-
 src/sdk/wxscintilla/src/wxscintilla.cpp | 28 ++++++++++++++++++++++++++++
 11 files changed, 64 insertions(+), 11 deletions(-)

diff --git a/src/CodeBlocks_wx30.cbp b/src/CodeBlocks_wx30.cbp
index ac09ab1..5a304dd 100644
--- a/src/CodeBlocks_wx30.cbp
+++ b/src/CodeBlocks_wx30.cbp
@@ -136,7 +136,6 @@
  </Compiler>
  <Linker>
  <Add option="-Wl,--enable-auto-image-base" />
- <Add option="-Wl,--export-all-symbols" />
  <Add option="-Wl,--add-stdcall-alias" />
  <Add option="-Wl,--enable-auto-import" />
  <Add option="-Wl,--no-undefined" />
diff --git a/src/include/cbexception.h b/src/include/cbexception.h
index 2044dd9..bfa91bc 100644
--- a/src/include/cbexception.h
+++ b/src/include/cbexception.h
@@ -20,7 +20,7 @@ cbThrow() and cbAssert().
 */
 
 /** @brief The base Code::Blocks exception object. */
-class cbException
+class DLLIMPORT cbException
 {
     public:
         cbException(const wxString& msg, const wxString& file, int line);
diff --git a/src/include/cbstyledtextctrl.h b/src/include/cbstyledtextctrl.h
index 55835a3..77c3d78 100644
--- a/src/include/cbstyledtextctrl.h
+++ b/src/include/cbstyledtextctrl.h
@@ -17,7 +17,7 @@ class wxFocusEvent;
 class wxMouseEvent;
 class wxPoint;
 
-class cbStyledTextCtrl : public wxScintilla
+class DLLIMPORT cbStyledTextCtrl : public wxScintilla
 {
     public:
         cbStyledTextCtrl(wxWindow* pParent, int id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0);
diff --git a/src/include/editorcolourset.h b/src/include/editorcolourset.h
index a6573bd..e79ddac 100644
--- a/src/include/editorcolourset.h
+++ b/src/include/editorcolourset.h
@@ -73,7 +73,7 @@ struct OptionSet
 };
 WX_DECLARE_STRING_HASH_MAP(OptionSet, OptionSetsMap);
 
-class EditorColourSet
+class DLLIMPORT EditorColourSet
 {
     public:
         EditorColourSet(const wxString& setName = COLORSET_DEFAULT);
diff --git a/src/include/filemanager.h b/src/include/filemanager.h
index 343c087..6d80f04 100644
--- a/src/include/filemanager.h
+++ b/src/include/filemanager.h
@@ -28,7 +28,7 @@ namespace TinyXML{ bool SaveDocument(const wxString&, TiXmlDocument*); }
 
 
 // ***** class: LoaderBase *****
-class LoaderBase : public AbstractJob
+class DLLIMPORT LoaderBase : public AbstractJob
 {
     wxSemaphore sem;
     bool wait;
@@ -109,7 +109,7 @@ public:
 };
 
 // ***** class: FileManager *****
-class FileManager : public Mgr<FileManager>
+class DLLIMPORT FileManager : public Mgr<FileManager>
 {
     BackgroundThread fileLoaderThread;
     BackgroundThread uncLoaderThread;
diff --git a/src/include/manager.h b/src/include/manager.h
index 7dfe827..cd0cb30 100644
--- a/src/include/manager.h
+++ b/src/include/manager.h
@@ -179,7 +179,7 @@ private:
     cbSearchResultsLog *m_SearchResultLog;
 };
 
-template <class MgrT> class Mgr
+template <class MgrT> class DLLIMPORT Mgr
 {
     static MgrT *instance;
     static bool isShutdown;
diff --git a/src/include/scrollingdialog.h b/src/include/scrollingdialog.h
index 33725fe..072d578 100644
--- a/src/include/scrollingdialog.h
+++ b/src/include/scrollingdialog.h
@@ -159,7 +159,7 @@ protected:
  * A class that makes its content scroll if necessary
  */
 
-class wxScrollingDialog: public wxDialog
+class DLLIMPORT wxScrollingDialog: public wxDialog
 #if !wxCHECK_VERSION(2,9,0)
     , public wxDialogHelper
 #endif
diff --git a/src/include/xtra_res.h b/src/include/xtra_res.h
index b8848d5..35494e3 100644
--- a/src/include/xtra_res.h
+++ b/src/include/xtra_res.h
@@ -13,7 +13,7 @@
 
 class wxXmlResourceHandler;
 
-class wxToolBarAddOnXmlHandler : public wxXmlResourceHandler
+class DLLIMPORT wxToolBarAddOnXmlHandler : public wxXmlResourceHandler
 {
     public:
         wxToolBarAddOnXmlHandler();
@@ -30,7 +30,7 @@ class wxToolBarAddOnXmlHandler : public wxXmlResourceHandler
             wxSize size = wxDefaultSize);
 };
 
-class wxScrollingDialogXmlHandler : public wxDialogXmlHandler
+class DLLIMPORT wxScrollingDialogXmlHandler : public wxDialogXmlHandler
 {
     DECLARE_DYNAMIC_CLASS(wxScrollingDialogXmlHandler)
 
diff --git a/src/sdk/cbstyledtextctrl.cpp b/src/sdk/cbstyledtextctrl.cpp
index 4e3d6c6..dc8d06b 100644
--- a/src/sdk/cbstyledtextctrl.cpp
+++ b/src/sdk/cbstyledtextctrl.cpp
@@ -8,6 +8,16 @@
  */
 
 #include "sdk_precomp.h"
+
+// this workaround an issue that WXEXPORT is defined as empty, so that wxScintilla class is not
+// exported from the codeblocks.dll
+#ifdef __WINDOWS__
+    #ifdef WXEXPORT
+        #undef WXEXPORT
+        #define WXEXPORT __declspec(dllexport)
+    #endif // WXEXPORT
+#endif // __WINDOWS__
+
 #include "cbstyledtextctrl.h"
 #ifndef CB_PRECOMP
     #include <wx/gdicmn.h> // for wxPoint
@@ -539,3 +549,18 @@ void cbStyledTextCtrl::MakeNearbyLinesVisible(int line)
     else if (dist >= LinesOnScreen() - 2)
         LineScroll(0, 3 + dist - LinesOnScreen());
 }
+
+
+/* definition to expand macro then apply to pragma message */
+#define VALUE_TO_STRING(x) #x
+#define VALUE(x) VALUE_TO_STRING(x)
+#define VAR_NAME_VALUE(var) #var "="  VALUE(var)
+
+/* Some example here */
+#ifdef WXEXPORT
+    #pragma message(VAR_NAME_VALUE(WXEXPORT))
+#else
+    #pragma message("WXEXPORT not defined")
+#endif
+
+
diff --git a/src/sdk/scrollingdialog.cpp b/src/sdk/scrollingdialog.cpp
index e847775..cef22e8 100644
--- a/src/sdk/scrollingdialog.cpp
+++ b/src/sdk/scrollingdialog.cpp
@@ -8,8 +8,9 @@
 // Copyright:   (c) Julian Smart
 // Licence:
 /////////////////////////////////////////////////////////////////////////////
+#include "sdk_precomp.h"
+
 
-#include "wx/wx.h"
 #include "wx/module.h"
 #include "wx/display.h"
 #include "wx/bookctrl.h"
diff --git a/src/sdk/wxscintilla/src/wxscintilla.cpp b/src/sdk/wxscintilla/src/wxscintilla.cpp
index ca79dd2..8f033c6 100644
--- a/src/sdk/wxscintilla/src/wxscintilla.cpp
+++ b/src/sdk/wxscintilla/src/wxscintilla.cpp
@@ -45,8 +45,36 @@
 #endif
 
 #include "ScintillaWX.h"
+
+
+// this workaround an issue that WXEXPORT is defined as empty, so that wxScintilla class is not
+// exported from the codeblocks.dll
+#ifdef __WINDOWS__
+    #ifdef WXEXPORT
+        #undef WXEXPORT
+        #define WXEXPORT __declspec(dllexport)
+    #else
+        #define WXEXPORT __declspec(dllexport)
+    #endif // WXEXPORT
+
+#endif // __WINDOWS__
+
+
+
 #include "wx/wxscintilla.h"
 
+/* definition to expand macro then apply to pragma message */
+#define VALUE_TO_STRING(x) #x
+#define VALUE(x) VALUE_TO_STRING(x)
+#define VAR_NAME_VALUE(var) #var "="  VALUE(var)
+
+/* Some example here */
+#ifdef WXEXPORT
+    #pragma message(VAR_NAME_VALUE(WXEXPORT))
+#else
+    #pragma message("WXEXPORT not defined")
+#endif
+
 #ifdef SCI_NAMESPACE
 using namespace Scintilla;
 #endif

It looks like we need to export the functions which are from the static library (libwxscintilla_cb.a), some discussion: Why can't I __declspec(dllexport) a function from a static library? - The Old New Thing - Site Home - MSDN Blogs, my solution is just add __declspec(dllexport) when building the static library.

But I still see other undefined errors.
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #73 on: October 13, 2015, 05:15:08 pm »
The bad thing is, to solve this kind of error, I also need to add export decoration to squirrel library... :(
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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Build C::B against wx3.02 with gcc 5.2 under Windows
« Reply #74 on: October 13, 2015, 08:31:30 pm »
The bad thing is, to solve this kind of error, I also need to add export decoration to squirrel library... :(
What is the error related to squirrel?
(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!]