Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Can't find wx header files but they are there.

  1. #1
    Join Date
    Jul 2010
    Beans
    18
    Distro
    Ubuntu 10.04 Lucid Lynx

    Can't find wx header files but they are there.

    Hey guys I am trying to build a sample program using wxWidgets but it can't find the header files.

    This is the output:

    Code:
    g++ -o myprg hworld.cpp `pkg-config wx-config --libs`
    Package wx-config was not found in the pkg-config search path.
    Perhaps you should add the directory containing `wx-config.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'wx-config' found
    hworld.cpp:5: fatal error: wx/wx.h: No such file or directory
    compilation terminated.
    make: *** [all] Error 1

    And this is my makefile:


    Code:
    SOURCES = hworld.cpp
    OBJS    = ${SOURCES:.c=.o}
    CFLAGS  = `pkg-config wx-config --cflags` -I /usr/include/wx-2.8
    LDADD   = `pkg-config wx-config --libs`
    CC      = g++
    PACKAGE = myprg
    
    all : ${OBJS}
    	${CC} -o ${PACKAGE} ${OBJS} ${LDADD}
    
    .c.o:
    	${CC} ${CFLAGS} -c $<

    Thanks so much!

  2. #2
    Join Date
    Sep 2009
    Beans
    1,293

    Re: Can't find wx header files but they are there.

    wx-config is used as a replacement for pkg-config
    Code:
    $ wx-config --cflags --libs
    -I/usr/lib/wx/include/base-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -DwxUSE_GUI=0 -pthread
    -pthread -Wl,-Bsymbolic-functions  -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8
    So,
    Code:
     $ g++ -o myprg hworld.cpp ` wx-config --cflags --libs`

  3. #3
    Join Date
    May 2006
    Beans
    1,787

    Re: Can't find wx header files but they are there.

    Quote Originally Posted by Yoshi65 View Post
    Hey guys I am trying to build a sample program using wxWidgets but it can't find the header files.

    This is the output:

    Code:
    g++ -o myprg hworld.cpp `pkg-config wx-config --libs`
    Package wx-config was not found in the pkg-config search path.
    Perhaps you should add the directory containing `wx-config.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'wx-config' found
    hworld.cpp:5: fatal error: wx/wx.h: No such file or directory
    compilation terminated.
    make: *** [all] Error 1

    And this is my makefile:


    Code:
    SOURCES = hworld.cpp
    OBJS    = ${SOURCES:.c=.o}
    CFLAGS  = `pkg-config wx-config --cflags` -I /usr/include/wx-2.8
    LDADD   = `pkg-config wx-config --libs`
    CC      = g++
    PACKAGE = myprg
    
    all : ${OBJS}
    	${CC} -o ${PACKAGE} ${OBJS} ${LDADD}
    
    .c.o:
    	${CC} ${CFLAGS} -c $<

    Thanks so much!
    1) Use just wx-config, not pkg-config with wx-config as an argument;
    2) First compile hworld.cpp to get hworld.o, using wx-config --cflags, then link hworld.o with the rest using wx-config --libs.

  4. #4
    Join Date
    Jul 2010
    Beans
    18
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Can't find wx header files but they are there.

    Okay thanks guys! That fixed that problem but it isn't finding the wx/wx.h header and it does the for the GTK+ header too. But both of them are there. Why is it not seeing both of the header files? I switched from GTK+ to wxWidgets because of this problem but I see it here too!

  5. #5
    Join Date
    May 2006
    Beans
    1,787

    Re: Can't find wx header files but they are there.

    Quote Originally Posted by Yoshi65 View Post
    Okay thanks guys! That fixed that problem but it isn't finding the wx/wx.h header and it does the for the GTK+ header too. But both of them are there. Why is it not seeing both of the header files? I switched from GTK+ to wxWidgets because of this problem but I see it here too!
    What does your compilation command look like now?

  6. #6
    Join Date
    Jul 2010
    Beans
    18
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Can't find wx header files but they are there.

    I have this makefile:


    Code:
    SOURCES = hworld.cpp
    OBJS    = ${SOURCES:.c=.o}
    CFLAGS  = `wx-config --cflags`
    LDADD   = `wx-config --libs`
    CC      = g++
    PACKAGE = myprg
    
    all : ${OBJS}
    	${CC} -o ${PACKAGE} ${OBJS} ${LDADD}
    
    .c.o:
    	${CC} ${CFLAGS} -c $<
    and then I just type make.

  7. #7
    Join Date
    May 2006
    Beans
    1,787

    Re: Can't find wx header files but they are there.

    Quote Originally Posted by Yoshi65 View Post
    I have this makefile:


    Code:
    SOURCES = hworld.cpp
    OBJS    = ${SOURCES:.c=.o}
    CFLAGS  = `wx-config --cflags`
    LDADD   = `wx-config --libs`
    CC      = g++
    PACKAGE = myprg
    
    all : ${OBJS}
    	${CC} -o ${PACKAGE} ${OBJS} ${LDADD}
    
    .c.o:
    	${CC} ${CFLAGS} -c $<
    and then I just type make.
    Fine, but it's the actual command that gets executed that I want to see. And, also, the output from wx-config --cflags.

  8. #8
    Join Date
    Jul 2010
    Beans
    18
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Can't find wx header files but they are there.

    This is what is executed:

    Code:
    g++ -o myprg hworld.cpp `wx-config --libs`
    hworld.cpp:5: fatal error: wx/wx.h: No such file or directory
    compilation terminated.
    make: *** [all] Error 1
    This is the output of wx-config --libs:

    Code:
    -L/usr/local/lib -pthread   -lwx_gtk2_richtext-2.8 -lwx_gtk2_aui-2.8 -lwx_gtk2_xrc-2.8 -lwx_gtk2_qa-2.8 -lwx_gtk2_html-2.8 -lwx_gtk2_adv-2.8 -lwx_gtk2_core-2.8 -lwx_base_xml-2.8 -lwx_base_net-2.8 -lwx_base-2.8

  9. #9
    Join Date
    Jul 2010
    Beans
    18
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Can't find wx header files but they are there.

    Sorry for the double post...
    I just saw you said wx-config --cflags but here is the output of that.

    Code:
    -I/usr/local/lib/wx/include/gtk2-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread

  10. #10
    Join Date
    May 2006
    Beans
    1,787

    Re: Can't find wx header files but they are there.

    Quote Originally Posted by Yoshi65 View Post
    Sorry for the double post...
    I just saw you said wx-config --cflags but here is the output of that.

    Code:
    -I/usr/local/lib/wx/include/gtk2-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread
    I think I see the error in the Makefile: you have .cpp source files but do

    OBJS = ${SOURCES:.c=.o}

    Do

    OBJS = ${SOURCES:.cpp=.o}

    instead, and then the building ought to follow the steps outlined in the first answers to your question. Maybe it even works, but if not, we will have a more correct compilation step.

Page 1 of 2 12 LastLast

Tags for this Thread

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
  •