Solved wx simple example needed

Hi all,

I trying to write a trivial "hello world" application using wx widgets in FreeBSD but I get tons of errors when copying code from the web and trying to compile.

I simlinked wxgtk2u2.8config to wx-config, ok, I solved that silly point.

Could some of you help me to get started? What I would need is a simple, trivial foo.cc file with the instructions for compilation.
From there I will move on my own feet.

In the long run what I would like to do is making wxruby work in FreeBSD but, for now, I need to grasp the basics of how the c++ works, or my attempts to "rake" the "wxruby" will be headless try & pray.
 
Can't help much with this but you typically have to add -L/usr/local/lib and -I/usr/local/include to get things to compile and link properly on FreeBSD. This is because these are third party libraries (prefixed /usr/local/) and the compiler usually only looks at /usr/lib and /usr/include.
 
I tend to use this to get me started:

https://wiki.wxwidgets.org/Example_Of_Using_Connect_For_Events

Why I like it is because it uses Connect (or Bind) to setup click events and things rather than that old style event table system that wxWidgets used to use (and copied off Microsoft's MFC).

To compile it is something like this. The wx-config script should add the correct include and library path for /usr/local/[include,lib]
c++ `wx-config --cflags` main.cpp `wx-config --libs`

However, you don't have wx-config in the FreeBSD port of wxGTK. It is named something like wxgtk-*-config so just type "wx" into the command prompt and press tab a couple of times until you find it ;)

The ` is a backtick, it basically calls the command and uses its stdout as part of the current command. wxWidgets (like most GUI libraries) is a little bit overly sloppy when it comes to ease of use and so isn't in a single nice library. For this reason I recommend using the wx-config tool rather than manually specifying the -I, -L, -l flags. Though you can find what wx-config is returning simply by running it on the command prompt.
 
guys, i really appreciate your help !
I saw someting I tried already as many -I and -L and ` wx-config xxx ` options
but I will re-read all carefully tomorrow and do some experiments.
I will let you know.
 
i could not resist, i tried something before leaving, starting from
the last, kpedersen suggestion. And i was lucky.

The code you link does not compile with:
c++ `wxgtk2u-2.8-config --cflags` ex2.cpp `wxgtk2u-2.8-config --libs`

But it (even if tossing quite a bit of warnings) compiles and runs with:
c++ `wxgtk2u-3.0-config --cflags` ex2.cpp `wxgtk2u-3.0-config --libs`

So, yes, ok, I have my starting point ! Thank you again to everybody.
Time to go to sleep.
As Guy Steele wrote in a thick book "I am not as young as i used to be" ;)
 
Back
Top