Fedora 无法找到 libSDL2main.so(并且不需要它):我可以为 Fedora 和 Ubuntu 使用一个 Makefile 吗?

Fedora can't find libSDL2main.so (and doesn't need it): can I use one Makefile for Fedora and Ubuntu?

在 Fedora 上,我的命令 g++ main.cpp sdl2-config --cflags -lSDL2main -lSDL2 认为 SLD2main 库不可用。没错:其他SDL2库在/usr/lib64libSDL2main.so 不是。

但我安装了所有明显相关的 SDL2 rpm。这是当我说 yum install SDL2:

时系统告诉我的内容
Package SDL2-2.0.12-1.fc32.x86_64 is already installed.
Package SDL2-devel-2.0.12-1.fc32.x86_64 is already installed.
Package SDL2_image-2.0.5-3.fc32.x86_64 is already installed.
Package SDL2_image-devel-2.0.5-3.fc32.x86_64 is already installed.
Package SDL2_mixer-2.0.4-5.fc32.x86_64 is already installed.
Package SDL2_mixer-devel-2.0.4-5.fc32.x86_64 is already installed.
Package SDL2_ttf-2.0.15-4.fc32.x86_64 is already installed.
Package SDL2_ttf-devel-2.0.15-4.fc32.x86_64 is already installed.

如果我去掉 g++ 选项 -lSDL2main,程序会链接并运行。

但这是一个问题。我希望我的 Makefile 通常可以在 Unix 系统上运行。我该怎么做——对 RedHat/Fedora 和 Debian/Ubuntu 使用相同的 Makefile?

您应该从 sdl2-config --libspkg-config sdl2 --libs 获取链接器标志。