Search code examples
c++macosclangwxwidgets

No such file errors when compiling "Hello, world!" wx-widgets app on macOS


I have installed wx-widgets on my Mac (macOS Big Sur) via Homebrew

brew install wxwidgets

But when I try to compile this or this Hello, World! example I get and errors

clang: error: no such file or directory: 'libexpat.tbd'
clang: error: no such file or directory: 'libz.tbd'
clang: error: no such file or directory: 'libiconv.tbd'

I use this command from wx-config documentation:

g++ `wx-config --cxxflags` -o HelloWorld HelloWorld.cpp `wx-config --libs`

Just what I am doing wrong?

wx-config --cflags output:

-I/usr/local/lib/wx/include/osx_cocoa-unicode-static-3.1 -I/usr/local/include/wx-3.1 -DWXUSINGDLL -D__WXOSX_COCOA__ -D__WXMAC__ -D__WXOSX__ -pthread

wx-config --libs output:

-L/usr/local/lib -pthread /usr/local/lib/libwx_osx_cocoau_xrc-3.1.a /usr/local/lib/libwx_osx_cocoau_qa-3.1.a /usr/local/lib/libwx_baseu_net-3.1.a /usr/local/lib/libwx_osx_cocoau_html-3.1.a /usr/local/lib/libwx_osx_cocoau_core-3.1.a /usr/local/lib/libwx_baseu_xml-3.1.a /usr/local/lib/libwx_baseu-3.1.a -lwx_osx_cocoau_core-3.1 -lwxjpeg-3.1 -lwxpng-3.1 -lwxtiff-3.1 -framework AudioToolbox -framework WebKit -lwx_baseu-3.1 libexpat.tbd libz.tbd -lwxregexu-3.1 libiconv.tbd -framework CoreFoundation -framework Security -framework Carbon -framework Cocoa -framework IOKit -framework QuartzCore```

Solution

  • I solved the issue by building wxwidgets from source. The command to build apps also need to be changed to

    g++ `full/path/to/wx-config ` -o HelloWorld HelloWorld.cpp `full/path/to/wx-config --libs`
    

    or

    g++ -o HelloWorld HelloWorld.cpp `full/path/to/wx-config --libs --cxxflags`