Results 1 to 6 of 6

Thread: C++ wx/wx.h No such file

  1. #1
    Join Date
    May 2006
    Location
    CT, USA
    Beans
    151

    C++ wx/wx.h No such file

    I am JUST learning C++ because I need to write a cross-platform application. I decided to go with the wxWidgets library and am trying to get a very simple program to compile. I come from C#, so #include and all that other C++ stuff scares me. I am very new so I will need some hand-holding

    This is the application I have so far:
    Code:
    #include "wx/wx.h"
    
    int main(int argc, char **argv)
    {
        wxPuts(wxT("A console application"));
    }
    I have build-essential, libwxbase2.8-0, libwxbase2.8-dev, wx-common, wx2.8-headers, libwxgtk2.8-0, libwxgtk2.8-dev installed but I'm getting the following error:
    Code:
    g++ console.cpp -o console
    
    console.cpp:1:19: error: wx/wx.h: No such file or directory
    console.cpp: In function ‘int main(int, char**)’:
    console.cpp:5: error: ‘wxT’ was not declared in this scope
    console.cpp:5: error: ‘wxPuts’ was not declared in this scope
    I don't really know how to use g++, I was using Code:Blocks (because I thought it would help me to learn since I'm used to IDE's) and it was having the same issue, so I've been trying a few commands I found after Googling the problem.

    I tried this command I found from an earlier post Here:
    Code:
    g++ console.cpp 'wx-config --libs' 'wx-config --cxxflags' -o console
    And no luck. I also tried copying everything from /usr/include/wx-2.8/wx into it's own wx folder in the same folder as the cpp file. I also tried using #include <wx2.8/wx/wx.h> instead, but then all of it's #includes give me "No such file or directory" errors.

    Remember, I have no idea what I'm doing when it comes to C++...so if you have any tips for someone trying to learn C++ I would appreciate that as well. Thanks for any help you can give me.

  2. #2
    Join Date
    Aug 2005
    Location
    Fargo, ND, USA
    Beans
    1,499
    Distro
    Kubuntu 10.04 Lucid Lynx

    Re: C++ wx/wx.h No such file

    You need the -dev package to build programs. I don't know if this is all you need, by you definately need it.
    Code:
    sudo aptitude install wx2.8-headers libwxbase2.8-dev
    Then, make sure you can run wx-config. I can't figure out what package it's in.
    Code:
    wx-config --help
    Finally, you need backticks (`) not single quotes ('). An alternative syntax is '$()'. It takes the quoted expression, tries to run it as a command, and replaces the quoted expression with the output of the command.
    Code:
    g++ console.cpp `wx-config --libs` `wx-config --cxxflags` -o console
    Help yourself: Search the community docs or try other resources.
    Quote Originally Posted by Henry Spencer
    Those who do not understand Unix are condemned to reinvent it, poorly.
    Let science use your computer when you aren't: Folding@Home.

  3. #3
    Join Date
    May 2006
    Location
    CT, USA
    Beans
    151

    Re: C++ wx/wx.h No such file

    I already had the needed packages installed and I was able to run wx-config. It was the backticks. That's so strange and certainly not mentioned in any tutorial.

    This leads me to other questions (hope you don't mind answering):
    • Is g++ the right thing to be using?
    • If so, is there a way to make this work without the extra commands?

  4. #4
    Join Date
    May 2008
    Beans
    Hidden!

    Re: C++ wx/wx.h No such file

    G++ is the C++ compiler, so yes. You've avoided a lot of confusion by not using gcc.

    The backticks are shell syntax. Basically it means, "Run this command and substitute the output here". So wx-config prints out installation information in a format that GCC accepts as compilation flags.

    Set up a build system (I like SCons personally) to do it all automatically.

  5. #5
    Join Date
    May 2006
    Location
    CT, USA
    Beans
    151

    Re: C++ wx/wx.h No such file

    Is there a good way to do this using Code:Blocks? I suppose I could do all this using the CLI, but I'd like to get the IDE working as well.

  6. #6
    Join Date
    May 2008
    Beans
    Hidden!

    Re: C++ wx/wx.h No such file

    With Code::Blocks, the only way I know of is to get the output of wx-config and insert the values into the appropriate fields manually.

    I haven't used it in a while, however this should work.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •