LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 01-18-2006, 08:04 PM   #1
Mezzanine
LQ Newbie
 
Registered: Jan 2006
Posts: 19

Rep: Reputation: 0
Compiling Programs with wxWidgets


I used to program PHP for quite a while, and I am trying to break into the world of machine programming...but darn it's hard. Anyways, I am trying to compile a program using wxWidgets in C (I know a bit of C from programming PHP in the past but for the most part I'm just learning it catch-as-catch-can). When I try to compile, with GCC, I get an error saying it cannot find the wx.h include (code: #include <wx/wx.h>). My wx.h file is located in /usr/local/include/wx-2.6/wx/wx.h. I imagine this is just a stupid mistake on my part but I have not been able to figure it out. I successfully installed wxWidgets with no errors. I run on 64 bit Fedora Core 4. Can anyone help me with this?
 
Old 01-18-2006, 09:00 PM   #2
smallville
Member
 
Registered: Dec 2005
Posts: 44

Rep: Reputation: 15
instead of this one
#include <wx/wx.h

try this
#include <wx-2.6/wx/wx.h>
 
Old 01-18-2006, 09:16 PM   #3
Mezzanine
LQ Newbie
 
Registered: Jan 2006
Posts: 19

Original Poster
Rep: Reputation: 0
I tried that, and I get a long series of errors saying that a number of other include files aren't there...and yet they are.

In file included from testspace.c:23:
/usr/local/include/wx-2.6/wx/wx.h:15:21: error: wx/defs.h: No such file or directory
/usr/local/include/wx-2.6/wx/wx.h:16:23: error: wx/object.h: No such file or directory
/usr/local/include/wx-2.6/wx/wx.h:17:25: error: wx/dynarray.h: No such file or directory
/usr/local/include/wx-2.6/wx/wx.h:18:21: error: wx/list.h: No such file or directory
/usr/local/include/wx-2.6/wx/wx.h:19:21: error: wx/hash.h: No such file or directory
/usr/local/include/wx-2.6/wx/wx.h:20:23: error: wx/string.h: No such file or directory
/usr/local/include/wx-2.6/wx/wx.h:21:21: error: wx/intl.h: No such file or directory
/usr/local/include/wx-2.6/wx/wx.h:22:20: error: wx/log.h: No such file or directory
/usr/local/include/wx-2.6/wx/wx.h:23:22: error: wx/event.h: No such file or directory
/usr/local/include/wx-2.6/wx/wx.h:24:20: error: wx/app.h: No such file or directory
/usr/local/include/wx-2.6/wx/wx.h:25:22: error: wx/utils.h: No such file or directory
/usr/local/include/wx-2.6/wx/wx.h:26:23: error: wx/stream.h: No such file or directory

...Now I'm assuming that each and every include within that include would have to be changed to that directory in the same way... Could it just be that I have to switch this wx folder to a different directory for GCC to pick up on the includes automatically?
 
Old 01-18-2006, 10:28 PM   #4
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
are you running gcc with somthing like this?
Code:
gcc -I/usr/local/include/wx-2.6 yourfile.c
the -I specifies additional header locations..
 
Old 01-18-2006, 11:40 PM   #5
Mezzanine
LQ Newbie
 
Registered: Jan 2006
Posts: 19

Original Poster
Rep: Reputation: 0
I get the same string of errors even with the -I command.
 
Old 01-19-2006, 10:42 AM   #6
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
this is what i have to use outside of kdevelop to compile..
Code:
g++ `wx-config --libs --cxxflags` wxtest.cpp
my headers are in /usr/local/include/wx-2.6 and i have a symlink wx to the wx-2.6 dir in there also

i have never seen a wx program written in straight C.. since you have to derive from the wxApp class i dont know if it is possible.. though i have not done very much with wx so i only know a little..

hope it helps a little..
 
Old 01-19-2006, 05:10 PM   #7
Mezzanine
LQ Newbie
 
Registered: Jan 2006
Posts: 19

Original Poster
Rep: Reputation: 0
Those commands work perfectly. Thanks, xhi. But now I get the error: ./a.out: error while loading shared libraries: libwx_gtk2_xrc-2.6.so.0: cannot open shared object file: No such file or directory

Yet, libwx_gtk2_xrc-2.6.so.0 is there, located in /usr/local/lib

Any ideas?
 
Old 01-19-2006, 10:26 PM   #8
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
hmmm..

maybe check the permissions on the libs..

also make sure they are being loaded.. try somthing like this..
Code:
% ldconfig -p | grep wx_gtk
to make sure that the libs available for runtime.. see what you get..
 
Old 01-20-2006, 04:08 AM   #9
Mezzanine
LQ Newbie
 
Registered: Jan 2006
Posts: 19

Original Poster
Rep: Reputation: 0
I've sort of figured it out, it seems to be another distro problem. The libraries are not linked properly, and Fedora definitely does not want me to link them properly. Using ldconfig on installation seems to have done absolutely nothing, and no matter how many reinstallations I try it's just not going to happen. Not to mention, Fedora won't let me uninstall it! make uninstall doesn't work! GRR! Is there any way to manually link the libraries?
 
Old 01-20-2006, 08:32 AM   #10
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
so they are not showing up in ldconfig -p
 
Old 01-20-2006, 01:57 PM   #11
Mezzanine
LQ Newbie
 
Registered: Jan 2006
Posts: 19

Original Poster
Rep: Reputation: 0
No, ldconfig does not seem to show it.
 
Old 01-20-2006, 02:06 PM   #12
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
what are the permissions on the libs in /usr/local/lib
and also whats the contents of /etc/ld.so.conf
 
Old 01-20-2006, 02:20 PM   #13
Mezzanine
LQ Newbie
 
Registered: Jan 2006
Posts: 19

Original Poster
Rep: Reputation: 0
My permissions are set to 755 and I've been doing all this from root. /etc/ld.so.conf only has a link to include ld.so.conf.d/*.conf --I tried editing ld.so.conf to include that WX library, and then ran ldconfig. Nothing happened. Within folder /etc/ld.so.conf.d, which ld.so.conf links to, there's 5 small .conf files for MySQL, QT and Xorg (all containing a single library link, for example, /usr/X11R6/lib)
 
Old 01-20-2006, 02:28 PM   #14
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
ok i guess there are some differences to how ld is setup between slackware and your distro ??

/etc/ld.so.conf is where ldconfig finds lib locations to add libs to the cache so that they can be linked at runtime..
look through those files and see if /usr/local/lib is anywhere to be found.. if not try to put in a line like
/usr/local/lib
at the top of /etc/ld.so.conf

then run

ldconfig
 
Old 01-20-2006, 03:03 PM   #15
Mezzanine
LQ Newbie
 
Registered: Jan 2006
Posts: 19

Original Poster
Rep: Reputation: 0
It worked! Perfectly! Thanks a million, xhi. This really taught me alot about Linux.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling Programs Thorrn4 Linux - Software 6 03-26-2005 12:25 AM
Compiling C++ programs rchillal Linux - Newbie 13 02-08-2005 05:27 AM
Compiling Programs mike35 Linux - Newbie 2 10-22-2003 09:39 AM
compiling programs disorderly Linux - Newbie 2 10-17-2003 12:48 PM
Compiling Programs Jabber63 Linux - Software 3 08-06-2003 02:58 AM


All times are GMT -5. The time now is 08:43 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration