User forums > Help

problems compiling default wxWidgets application

(1/3) > >>

pivica:
Hello everybody,

First of all thanks for codebloks, its really looking promising, but problems never ends :)
I have trouble compiling default wxWidgets application which i get from new project-> wxWidgets application.
I added include and lib directories from wxWidgets 2.6.0 for compiler and linker in build options.

When i try to compile whit MS Free Toolkit 2003 (i added Platform SDK and corresponding directories for include and lib), compilation went smoothly but linker complaint that he can't found ctl3d32.lib. I try to erase that lib from codebloks build option and than linker couldn't find MSVCRTD.lib; i added that lib from ms visual studio 2003 to lib directories from MS Free Toolkit and than i got many of already defined link errors.

I also tried with GCC and i get next error from compiler

--- Code: ---Project   : wxWidgets application
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\TEMP\wxWidgets1\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: main.cpp
In file included from C:/wx/wxWidgets/2.6.0/include/wx/platform.h:260,
                 from C:/wx/wxWidgets/2.6.0/include/wx/defs.h:21,
                 from C:/wx/wxWidgets/2.6.0/include/wx/wxprec.h:13,
                 from app.h:4,
                 from main.h:4,
                 from main.cpp:1:
C:/wx/wxWidgets/2.6.0/include/msvc/wx/setup.h:111:6: #error "This file should only be included when using Microsoft Visual C++"
--- End code ---

Version of codebloks is 1.0-RC1

Can anyone help me?

Funto:

--- Quote ---C:/wx/wxWidgets/2.6.0/include/msvc/wx/setup.h:111:6: #error "This file should only be included when using Microsoft Visual C++"
--- End quote ---
There should be another setup.h avalaible for MinGW somewhere in your wxWidgets install I think...

You could also, either compile wxWidgets by yourself with MinGW/MSYS, or use a DevPak.

zieQ:
Yes, you included the wrong header.
mine is here: wxWidgets-2.6.1\lib\gcc_dll\msw\wx

I compiled wxWidgets from the makefiles with MSVC Toolkit and MinGW with no problem, but you must carefully set the make options of wxWidgets to compile with MSVC Toolkit since it lacks some libraries. Compile only Release versions and you should not have any problem.

To compile with MSVC from C::B without MSVCRTD.lib, you must change the runtime libraries option in the build settings, but it will be a pain. Some advice as above, only release version. Don't know how to cope with the missing libraries of the Toolkit! I proposed an auto-detection of the missing libraries to disable some of the runtime library options but it is not implemented for now. If you have the libraries from Visual Studio it should work anyway. Could you please give the link errors you obtain?

pivica:
GCC

This time I include right header, and compilation went fine but linker stuck. I compiled wxWidgets with MS Visual Studio 7.1, and it cross on my mind that maybe I can't use GCC with wxWidgets libs that was compiled with MSVC. So I downloaded cygwin and compile wxWidgets with it; after little struggle I manage to compile wxWidgets. Back to CodeBloks, changed libs dir, and tried to rebuild all – program was compiled but, again, linking failed. Here is output:


--- Code: ---Project   : wxWidgets application
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\TEMP\wxWidgets1\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: main.cpp
Compiling: app.cpp
Linking executable: C:\TEMP\wxWidgets1\wxWidgets.exe
.objs\main.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x138): undefined reference to `wxWindow::RegisterHotKey(int, int, int)'
.objs\main.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x13c): undefined reference to `wxWindow::UnregisterHotKey(int)'
C:\wx\wxWidgets\2.6.0\lib\gcc_lib/libwx_based-2.6.a(baselib_wxchar.o): In function `Z7wxMB2WCPwPKcj':
../../src/common/wxchar.cpp:79: undefined reference to `mbsrtowcs'
../../src/common/wxchar.cpp:86: undefined reference to `mbsrtowcs'
C:\wx\wxWidgets\2.6.0\lib\gcc_lib/libwx_based-2.6.a(baselib_wxchar.o): In function `Z7wxWC2MBPcPKwj':
../../src/common/wxchar.cpp:106: undefined reference to `wcsrtombs'
../../src/common/wxchar.cpp:113: undefined reference to `wcsrtombs'
C:\wx\wxWidgets\2.6.0\lib\gcc_lib/libwx_based-2.6.a(baselib_log.o):../../src/common/log.cpp:532: undefined reference to `__getreent'
C:\wx\wxWidgets\2.6.0\lib\gcc_lib/libwx_based-2.6.a(baselib_log.o):../../src/common/log.cpp:532: undefined reference to `__getreent'
C:\wx\wxWidgets\2.6.0\lib\gcc_lib/libwx_based-2.6.a(baselib_log.o):../../src/common/log.cpp:551: undefined reference to `__getreent'
C:\wx\wxWidgets\2.6.0\lib\gcc_lib/libwx_based-2.6.a(baselib_utils.o): In function `Z12wxGetHomeDirP8wxString':
../../src/msw/utils.cpp:395: undefined reference to `cygwin_conv_to_full_win32_path'
C:\wx\wxWidgets\2.6.0\lib\gcc_lib/libwx_based-2.6.a(baselib_filename.o):../../src/common/filename.cpp:1063: undefined reference to `CoCreateInstance@20'
C:\wx\wxWidgets\2.6.0\lib\gcc_lib/libwx_based-2.6.a(baselib_filename.o):../../src/common/filename.cpp:1069: undefined reference to `IID_IPersistFile'
C:\wx\wxWidgets\2.6.0\lib\gcc_lib/libwx_based-2.6.a(baselib_filefn.o): In function `Z21wxGetWorkingDirectoryPci':
../../src/common/filefn.cpp:1459: undefined reference to `cygwin_conv_to_full_win32_path'
C:\wx\wxWidgets\2.6.0\lib\gcc_lib/libwx_based-2.6.a(baselib_filefn.o): In function `Z13wxGetFileKindi':
../../src/common/filefn.cpp:1928: undefined reference to `get_osfhandle'
C:\wx\wxWidgets\2.6.0\lib\gcc_lib/libwx_based-2.6.a(baselib_msgout.o):../../src/common/msgout.cpp:104: undefined reference to `__getreent'

.......
--- End code ---

MSVC Toolkit

Here are link errors I get when copy MSVCRTD.lib from visual studio to toolkit


--- Code: ---Project   : wxWidgets application
Compiler  : Microsoft Visual C++ Toolkit 2003 (called directly)
Directory : C:\TEMP\wxWidgets1\
--------------------------------------------------------------------------------
Switching to target: default
main.cpp
cl : Command line warning D4002 : ignoring unknown option '-pipe'
cl : Command line warning D4002 : ignoring unknown option '-mthreads'
cl : Command line warning D4002 : ignoring unknown option '-fno-pcc-struct-return'
cl : Command line warning D4002 : ignoring unknown option '-fno-rtti'
cl : Command line warning D4002 : ignoring unknown option '-fno-exceptions'
app.cpp
cl : Command line warning D4002 : ignoring unknown option '-pipe'
cl : Command line warning D4002 : ignoring unknown option '-mthreads'
cl : Command line warning D4002 : ignoring unknown option '-fno-pcc-struct-return'
cl : Command line warning D4002 : ignoring unknown option '-fno-rtti'
cl : Command line warning D4002 : ignoring unknown option '-fno-exceptions'
Linking executable: C:\TEMP\wxWidgets1\wxWidgets.exe
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _malloc already defined in LIBC.lib(malloc.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _realloc already defined in LIBC.lib(realloc.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _memmove already defined in LIBC.lib(memmove.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _free already defined in LIBC.lib(free.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _tolower already defined in LIBC.lib(tolower.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _calloc already defined in LIBC.lib(calloc.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _atoi already defined in LIBC.lib(atox.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _exit already defined in LIBC.lib(crt0dat.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _abort already defined in LIBC.lib(abort.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _strncpy already defined in LIBC.lib(strncpy.obj)
MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBC.lib(typinfo.obj)
MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBC.lib(typinfo.obj)
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
wxbase26d.lib(appbase.obj) : error LNK2019: unresolved external symbol __imp__MessageBoxA@16 referenced in function "bool __cdecl DoShowAssertDialog(class wxString const &)" (?DoShowAssertDialog@@YA_NABVwxString@@@Z)
wxbase26d.lib(log.obj) : error LNK2019: unresolved external symbol __imp__MessageBoxA@16 referenced in function "void __cdecl wxLogSysErrorHelper(long)" (?wxLogSysErrorHelper@@YAXJ@Z)
wxmsw26d_core.lib(app.obj) : error LNK2001: unresolved external symbol __imp__MessageBoxA@16
wxmsw26d_core.lib(msgdlg.obj) : error LNK2001: unresolved external symbol __imp__MessageBoxA@16
wxmsw26d_core.lib(evtloop.obj) : error LNK2001: unresolved external symbol __imp__PostMessageA@16
wxbase26d.lib(thread.obj) : error LNK2019: unresolved external symbol __imp__PostMessageA@16 referenced in function "public: enum wxThreadError __thiscall wxThreadInternal::WaitForTerminate(class wxCriticalSection &,void * *,class wxThread *)" (?WaitForTerminate@wxThreadInternal@@QAE?AW4wxThreadError@@AAVwxCriticalSection@@PAPAXPAVwxThread@@@Z)
wxbase26d.lib(utils.obj) : error LNK2001: unresolved external symbol __imp__PostMessageA@16
wxmsw26d_core.lib(frame.obj) : error LNK2001: unresolved external symbol __imp__PostMessageA@16
wxmsw26d_core.lib(app.obj) : error LNK2001: unresolved external symbol __imp__PostMessageA@16
wxbase26d.lib(thread.obj) : error LNK2019: unresolved external symbol __imp__MsgWaitForMultipleObjects@20 referenced in function "public: enum wxThreadError __thiscall wxThreadInternal::WaitForTerminate(class wxCriticalSection &,void * *,class wxThread *)" (?WaitForTerminate@wxThreadInternal@@QAE?AW4wxThreadError@@AAVwxCriticalSection@@PAPAXPAVwxThread@@@Z)
wxbase26d.lib(thread.obj) : error LNK2019: unresolved external symbol __imp__PostThreadMessageA@16 referenced in function "void __cdecl wxWakeUpMainThread(void)" (?wxWakeUpMainThread@@YAXXZ)
wxmsw26d_core.lib(evtloop.obj) : error LNK2019: unresolved external symbol __imp__PeekMessageA@20 referenced in function "public: virtual void __thiscall wxEventLoop::Exit(int)" (?Exit@wxEventLoop@@UAEXH@Z)
wxmsw26d_core.lib(printwin.obj) : error LNK2001: unresolved external symbol __imp__PeekMessageA@20
wxbase26d.lib(basemsw.obj) : error LNK2019: unresolved external symbol __imp__PeekMessageA@20 referenced in function "public: virtual void __thiscall wxConsoleAppTraits::AlwaysYield(void)" (?AlwaysYield@wxConsoleAppTraits@@UAEXXZ)
wxmsw26d_core.lib(window.obj) : error LNK2019: unresolved external symbol __imp__PeekMessageA@20 referenced in function "public: virtual bool __thiscall wxWindow::RegisterHotKey(int,int,int)" (?RegisterHotKey@wxWindow@@UAE_NHHH@Z)
wxmsw26d_core.lib(app.obj) : error LNK2019: unresolved external symbol __imp__PeekMessageA@20 referenced in function "public: static int __cdecl wxApp::GetComCtl32Version(void)" (?GetComCtl32Version@wxApp@@SAHXZ)
wxmsw26d_core.lib(utilsgui.obj) : error LNK2001: unresolved external symbol __imp__PeekMessageA@20
wxbase26d.lib(utils.obj) : error LNK2019: unresolved external symbol __imp__GetWindowThreadProcessId@8 referenced in function "int __stdcall wxEnumFindByPidProc(struct HWND__ *,long)" (?wxEnumFindByPidProc@@YGHPAUHWND__@@J@Z)
wxbase26d.lib(utils.obj) : error LNK2019: unresolved external symbol __imp__EnumWindows@8 referenced in function "int __cdecl wxKill(long,enum wxSignal,enum wxKillError *,int)" (?wxKill@@YAHJW4wxSignal@@PAW4wxKillError@@H@Z)
wxbase26d.lib(utils.obj) : error LNK2019: unresolved external symbol __imp__ExitWindowsEx@8 referenced in function "bool __cdecl wxShutdown(enum wxShutdownFlags)" (?wxShutdown@@YA_NW4wxShutdownFlags@@@Z)
wxbase26d.lib(utils.obj) : error LNK2019: unresolved external symbol __imp__MessageBeep@4 referenced in function "void __cdecl wxBell(void)" (?wxBell@@YAXXZ)
wxbase26d.lib(utils.obj) : error LNK2019: unresolved external symbol __imp__RegisterClassA@4 referenced in function _wxCreateHiddenWindow
wxmsw26d_core.lib(toplevel.obj) : error LNK2001: unresolved external symbol __imp__RegisterClassA@4
wxmsw26d_core.lib(app.obj) : error LNK2001: unresolved external symbol __imp__RegisterClassA@4
wxmsw26d_core.lib(notebook.obj) : error LNK2001: unresolved external symbol __imp__RegisterClassA@4
wxmsw26d_core.lib(tooltip.obj) : error LNK2001: unresolved external symbol __imp__CreateWindowExA@48
wxmsw26d_core.lib(spinctrl.obj) : error LNK2019: unresolved external symbol __imp__CreateWindowExA@48 referenced in function "public: virtual __thiscall wxCommandEvent::~wxCommandEvent(void)" (??1wxCommandEvent@@UAE@XZ)
wxmsw26d_core.lib(bmpbuttn.obj) : error LNK2001: unresolved external symbol __imp__CreateWindowExA@48
wxmsw26d_core.lib(slider95.obj) : error LNK2001: unresolved external symbol __imp__CreateWindowExA@48
wxbase26d.lib(utils.obj) : error LNK2019: unresolved external symbol __imp__CreateWindowExA@48 referenced in function "struct HWND__ * __cdecl CreateWindow(char const *,char const *,unsigned long,int,int,int,int,struct HWND__ *,struct HMENU__ *,struct HINSTANCE__ *,void *)" (?CreateWindow@@YAPAUHWND__@@PBD0KHHHHPAU1@PAUHMENU__@@PAUHINSTANCE__@@PAX@Z)
wxmsw26d_core.lib(toplevel.obj) : error LNK2001: unresolved external symbol __imp__CreateWindowExA@48
wxmsw26d_core.lib(window.obj) : error LNK2001: unresolved external symbol __imp__CreateWindowExA@48
wxmsw26d_core.lib(control.obj) : error LNK2001: unresolved external symbol __imp__CreateWindowExA@48
wxmsw26d_core.lib(textctrl.obj) : error LNK2001: unresolved external symbol __imp__SetCursor@4
wxmsw26d_core.lib(cursor.obj) : error LNK2001: unresolved external symbol __imp__SetCursor@4
wxbase26d.lib(crashrpt.obj) : error LNK2019: unresolved external symbol __imp__SetCursor@4 referenced in function "public: __thiscall BusyCursor::BusyCursor(void)" (??0BusyCursor@@QAE@XZ)
wxmsw26d_core.lib(window.obj) : error LNK2019: unresolved external symbol __imp__SetCursor@4 referenced in function "char const * __cdecl wxGetMessageName(int)" (?wxGetMessageName@@YAPBDH@Z)
wxmsw26d_core.lib(utilsgui.obj) : error LNK2001: unresolved external symbol __imp__SetCursor@4
Process terminated with status 1 (0 minutes, 15 seconds)
52 errors, 1 warnings
--- End code ---

I don't know those it matter but I didn't downloaded Platform SDK, I used one from MS Visual Studio installation. Then I tried with libs from Visual Studio, and I get identical errors like above.
Finally I compiled release version of wxWidgets with help of MS Visual Studio and give it a try, and again I have got same errors.
Where the hell I mistaking?

Why is so hard to make code::bloks compile wxWidgets applications? I read posts on forum and find out that there are many peoples who had problems whit this issue. When I find code::bloks on internet, couple days ago, and read that it is build with wxWidgets, I thought that compiling and running wxWidgets application from Code::Bloks would be easy thing, but it become very difficult thing.

zieQ:
There still may be some issues with the visual workspace loaders. I didn't try to compile wxWidgets when imported to C::B, so I can't tell you if I'm right or not. May you do not set the libraries correctly, I can't confirm you anything from the log you sent. I would not be surprised if the visual importer did not import wxWidget workspace well. You may check the projects compiler options in the second case to see if there's no two runtime libraries set for the projects (at the bottom of the option list - that addresses the "already defined in LIBC.lib" problem).

However, I have already recommended you to compile wxWidgets from the makefiles and not from C::B, you should try. There will be NO problem in this case, since that what I have done, provided that you set the PATH environment variable correctly to point your compiler directory. Please follow the build instructions shipped with wxWidgets.

Navigation

[0] Message Index

[#] Next page

Go to full version