Author Topic: Build CodeBlocks using Microsoft Visual C++  (Read 39085 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Build CodeBlocks using Microsoft Visual C++
« on: April 05, 2011, 06:31:38 pm »
Hi, All, I am try building CB using MSVC, But have some linker error, and can not solved it.
I am need your help.
Many thanks!
Quote
scriptingsettingsdlg.obj||error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxDialogHelper::DoLayoutAdaptation(void)" (?DoLayoutAdaptation@wxDialogHelper@@UAE_NXZ)|
switcherdlg.obj||error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxDialogHelper::DoLayoutAdaptation(void)" (?DoLayoutAdaptation@wxDialogHelper@@UAE_NXZ)|
dlgaboutplugin.obj||error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxDialogHelper::DoLayoutAdaptation(void)" (?DoLayoutAdaptation@wxDialogHelper@@UAE_NXZ)|
environmentsettingsdlg.obj||error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxDialogHelper::DoLayoutAdaptation(void)" (?DoLayoutAdaptation@wxDialogHelper@@UAE_NXZ)|
main.obj||error LNK2019: unresolved external symbol "public: virtual bool __thiscall wxDialogHelper::DoLayoutAdaptation(void)" (?DoLayoutAdaptation@wxDialogHelper@@UAE_NXZ) referenced in function "bool __cdecl SqPlus::Match(struct SqPlus::TypeWrapper<bool>,struct SQVM *,int)" (?Match@SqPlus@@YA_NU?$TypeWrapper@_N@1@PAUSQVM@@H@Z)|
printdlg.obj||error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxDialogHelper::DoLayoutAdaptation(void)" (?DoLayoutAdaptation@wxDialogHelper@@UAE_NXZ)|
app.obj||error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxDialogHelper::DoLayoutAdaptation(void)" (?DoLayoutAdaptation@wxDialogHelper@@UAE_NXZ)|
........
........
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings (0 minutes, 54 seconds) ===|
« Last Edit: April 06, 2011, 03:37:20 am by Loaden »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #1 on: April 05, 2011, 10:47:51 pm »
What is your wx version? 2.9 probably?
If it is 2.8 check if you compile the scrollingdialog.cpp correctly.
(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 Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #2 on: April 06, 2011, 01:31:18 am »
What is your wx version? 2.9 probably?
If it is 2.8 check if you compile the scrollingdialog.cpp correctly.
It's 2.8.12, And I can sure scrollingdialog.cpp been compiled.
« Last Edit: April 06, 2011, 01:33:07 am by Loaden »

Offline xunxun

  • Almost regular
  • **
  • Posts: 187
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #3 on: April 06, 2011, 03:22:08 am »
Yes, scrollingdialog.cpp is really compiled, but in my surprise, CodeBlocks.lib doesn't contain any wxDialogHelper's symbol.
Regards,
xunxun

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #4 on: April 06, 2011, 03:36:00 am »
@loaden
someone has used a msvc compiler to build the codeblocks, he just released it on sourceforge. Sorry I can't find the link now.
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 Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #5 on: April 06, 2011, 03:38:52 am »
Yes, scrollingdialog.cpp is really compiled, but in my surprise, CodeBlocks.lib doesn't contain any wxDialogHelper's symbol.
I am think so, but I can't find the reason.
In V2, I am using /OPT:NOREF and /OPT:NOICF, But not work too.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #6 on: April 06, 2011, 03:39:25 am »
@loaden
someone has used a msvc compiler to build the codeblocks, he just released it on sourceforge. Sorry I can't find the link now.
OK, I try search now.

Offline xunxun

  • Almost regular
  • **
  • Posts: 187
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #7 on: April 06, 2011, 04:08:55 am »
I try to change CodeBlocks.lib(dynamic lib) to static lib and add /ignore:4006 /ignore:4221 to linker option.
The LNK1189 error comes out : The limit of 65535 objects or members in a library has been exceeded.
Regards,
xunxun

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #8 on: April 06, 2011, 04:26:24 am »
I try to change CodeBlocks.lib(dynamic lib) to static lib and add /ignore:4006 /ignore:4221 to linker option.
The LNK1189 error comes out : The limit of 65535 objects or members in a library has been exceeded.

We can't build the SDK to static lib, because there have many plugins need the SDK.
Now I find a reason, that we need make it import.
like:
class DLLIMPORT wxDialogHelper
{

Offline xunxun

  • Almost regular
  • **
  • Posts: 187
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #9 on: April 06, 2011, 04:31:17 am »
I try to change CodeBlocks.lib(dynamic lib) to static lib and add /ignore:4006 /ignore:4221 to linker option.
The LNK1189 error comes out : The limit of 65535 objects or members in a library has been exceeded.

We can't build the SDK to static lib, because there have many plugins need the SDK.
Now I find a reason, that we need make it import.
like:
class DLLIMPORT wxDialogHelper
{

That's right. I have found it just now.
Regards,
xunxun

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #10 on: April 06, 2011, 06:30:41 am »
@loaden
someone has used a msvc compiler to build the codeblocks, he just released it on sourceforge. Sorry I can't find the link now.
OK, I try search now.
It's here:
http://forums.codeblocks.org/index.php/topic,13454.msg90615.html#msg90615
(http://cb4vc.sourceforge.net/)

But I see no reason why we should try to make C::B compile with VC. C::B was designed to support the GCC compiler and only the GCC compiler. Support for VC will force us to use a lot of #defines which will make the code look very ugly and this is clearly not what we want. In the fact we've removed a lot portions in the code concerning VC (like pragmas and alike) because it really made the code hard to read. So whatever you come out with, please do not commit.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #11 on: April 06, 2011, 06:32:16 am »
Success for Release Build, But still occured some error when use Debug build.
Quote
advancedcompileroptionsdlg.obj||error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl wxOnAssert(wchar_t const *,int,char const *,wchar_t const *,wchar_t const *)" (__imp_?wxOnAssert@@YAXPB_WHPBD00@Z) referenced in function "void * __cdecl wxCheckCast(void *)" (?wxCheckCast@@YAPAXPAX@Z)|
compilererrors.obj||error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl wxOnAssert(wchar_t const *,int,char const *,wchar_t const *,wchar_t const *)" (__imp_?wxOnAssert@@YAXPB_WHPBD00@Z)|
compilergcc.obj||error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl wxOnAssert(wchar_t const *,int,char const *,wchar_t const *,wchar_t const *)" (__imp_?wxOnAssert@@YAXPB_WHPBD00@Z)|
compileroptionsdlg.obj||error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl wxOnAssert(wchar_t const *,int,char const *,wchar_t const *,wchar_t const *)" (__imp_?wxOnAssert@@YAXPB_WHPBD00@Z)|


Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #12 on: April 06, 2011, 06:39:45 am »
It's here:
http://forums.codeblocks.org/index.php/topic,13454.msg90615.html#msg90615
(http://cb4vc.sourceforge.net/)
Thanks!!

But I see no reason why we should try to make C::B compile with VC. C::B was designed to support the GCC compiler and only the GCC compiler. Support for VC will force us to use a lot of #defines which will make the code look very ugly and this is clearly not what we want. In the fact we've removed a lot portions in the code concerning VC (like pragmas and alike) because it really made the code hard to read. So whatever you come out with, please do not commit.
I don't think so, Only need a little guard code (like #ifdef _MSC_VER), and seems very clearly.

Some reasons:
1. Use MSVC's Debug Tools for find some crash
2. Get VC compiler warnings to correct the code
3. VC is better and faster than GCC in Windows OS

Morten, could you view the patch? If you fell the VC Support Code is so *ugly*.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #13 on: April 06, 2011, 06:43:36 am »
BTW, The V6 patch only support mini core CB code now.
In currently, there not include Debugger, OpenFileList....

When using GDB, some crash is difficult to capture.
I think this project (for MSVC) should be usefull.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Build CodeBlocks using Microsoft Visual C++
« Reply #14 on: April 06, 2011, 07:05:38 am »
@loaden
it seems you add a lot of DLLIMPORT before the class declaration. But why they are not needed when build with MinGW GCC?

You patches v6 contains a lot of duplicated piece code. (which means: you don't change anything on the code, maybe, there are some space, tabs added/moved)

From my point of view, if the change code is quite minimal, then I think adding for the VC build could be added. :D
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.