3

I have just installed the latest stable version of wxWidget on my mac and tried to compile the code from the hello world tutorial. This is the code that is causing the error:

#include <wx/wxprec.h>'
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

My compiler throws the following warning:

hello_world.cpp:4:10: fatal error: 'wx/wxprec.h' file not found
#include <wx/wxprec.h>
         ^~~~~~~~~~~~~
1 error generated.

I have checked the directory where I installed wxMac and the file wxprec.h exists in the "include" sub-directory.

If anyone knows why the file cannot be found even though it exists please let me know.

RedKnite
  • 1,525
  • 13
  • 26
polar
  • 194
  • 1
  • 15
  • 1
    Does this question answer you question? https://stackoverflow.com/questions/134029/wxwidgets-setup-h-no-such-file?rq=1 – RedKnite May 24 '20 at 19:51
  • 1
    @polar, which version of library do you try to use? Did you build it yourself? Can you build the mininmal sample found inside wxWidgets? – Igor May 24 '20 at 20:49
  • @RedKnite, those are not related. – Igor May 24 '20 at 20:50
  • @Igor I used homebrew to install the version 3.0.5.1 – polar May 24 '20 at 23:30
  • 1
    @polar, how do you try to build it? Can you post the Makefile you use? Or if its too big - what command is generated/printed on the screen when you issue `make`? Also, question remains - can you try to build the `minimal` sample? – Igor May 25 '20 at 04:59

1 Answers1

2

I found out the answer to this problem. To fix it I used the following line to compile/build the hello world app:

g++ `wx-config --cxxflags` -o out *.cpp `wx-config --libs`

after doing this it was only a matter of sorting out the linking, adding header guards and adding in

IMPLEMENT_APP(MyApp)

and

DECLARE_APP(MyApp)

in MyApp.h and MyApp.cpp respectively which functions as the main function.

I got this information from https://wiki.wxwidgets.org/Hello_World

polar
  • 194
  • 1
  • 15
  • Is this made in a designer, or in pure code? If this is made in pure code, so you mind telling me where IMPLEMENT_APP and DECLARE_APP are, thank you – crjase Oct 27 '22 at 04:30