Author Topic: building CodeBlocks with M$ VC++ Toolkit 2003  (Read 28036 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

Offline CrazyAbbot

  • Multiple posting newcomer
  • *
  • Posts: 14
    • http://
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: [Select]

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

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
[email protected]@[email protected])

>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)" (
[email protected]@[email protected])

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

Offline CrazyAbbot

  • Multiple posting newcomer
  • *
  • Posts: 14
    • http://
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: [Select]

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: [Select]

------ 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" ([email protected]@@[email protected]@B)
cbeditor.obj : error LNK2001: unresolved external symbol "char const * const wxSTCNameStr" ([email protected]@3PBDB)
editorconfigurationdlg.obj : error LNK2001: unresolved external symbol "char const * const wxSTCNameStr" ([email protected]@3PBDB)
editormanager.obj : error LNK2001: unresolved external symbol "char const * const wxSTCNameStr" ([email protected]@3PBDB)
cbeditor.obj : error LNK2001: unresolved external symbol "public: static class wxClassInfo wxStyledTextCtrl::sm_classwxStyledTextCtrl" ([email protected]@@[email protected]@A)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_USERLISTSELECTION" ([email protected]@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_DWELLEND" ([email protected]@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_DWELLSTART" ([email protected]@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_CHARADDED" ([email protected]@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_CHANGE" ([email protected]@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_UPDATEUI" ([email protected]@3HB)
cbeditor.obj : error LNK2001: unresolved external symbol "int const wxEVT_STC_MARGINCLICK" ([email protected]@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?"

Offline CrazyAbbot

  • Multiple posting newcomer
  • *
  • Posts: 14
    • http://
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.

Offline CrazyAbbot

  • Multiple posting newcomer
  • *
  • Posts: 14
    • http://
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.

Offline CrazyAbbot

  • Multiple posting newcomer
  • *
  • Posts: 14
    • http://
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?

Offline CrazyAbbot

  • Multiple posting newcomer
  • *
  • Posts: 14
    • http://
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.

Offline CrazyAbbot

  • Multiple posting newcomer
  • *
  • Posts: 14
    • http://
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: [Select]
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?