Downloaded samples from www.wxwidget.org are not working Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
gunjan
Earned a small fee
Earned a small fee
Posts: 18
Joined: Wed Sep 22, 2010 8:34 am

Downloaded samples from www.wxwidget.org are not working

Post by gunjan »

I have downloaded the wxwidget samples from www.wxwidget.org download section and the release I download is stable release. I build and install as per given in install_gtk.txt file.
After building I tried to compile and run a sample given in sample folder. But all of them giving errors. Initial errors are not correct path of headers included.

Do I need to do some change in path or need to configure something before I run and sample or my own application.

Regards
Gunjan
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Hi,
I have downloaded the wxwidget samples
Do you mean one of the wxWidgets source packages? If so, which one?
I build and install as per given in install_gtk.txt file.
That probably means the answer to my first question is 'Yes' ;) . Which bit of the install_gtk.txt advice did you follow? The "simplest case" with ../configure --with-gtk, or one of the others?
After building I tried to compile and run a sample given in sample folder
Which sample folder, and how did you try to compile?
What you should have done for e.g. the 'minimal' sample, was to cd to buildgtk/samples/minimal/ and then run 'make'.
The 'simplest program' instructions apply to your own programs. If you get problems with those, the first thing to do is to run 'wx-config --list' and examine the output.

Regards,

David
gunjan
Earned a small fee
Earned a small fee
Posts: 18
Joined: Wed Sep 22, 2010 8:34 am

Post by gunjan »

Hi,

Thanks for your quick reply.
I have downloaded 2.8.11 version of wxWidget source packages.
Yes I have followed the simplest case with ../configure --with-gtk in Linux system.(Working on fedora 9.0)

After successfully doing above , I tried to build and run an example as you told i.e. ( e.g. the 'minimal' sample, was to cd to buildgtk/samples/minimal/ and then run 'make'.)
Now I am able to make and run.

But if I want to make my own new project suppose myapp.cpp anywhere in my system and want to compile it with wxWidget,then how can I do that?

Regards
Gunjan
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Hi!
gunjan wrote:But if I want to make my own new project suppose myapp.cpp anywhere in my system and want to compile it with wxWidget,then how can I do that?
If you did "make install" for wxWidgets it's quite simple: use wx-config.

Like
g++ -otest myapp.cpp `wx-config --libs --cxxflags`

Check wx-config options. It's quite a mighty script that allows you to skip between different wxWidgets versions (if installed) and choose debug and release libs.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
gunjan
Earned a small fee
Earned a small fee
Posts: 18
Joined: Wed Sep 22, 2010 8:34 am

Post by gunjan »

I tried
g++ -o test myapp.cpp `wx-config --libs --cxxflags`
but it didn't worked stating that -> g++ :wx-config --libs -cxxflags: No such file or directory.


where and how to check for wx-config option.

Regards
Gunjan
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

If you did 'make install' after you compiled wxGTK (assuming you configured without --prefix=<somewhere else>) then you installed to /usr/local/, and wx-config will be in /usr/local/bin. Perhaps that isn't in your PATH. Try using the full filepath to wx-config.

If you installed to somewhere else, then the same applies.

BTW, you can instead do, in your terminal:
PATH=/full/path/to/wherever/you/installed/wx-config/:$PATH
and then use g++ `wx-config --libs --cxxflags` <etc> as normal.
gunjan
Earned a small fee
Earned a small fee
Posts: 18
Joined: Wed Sep 22, 2010 8:34 am

Post by gunjan »

I am not able to track the location of wx-config --libs .
Yes I did 'make install' after compilation. I configured with gtk option. i.e. ./configure --with-gtk.

Also there is no /usr/local/ folder. So I am not able to set path.
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Also there is no /usr/local/ folder
Really? How strange: there is one on my fedora 9 virtualbox guest.

If its database is populated, the easiest way to find the installed wx-config is:
locate wx-config

If 'locate' complains, the slower alternative is to become root, then do:
find / -name wx-config

If it turns out that the only wx-config is the one in buildgtk/ then I suggest you configure again:
../configure --prefix=/usr
I think you'll not need to make clean, but can use the old build. su to root, make install and ldconfig. You should then have a working wx-config in your PATH.
gunjan
Earned a small fee
Earned a small fee
Posts: 18
Joined: Wed Sep 22, 2010 8:34 am

Post by gunjan »

I can see wx-config in /usr/local/bin of my fedora(previously i thought that it will be inside wxWidget folder) , but still if i use g++ myapp.cpp '/usr/local/bin/wx-config --libs --cxxflags' -o test. It is giving same error i.e. "g++:wx-config --libs --cxxflags: No such files or directory".
After this error other errors came for headers inclusion path like "myapp.cpp:6:20: error: wx/wx.h: No such file or directory"
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Earlier you wrote:
I tried
g++ -o test myapp.cpp `wx-config --libs --cxxflags`
but it didn't worked stating that -> g++ :wx-config --libs -cxxflags: No such file or directory.
This time you wrote:
but still if i use g++ myapp.cpp '/usr/local/bin/wx-config --libs --cxxflags' -o test. It is giving same error
You must use backticks:`...` not single-quotes:'...'. Backticks say: "Run this command and use the resulting output". So `wx-config --libs --cxxflags` will be replaced by the list of wx libraries and compilation flags.

If you still were using backticks, please post the output of doing (in a terminal, no backticks required):
wx-config --libs --cxxflags
gunjan
Earned a small fee
Earned a small fee
Posts: 18
Joined: Wed Sep 22, 2010 8:34 am

Post by gunjan »

I used backticks and able to compile successfullt and an exe is made. But when I ran the exe by command ./exename , it is giving error -> "error while loading shared libraries: libwx_gtk2u_xrc-2.9.so.1 :cannot open shared object file or directory"

Regards
Gunjan
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

I used backticks and able to compile successfullt and an exe is made.
Wow, did your app really take 18 days to build? ;)
But when I ran the exe by command ./exename , it is giving error -> "error while loading shared libraries: libwx_gtk2u_xrc-2.9.so.1 :cannot open shared object file or directory"
That's a standard problem with some distros, that don't look for shared libs in /usr/local/lib.

The quick answer is to do this in each terminal:

Code: Select all

export LD_LIBRARY_PATH=/usr/local/lib
./exename
A more permanent answer is to add:
export LD_LIBRARY_PATH=/usr/local/lib
to your ~/.bashrc
gunjan
Earned a small fee
Earned a small fee
Posts: 18
Joined: Wed Sep 22, 2010 8:34 am

Post by gunjan »

Thanks a lot David. My application is running now. :)
Thanks for a great help.

I turned up after 18 days as I was doing some other work. Sorry for that.

Regards
Gunjan
gunjan
Earned a small fee
Earned a small fee
Posts: 18
Joined: Wed Sep 22, 2010 8:34 am

Post by gunjan »

If I want to make exe in two steps. First make object and then link it. then how can i do this.

e.g. g++ -c test.cpp `/usr/local/bin/wx-config --libs --cxxflags` will generate test.o and now if i want to link it and make exe I will do g++ -o test test.o `/usr/local/bin/wx-config --libs --cxxflags`.
Is this correct or there is some more correcdt method of doing it.

Regards
Gunjan
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

You only need `wx-config --cxxflags` for the compiling stage, and you only need `wx-config --libs` for the linking stage.
Is this correct or there is some more correct method of doing it.
AFAIK it's correct, though I have little experience in using g++ direct from the commandline (most of the time nowadays there's a makefile). However you can easily find lots of information about g++ from the man page and internet.
Post Reply