Author Topic: building CodeBlocks with M$ VC++ Toolkit 2003  (Read 36467 times)

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #15 on: June 15, 2005, 02:54:31 pm »
for wx 2.4.2 look into the contrib dir. (see installatio instructions in the wiki)
for wx 2.6.* you will find the stc in the contrib dir and xrc with USE_XRC option in the normal build (again look into the wiki)
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

CrazyAbbot

  • Guest
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #16 on: June 15, 2005, 04:57:52 pm »
Ok ive done that, both the stc and xrc librarys compiled as a DLL and linked in

It's been giving me a few more errors now, in trying to link codeblocks.dll
I've sorted out most of them, but these ones remain.

Some of them look like functions/classes in the dll itself, why are they causing link errors?

I'm using wx 2.4.2

Code

cbeditor.obj : error LNK2001: unresolved external symbol "protected: static struct wxEventTable const wxStyledTextCtrl::sm_eventTable" (?sm_eventTable@wxStyledTextCtrl@@1UwxEventTable@@B)
cbeditor.obj : error LNK2001: unresolved external symbol "char const * const wxSTCNameStr" (?wxSTCNameStr@@3PBDB)
editorconfigurationdlg.obj : error LNK2001: unresolved external symbol "char const * const wxSTCNameStr" (?wxSTCNameStr@@3PBDB)
cbeditor.obj : error LNK2001: unresolved external symbol "public: static class wxClassInfo wxStyledTextCtrl::sm_classwxStyledTextCtrl" (?sm_classwxStyledTextCtrl@wxStyledTextCtrl@@2VwxClassInfo@@A)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_USERLISTSELECTION" (?wxEVT_STC_USERLISTSELECTION@@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_DWELLEND" (?wxEVT_STC_DWELLEND@@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_DWELLSTART" (?wxEVT_STC_DWELLSTART@@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_CHARADDED" (?wxEVT_STC_CHARADDED@@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_CHANGE" (?wxEVT_STC_CHANGE@@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_UPDATEUI" (?wxEVT_STC_UPDATEUI@@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_MARGINCLICK" (?wxEVT_STC_MARGINCLICK@@3HB)
projectmanager.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl wxAssert(int,char const *,int,char const *,char const *)" (__imp_?wxAssert@@YAXHPBDH00@Z)
projecttemplateloader.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl wxAssert(int,char const *,int,char const *,char const *)" (__imp_?wxAssert@@YAXHPBDH00@Z)
xtra_res.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl wxAssert(int,char const *,int,char const *,char const *)" (__imp_?wxAssert@@YAXHPBDH00@Z)
configmanager.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl wxAssert(int,char const *,int,char const *,char const *)" (__imp_?wxAssert@@YAXHPBDH00@Z)
filegroupsandmasks.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl wxAssert(int,char const *,int,char const *,char const *)" (__imp_?wxAssert@@YAXHPBDH00@Z)
pipedprocess.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl wxAssert(int,char const *,int,char const *,char const *)" (__imp_?wxAssert@@YAXHPBDH00@Z)
projectbuildtarget.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl wxAssert(int,char const *,int,char const *,char const *)" (__imp_?wxAssert@@YAXHPBDH00@Z)
cbplugin.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl wxAssert(int,char const *,int,char const *,char const *)" (__imp_?wxAssert@@YAXHPBDH00@Z) referenced in function "void __cdecl wxPostEvent(class wxEvtHandler *,class wxEvent &)" (?wxPostEvent@@YAXPAVwxEvtHandler@@AAVwxEvent@@@Z)
cbproject.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl wxAssert(int,char const *,int,char const *,char const *)" (__imp_?wxAssert@@YAXHPBDH00@Z)
compiler.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl wxAssert(int,char const *,int,char const *,char const *)" (__imp_?wxAssert@@YAXHPBDH00@Z) referenced in function "public: void __thiscall RegExArray::Add(struct RegExStruct const &,unsigned int)" (?Add@RegExArray@@QAEXABURegExStruct@@I@Z)
compilerfactory.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl wxAssert(int,char const *,int,char const *,char const *)" (__imp_?wxAssert@@YAXHPBDH00@Z)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #17 on: June 15, 2005, 11:27:44 pm »
Check out the latest CVS and see if the errors are reduced. I think it's got to do with  a DLLIMPORT clause missing.

Regarding the wxAssert, it seems (IMHO) you're using the DEBUG build of wxwidgets. Check out the wiki for wxwidgets compilation instructions.

Oh, found similar warnings in the web. Look!

http://lists.wxwidgets.org/archive/wxPython-users/msg04275.html

Quote

>but now I am getting unresolved externals.
> A bunch of unresolved externals involving wxAssert like this:
> windows.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) v
> void __cdecl wxAssert(int,char const *,int,char const *,char const *)" (__imp_?wx
Assert@@YAXHPBDH00@Z)

>as well as a bunch about wxObject new:

> wx.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public
: static void * __cdecl wxObject::operator new(unsigned int,char const *,int)" (
__imp_??2wxObject@@SAPAXIPBDH@Z)

You need to rebuild everything. It looks like at lease some of your wxPython .obj files were built with hybrid settings.

CrazyAbbot

  • Guest
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #18 on: June 16, 2005, 03:39:24 am »
Ok, i've downloaded the code from cvs and i'm using that.

ive found a little oddity in your code, its nothing major but the compiler complains about it.

in toolsmanager.h you have struct Tool{}  but you prototype it elsewhere as class Tool;

I've done this in toolsmanager.h to shut it up.

Code

class Tool
{
public:
Tool(){ menuId = -1; }
wxString name;
wxString command;
wxString params;
wxString workingDir;
int menuId;
};


I'm not using a debug build of wxwidgets or any other library and i'm linking it with libtinyxml, wxxrc stcdll and the wxwidgets dll.

I'm defining these preprocessor symbols.  Is there anything im missing?

__WX__
__WIN32__
__WINDOWS__
WINDOWS
WXMSW
__WXMSW__
WXUSINGDLL
EXPORT_LIB
EXPORT_EVENTS
_USRDLL

The build errors are a bit different now.  they seem to be about the styled text control.  Thats built as a dll.

The wiki isnt completey clear, should the stc and xrc be build as static libraries?

compiling and linking stc staticly seems to generate even more linker errors.

Code

------ Build started: Project: codeblocks_dll, Configuration: Release Win32 ------

Linking...
   Creating library Release/codeblocks_dll.lib and object Release/codeblocks_dll.exp
cbeditor.obj : error LNK2001: unresolved external symbol "protected: static struct wxEventTable const wxStyledTextCtrl::sm_eventTable" (?sm_eventTable@wxStyledTextCtrl@@1UwxEventTable@@B)
cbeditor.obj : error LNK2001: unresolved external symbol "char const * const wxSTCNameStr" (?wxSTCNameStr@@3PBDB)
editorconfigurationdlg.obj : error LNK2001: unresolved external symbol "char const * const wxSTCNameStr" (?wxSTCNameStr@@3PBDB)
editormanager.obj : error LNK2001: unresolved external symbol "char const * const wxSTCNameStr" (?wxSTCNameStr@@3PBDB)
cbeditor.obj : error LNK2001: unresolved external symbol "public: static class wxClassInfo wxStyledTextCtrl::sm_classwxStyledTextCtrl" (?sm_classwxStyledTextCtrl@wxStyledTextCtrl@@2VwxClassInfo@@A)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_USERLISTSELECTION" (?wxEVT_STC_USERLISTSELECTION@@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_DWELLEND" (?wxEVT_STC_DWELLEND@@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_DWELLSTART" (?wxEVT_STC_DWELLSTART@@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_CHARADDED" (?wxEVT_STC_CHARADDED@@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_CHANGE" (?wxEVT_STC_CHANGE@@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_UPDATEUI" (?wxEVT_STC_UPDATEUI@@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_MARGINCLICK" (?wxEVT_STC_MARGINCLICK@@3HB)
Release/codeblocks_dll.dll : fatal error LNK1120: 10 unresolved externals


I might give it a go with wx widgets 2.6 later on

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #19 on: June 16, 2005, 07:21:09 am »
OK, updated CVS with your Tool code. Did you remember to copy the libstc.a to your mingw path, or add its directory to your linker dir?

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #20 on: June 16, 2005, 09:05:57 am »
Quote from: rickg22
... Did you remember to copy the libstc.a to your mingw path, or add its directory to your linker dir?


hey rick ! please remember : in this thread MSVC compiler is used   8)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #21 on: June 16, 2005, 06:35:56 pm »
Ack! Yes, you're right. :oops: OK I'll rephrase. "Did you remember to copy the libstc.lib to your compiler path, or add its directory to your linker dir?"

CrazyAbbot

  • Guest
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #22 on: June 17, 2005, 02:53:04 am »
yeah im linking with libstc, libtinyxml and libwxxrc

do i complie stc and xrc as dll's or static libraries?

niether way works, i'll have to fiddle with it a bit more.
im not too familar with creating DLL's.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #23 on: June 17, 2005, 05:53:50 am »
According to the codeblocks compilation instructions they have to be linked statically.

CrazyAbbot

  • Guest
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #24 on: June 17, 2005, 04:37:34 pm »
Ok ive got it all to compile and link etc,  i've built the codeblocks exe

It loads the splash screen and then crashes.

I'll have a look at this in more detail later on to see what is going on.  i think i might be forgetting to do link or compile something.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #25 on: June 17, 2005, 06:35:42 pm »
Hmmm. Perhaps you should debug it and see what's the offending line.

BTW, did you try getting latest CVS? I discovered a missing DLLIMPORT clause that crashed whenever I added event handling to certain classes. Maybe this missing DLLIMPORT causes VC++ builds to crash, too.

CrazyAbbot

  • Guest
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #26 on: June 18, 2005, 05:21:17 am »
I tried it again with the CVS code and sort of have it working now, without any plugins.

The main problem is the codeblocks.dll  MSVC won't build it as a dll and the plugins need to link against it

I got around this by linking it as a static library. however this wont work with the plugins.

You seem to be doing some odd stuff that MSVC dosn't like with regard to your dll exports.  some classes appear to be defined in macros and i think they need to be marked as DLL export, im not certian. I'll look into this later. but are you aware of doing anything nonstandard with regard to this?

in the header file settings.h you have MSVC define DLLIMPORT as nothing.  defining as the proper declspec gives this error when trying to make the DLL. (for just about every class exported by codeblocks.dll)
Quote

class 'FileSetArray' needs to have dll-interface to be used by clients of class 'ProjectTemplateLoader'


Also, I've noticed a lot of strange things in the code, you seem to be casting pointers to longs and vice versa, why is this? its pretty poor practice and not 64 bit portable.  (not to insult the devs or anything, i know how tricky large projects can be)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #27 on: June 18, 2005, 05:41:37 am »
yeah, well. According to Yiannis, NULL isn't defined for all compilers and this is supposed to be cross-platform. But I'm sure we can argue that NULL is indeed defined for MSVC, and needed for 64-bit platforms.

So, what do you think, chief? :)

Anyway, CrazyAbbot, how do you define a dll import in MSVC?

CrazyAbbot

  • Guest
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #28 on: June 18, 2005, 06:41:25 am »
NULL? wtf ?!

anyway,

defining dll imports and exports is the same as for mingw
MSDN linky


It's these classes declared here in the macros that have the problem,  are they exported into the DLL?  if not then that may be the problem.

example:
WX_DECLARE_OBJARRAY(ConfigurationPath, Configurations);

I've gone through the header files right into the mess of #defines in the wxwidgets library and maybe its something going on there? does it generate dllexport linkages when the macros generate the class?

It looks like the member classes created in the macro's are not being exported.

CrazyAbbot

  • Guest
building CodeBlocks with M$ VC++ Toolkit 2003
« Reply #29 on: June 18, 2005, 08:00:26 am »
Hmm ok i just managed to get the codeblocks.dll to build and i managed to link it with the codeblocks.exe  (albiet with 600+ warnings, but working none the less)

To get the DLL to link with the exe i had to declare the MessageManager class with the DLLIMPORT macro.  (it was causing link errors in the main exe otherwise)

one question

in the file startherepage.cpp what is this class for?
Code
class DLLIMPORT MyHtmlWin : public wxHtmlWindow


I had to remove the DLLIMPORT macro for it to compile

When codeblocks starts up now, it complains that its unable to open the requested document "start_here.zip#zip:start_here.html"
is this something new that was added in recently?