Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Build C::B against wx3.02 with gcc 5.2 under Windows
ollydbg:
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
--- End code ---
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))
^
--- End code ---
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
...
--- End code ---
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.
ollydbg:
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
...
--- End code ---
Look at the line
--- Code: ---elif defined(__GNUC__) && !wxCHECK_GCC_VERSION(4, 5)
--- End code ---
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
--- End code ---
So, one solution is re-define WXEXPORT in the sdk\cbstyledtextctrl.cpp.
ollydbg:
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
--- End code ---
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.
ollydbg:
The bad thing is, to solve this kind of error, I also need to add export decoration to squirrel library... :(
oBFusCATed:
--- Quote from: ollydbg 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... :(
--- End quote ---
What is the error related to squirrel?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version