在 macOS 上编译 "Hello, world!" wx-widgets 应用程序时没有此类文件错误

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

我已经通过 Homebrew

在我的 Mac (macOS Big Sur) 上安装了 wx-widgets
brew install wxwidgets

但是当我尝试编译时 this or this 你好,世界!我得到的例子和错误

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'

我使用来自 wx-config documentation 的命令:

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

我哪里做错了?

wx-config --cflags 输出:

-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 输出:

-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```

我通过 building wxwidgets 从源代码解决了这个问题。 构建应用程序的命令也需要更改为

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

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