Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Build C::B against wx3.02 with gcc 5.2 under Windows
ollydbg:
It looks like the wxWidgets dll we build by the command like "mingw32-make ....", which does not have dllexport decortation enabled. See "D:\wx3\include\wx\dlimpexp.h", this means the mingw's linker option: "-export-all-symbols" is enabled by default.
I have manfully add DLLIMPORT to many sdk's headers, and currently, sdk and src, some plugins are build fine. (in this case, need to use the "-export-all-symbols" when building sdk)
But I see one error when building compiler plugin:
--- Code: ----------------- Build: Compiler in Code::Blocks wx3.0.x (compiler: GNU GCC Compiler)---------------
[100.0%] g++.exe -shared -Wl,--dll -Lbase\tinyxml -LD:\wx3\lib\gcc_dll -Ldevel30 -Lplugins\compilergcc\depslib .objs30\plugins\compilergcc\advancedcompileroptionsdlg.o .objs30\plugins\compilergcc\compiler_defs.o .objs30\plugins\compilergcc\compilerCYGWIN.o .objs30\plugins\compilergcc\compilererrors.o .objs30\plugins\compilergcc\compilerflagdlg.o .objs30\plugins\compilergcc\compilerG95.o .objs30\plugins\compilergcc\compilergcc.o .objs30\plugins\compilergcc\compilerGDC.o .objs30\plugins\compilergcc\compilerGNUARM.o .objs30\plugins\compilergcc\compilerGNUFortran.o .objs30\plugins\compilergcc\compilerIAR.o .objs30\plugins\compilergcc\compilerICC.o .objs30\plugins\compilergcc\compilerKeilC51.o .objs30\plugins\compilergcc\compilerLCC.o .objs30\plugins\compilergcc\compilermessages.o .objs30\plugins\compilergcc\compilerMINGW.o .objs30\plugins\compilergcc\compilerMINGWgenerator.o .objs30\plugins\compilergcc\compilerMSVC.o .objs30\plugins\compilergcc\compilerMSVC10.o .objs30\plugins\compilergcc\compilerMSVC8.o .objs30\plugins\compilergcc\compileroptionsdlg.o .objs30\plugins\compilergcc\compilerOW.o .objs30\plugins\compilergcc\compilerOWgenerator.o .objs30\plugins\compilergcc\compilerXML.o .objs30\plugins\compilergcc\directcommands.o -o devel30\share\CodeBlocks\plugins\compiler.dll -Wl,--enable-auto-image-base -Wl,--add-stdcall-alias -Wl,--enable-auto-import -Wl,--no-undefined -mthreads -lcodeblocks -lwxmsw30ud -ldepslib
.objs30\plugins\compilergcc\advancedcompileroptionsdlg.o: In function `ZN26AdvancedCompilerOptionsDlgC2EP8wxWindowRK8wxString':
F:\cb_sf_git\trunk\src/plugins/compilergcc/advancedcompileroptionsdlg.cpp:72: undefined reference to `RegExArray::~RegExArray()'
.objs30\plugins\compilergcc\advancedcompileroptionsdlg.o: In function `ZN26AdvancedCompilerOptionsDlgD2Ev':
F:\cb_sf_git\trunk\src/plugins/compilergcc/advancedcompileroptionsdlg.cpp:82: undefined reference to `RegExArray::~RegExArray()'
F:\cb_sf_git\trunk\src/plugins/compilergcc/advancedcompileroptionsdlg.cpp:82: undefined reference to `RegExArray::~RegExArray()'
--- End code ---
While, I found that RegExArray is defined in sdk's header
--- Code: ---WX_DECLARE_OBJARRAY(RegExStruct, RegExArray);
--- End code ---
Refer to the wx's document: wxWidgets: interface/wx/dynarray.h File Reference, I change to the export version of this macro
--- Code: ---WX_DECLARE_EXPORTED_OBJARRAY(RegExStruct, RegExArray);
--- End code ---
But the linker error still happens. I looked at this macro:
--- Code: ---#define WX_DECLARE_EXPORTED_OBJARRAY(T, name) \
WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name, WXDLLIMPEXP_CORE)
--- End code ---
And something in "D:\wx3\include\wx\dlimpexp.h"
--- Code: ---#ifdef WXMAKINGDLL_CORE
# define WXDLLIMPEXP_CORE WXEXPORT
# define WXDLLIMPEXP_DATA_CORE(type) WXEXPORT type
# if defined(HAVE_VISIBILITY)
# define WXDLLIMPEXP_INLINE_CORE WXEXPORT
# else
# define WXDLLIMPEXP_INLINE_CORE
# endif
#elif defined(WXUSINGDLL)
# define WXDLLIMPEXP_CORE WXIMPORT
# define WXDLLIMPEXP_DATA_CORE(type) WXIMPORT type
# if defined(HAVE_VISIBILITY)
# define WXDLLIMPEXP_INLINE_CORE WXIMPORT
# else
# define WXDLLIMPEXP_INLINE_CORE
# endif
#else /* not making nor using DLL */
# define WXDLLIMPEXP_CORE
# define WXDLLIMPEXP_DATA_CORE(type) type
# define WXDLLIMPEXP_INLINE_CORE
#endif
--- End code ---
This means WXDLLIMPEXP_CORE is expanded to an empty string... Thus, RegExArray can't be exported easily. :(
ollydbg:
Well, it looks like wxWidgets is explicitly use the auto import/export method, see the comments in dllimpexp.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 ---
Especially
--- Code: --- /*
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+.
*/
--- End code ---
ollydbg:
I asked a question on the wx user maillist build wxWidgets dll without __declspec(dllexport) for MinGW target - Google Groups, it looks like someone has already done that:
Re: Compiling wxWidgets
Or
MINGW-packages/wxWidgets-3.0.0-gcc-codelight.patch at master ยท Alexpux/MINGW-packages
This does not export the unnecessary symbol, and reduce the wx's dll size, also it can app's improve the startup time.
ollydbg:
Good news: I have successfully build all targets inside codeblocks-wx30.cbp, with sdk only export symbols through the dllexport decoration, and I checked the codeblocks.dll, and it export about 3000 symbols, and the old way(all the symbols are exported), I see it export 9000 symbols, that reduced 2/3, great!
I will post the full patch tomorrow. :) It's late today.
ollydbg:
OK, now the patches(git style patch serials) are in Code::Blocks / Tickets / #239 reduce exported symbols from codeblocks.dll
I mainly do the following things in those patches:
1, only one pch file is used to build C::B.
2, some symbols in static libraries(such as some symbols in sqplus) are marked as "dllexport", and he symbols are exported in codeblocks.dll. So that all the src and plugin target only need to link against codeblocks.dll. No need to link to those static library(such as sqplus.a).
(Note that also build wxWidgets 3.0.2 library with the change of only export the dllexport maked symbol, which reduce the dll size, see build wxWidgets dll without __declspec(dllexport) for MinGW target - Google Groups for more details.
BTW: I see one issue is that some static library is stored in the folder "src\sdk\scripting\lib", this means they are shared with both codeblocks.cbp and codeblocks-wx30.cbp, this may cause some conflicts.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version