Author Topic: wxWidgets Sample compiling error  (Read 8534 times)

cs378

  • Guest
wxWidgets Sample compiling error
« on: September 14, 2007, 06:42:43 am »
I have just successfully build wxWidgets 3.8.5 (took a day...)

Now I wanted to just compile a simple code in Code:Blocks.

I did File --> New Project

I selected wxWidgets project. Clicked on next on everything for default.

Now I compile the sample code and I get:

C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lwxmsw28d_core


I am using Code::Blocks SVN 4466 in Windows XP Pro SP2

In my Global Variables
Base: C:\wxWidgets-2.8.5
include: C:\wxWidgets-2.8.5\include
lib: C:\wxWidgets-2.8.5\lib\gcc_lib
others are left blank.

In my compiler and debugger --> Search Directories
Compiler: C:\wxWidgets-2.8.5\include
                       C:\wxWidgets-2.8.5\include\wx\msw
                       C:\wxWidgets-2.8.5\contrib\include
                       C:\MinGW\include
Linker: C:\wxWidgets-2.8.5\lib
                   C:\wxWidgets-2.8.5\lib\gcc_lib
                   C:\MinGW\lib
Resource Compiler:  C:\MinGW\include

And yes this is my first time using code::blocks :P

Thanks in advance.


                       

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: wxWidgets Sample compiling error
« Reply #1 on: September 14, 2007, 06:59:15 am »
I have just successfully build wxWidgets 3.8.5 (took a day...)

C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lwxmsw28d_core

Seems you have compiled the wxWidgets lib with MONOLITIC=1 but try to use them differently (with separated libs). You only need to link against wxmsw28 (or wxmswd28 for the debug build). Setup your linker options accordingly. BTW: I realised you are linking against the debug lib (wxmsw28d_core). Are you sure you have built this, too? Otherwise you have to compile the debug version of wx, too or simply link against the release version unless you really wanrt to debug into wx itself.
With regards, Morten.
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

cs378

  • Guest
Re: wxWidgets Sample compiling error
« Reply #2 on: September 14, 2007, 07:18:39 am »
Thank you for replying :)

yes you are right i compiled with MONOLITHIC = 1

mingw32-make -f makefile.gcc  MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release

So should I compile it again like this:

mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=release

Yeah I build it twice, the first build i used BUILD = debug
then is clean it and build with the top code.

I guess the clean didnt work well
« Last Edit: September 14, 2007, 07:20:14 am by cs378 »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: wxWidgets Sample compiling error
« Reply #3 on: September 14, 2007, 07:41:34 am »
So should I compile it again like this:
mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=release
Depends on what you have in mind. Both ways are possible: monolitic and shared. monolitic means "easier" project setup but slightly bigger executables. C::B uses monolitic. Shared means you have to think about what wx libs you actually use/need and link only against those. Nice one, too. What do you want? :)
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

cs378

  • Guest
Re: wxWidgets Sample compiling error
« Reply #4 on: September 14, 2007, 07:50:03 am »
errr.... I'm a newbie. This is my first time trying both wxWidgets and Code::Blocks

I guess the easier the better :P

So...

mingw32-make -f makefile.gcc  MONOLITHIC=1 UNICODE=1 BUILD=release

I am building from a fresh wxWidgets source. Hope this time it'll work :P

Thanks  :wink:
« Last Edit: September 14, 2007, 07:52:56 am by cs378 »

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: wxWidgets Sample compiling error
« Reply #5 on: September 14, 2007, 07:54:09 am »
I am using Code::Blocks SVN 4466 in Windows XP Pro SP2

In my Global Variables
Base: C:\wxWidgets-2.8.5
include: C:\wxWidgets-2.8.5\include
lib: C:\wxWidgets-2.8.5\lib\gcc_lib
others are left blank.

You don't need to fill include and lib directories. They will be added by the wx wizard. Specifying lib dir = C:\wxWidgets-2.8.5\lib\gcc_lib means that you're using static library of wx. But you've mentioned that you've compiled a shared library of wx. They contradict with each other and causing this error.
Be a part of the solution, not a part of the problem.

cs378

  • Guest
Re: wxWidgets Sample compiling error
« Reply #6 on: September 14, 2007, 07:56:33 am »
I see

I will try to change that after I have finish this newly compiled without SHARE.

Thank You so much both

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: wxWidgets Sample compiling error
« Reply #7 on: September 14, 2007, 08:00:16 am »
MONOLITHIC=1: a single library file with all wx stuff in it (preferred option).
MONOLITHIC=0: many library files separated by "category". core is one of those.

SHARED=1: create a shared (DLL/so/dylib) library (libraries if MONOLITHIC=0) that all your programs can share. You must provide this(these) file(s) along with your executable if you want to run it elsewhere (preferred option).
SHARED=0: create a static (.lib/.a) library. You won't have to include extra files to get your files working anywhere else, but all your executables will be huge.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: wxWidgets Sample compiling error
« Reply #8 on: September 14, 2007, 08:37:19 am »
MONOLITHIC=1:
MONOLITHIC=0:
SHARED=1:
SHARED=0:
Oh dear - it's too early in the morning. Sure - Ceniza is right. ;-)
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

cs378

  • Guest
Re: wxWidgets Sample compiling error
« Reply #9 on: September 14, 2007, 08:49:24 am »
Thank you al for the help early in the morning.

ahhh yes

it worked and i know what the problem was b4
its all abt the creating new project
i just had to check build unicode and monothic

sigh...

I am going to rebuild with SHARE now hehe :)

okay another queation
 what is the diff between BUILD=debug and BUILD=release??

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: wxWidgets Sample compiling error
« Reply #10 on: September 14, 2007, 09:15:49 am »
BUILD=debug will create a big library that you can debug (I don't really think you want that).
BUILD=release will create a smaller library with optimizations that you won't be able to debug (except if you feel like debugging asm code). However, you'll be able to debug your own code, so don't worry about it.

cs378

  • Guest
Re: wxWidgets Sample compiling error
« Reply #11 on: September 14, 2007, 11:22:31 pm »
Hi I rebuild everything. with monolithic and share
And it compiled the sample of wxWidgets given by Code::Blocks. Ran perfectly :P
Thank You all for helping me understand the different options.


Now its time learn the use of wxWidgets. I found:
http://www.wxwidgets.org/docs/tutorials/hello.htm

It seems like a good start. So I copied the code and compile it in an empty project.

and boom i got errors again :(

Code
-------------- Build: Release in wxHelloWorld ---------------
Compiling: wxHelloWorld.cpp
Linking console executable: bin\Release\wxHelloWorld.exe
Info: resolving wxFrame::sm_eventTable       by linking to __imp___ZN7wxFrame13sm_eventTableE (auto-import)
Info: resolving _wxEmptyString by linking to __imp__wxEmptyString (auto-import)
Info: resolving vtable for wxwxMenuItemListNodeby linking to __imp___ZTV20wxwxMenuItemListNode (auto-import)
Info: resolving wxAppConsole::ms_appInstance        by linking to __imp___ZN12wxAppConsole14ms_appInstanceE (auto-import)
Info: resolving wxStringBase::npos       by linking to __imp___ZN12wxStringBase4nposE (auto-import)
Info: resolving _wxFrameNameStr by linking to __imp__wxFrameNameStr (auto-import)
Info: resolving vtable for wxFrameby linking to __imp___ZTV7wxFrame (auto-import)
Info: resolving vtable for wxMenuBaseby linking to __imp___ZTV10wxMenuBase (auto-import)
Info: resolving vtable for wxListBaseby linking to __imp___ZTV10wxListBase (auto-import)
Info: resolving vtable for wxMenuby linking to __imp___ZTV6wxMenu (auto-import)
Info: resolving _wxStatusLineNameStr by linking to __imp__wxStatusLineNameStr (auto-import)
Info: resolving vtable for wxObjectby linking to __imp___ZTV8wxObject (auto-import)
Info: resolving _wxEVT_COMMAND_MENU_SELECTED by linking to __imp__wxEVT_COMMAND_MENU_SELECTED (auto-import)
Info: resolving _wxEVT_NULL by linking to __imp__wxEVT_NULL (auto-import)
Info: resolving wxAppConsole::ms_appInitFn        by linking to __imp___ZN12wxAppConsole12ms_appInitFnE (auto-import)
obj\Release\wxHelloWorld.o:wxHelloWorld.cpp:(.text+0x197): undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\wxHelloWorld.o:wxHelloWorld.cpp:(.text+0x33d): undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\wxHelloWorld.o:wxHelloWorld.cpp:(.text+0x370): undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\wxHelloWorld.o:wxHelloWorld.cpp:(.text+0x421): undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\wxHelloWorld.o:wxHelloWorld.cpp:(.text+0x454): undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\wxHelloWorld.o:wxHelloWorld.cpp:(.text+0x505): more undefined references to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)' follow
obj\Release\wxHelloWorld.o:wxHelloWorld.cpp:(.rdata$_ZTV15wxHelloWorldApp[vtable for wxHelloWorldApp]+0x44): undefined reference to `wxApp::Initialize(int&, char**)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 7 seconds)
6 errors, 0 warnings

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: wxWidgets Sample compiling error
« Reply #12 on: September 15, 2007, 04:41:55 pm »
It seems like a good start. So I copied the code and compile it in an empty project.
and boom i got errors again :(
Maybe before start using a framework like wx it's better to understand how a compiler and linker works. And what parameters you have to provide to the compiler and linker. An empty project has *no* options setup. How should C::B - and therefor the compiler/linker know against what to compile/link, where to search for things and so on. You (!) have to provide that information.

I really suggest you try the following: Try to compile a simple "hello wx world" thing from the *command line* without any IDE. Once this works go back to C::B, setup your project accordingly and use the fancy stuff an IDE provides you with correctly.

With regards, Morten.
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