c - 用 SDL2 编译我的项目得到链接错误
问题描述
我用 SDL2 编写了一个小项目当我在我的 Macbook Pro 上编译时,我得到了链接错误:
Undefined symbols for architecture x86_64:
"_HIDAPI_IsDevicePresent", referenced from:
_GetDeviceInfo in SDL_sysjoystick.c.o
"_HIDAPI_UpdateDevices", referenced from:
_SDL_JoystickUpdate_REAL in SDL_joystick.c.o
"_METAL_RenderDriver", referenced from:
_render_drivers in SDL_render.c.o
"_SDL_HIDAPI_JoystickDriver", referenced from:
_SDL_joystick_drivers in SDL_joystick.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libs/SDL2/libSDL2-2.0d.dylib] Error 1
make[1]: *** [libs/SDL2/CMakeFiles/SDL2.dir/all] Error 2
make: *** [all] Error 2
我的系统信息
macOS 10.15.4 (19E287)
我的项目源代码
https://github.com/yangruihan/libray
非常感谢!:)
所有构建日志
--
-- SDL2 was configured with the following options:
--
-- Platform: Darwin-19.4.0
-- 64-bit: TRUE
-- Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
--
-- Subsystems:
-- Atomic: ON
-- Audio: ON
-- Video: ON
-- Render: ON
-- Events: ON
-- Joystick: ON
-- Haptic: ON
-- Power: ON
-- Threads: ON
-- Timers: ON
-- File: ON
-- Loadso: ON
-- CPUinfo: ON
-- Filesystem: ON
-- Dlopen: ON
-- Sensor: ON
--
-- Options:
-- 3DNOW (Wanted: ON): ON
-- ALSA (Wanted: OFF): OFF
-- ALSA_SHARED (Wanted: OFF): OFF
-- ALTIVEC (Wanted: ON): OFF
-- ARMNEON (Wanted: ON): OFF
-- ARMSIMD (Wanted: ON): OFF
-- ARTS (Wanted: OFF): OFF
-- ARTS_SHARED (Wanted: OFF): OFF
-- ASSEMBLY (Wanted: ON): ON
-- ASSERTIONS (Wanted: auto): auto
-- BACKGROUNDING_SIGNAL (Wanted: OFF): OFF
-- CLOCK_GETTIME (Wanted: OFF): OFF
-- DIRECTFB_SHARED (Wanted: OFF): OFF
-- DIRECTX (Wanted: OFF): OFF
-- DISKAUDIO (Wanted: ON): ON
-- DUMMYAUDIO (Wanted: ON): ON
-- ESD (Wanted: OFF): OFF
-- ESD_SHARED (Wanted: OFF): OFF
-- FOREGROUNDING_SIGNAL (Wanted: OFF): OFF
-- FUSIONSOUND (Wanted: OFF): OFF
-- FUSIONSOUND_SHARED (Wanted: OFF): OFF
-- GCC_ATOMICS (Wanted: ON): ON
-- HIDAPI (Wanted: OFF): OFF
-- INPUT_TSLIB (Wanted: OFF): OFF
-- JACK (Wanted: OFF): OFF
-- JACK_SHARED (Wanted: OFF): OFF
-- KMSDRM_SHARED (Wanted: OFF): OFF
-- LIBC (Wanted: ON): ON
-- LIBSAMPLERATE (Wanted: OFF): OFF
-- LIBSAMPLERATE_SHARED (Wanted: OFF): OFF
-- MMX (Wanted: ON): ON
-- NAS (Wanted: OFF): OFF
-- NAS_SHARED (Wanted: OFF): OFF
-- OSS (Wanted: OFF): OFF
-- PTHREADS (Wanted: ON): ON
-- PTHREADS_SEM (Wanted: ON): ON
-- PULSEAUDIO (Wanted: OFF): OFF
-- PULSEAUDIO_SHARED (Wanted: OFF): OFF
-- RENDER_D3D (Wanted: OFF): OFF
-- RENDER_METAL (Wanted: 0): OFF
-- RPATH (Wanted: OFF): OFF
-- SDL_DLOPEN (Wanted: ON): ON
-- SDL_STATIC_PIC (Wanted: OFF): OFF
-- SDL_TEST (Wanted: OFF): OFF
-- SNDIO (Wanted: OFF): OFF
-- SSE (Wanted: ON): ON
-- SSE2 (Wanted: ON): ON
-- SSE3 (Wanted: ON): ON
-- SSEMATH (Wanted: ON): OFF
-- VIDEO_COCOA (Wanted: ON): ON
-- VIDEO_DIRECTFB (Wanted: OFF): OFF
-- VIDEO_DUMMY (Wanted: ON): ON
-- VIDEO_KMSDRM (Wanted: OFF): OFF
-- VIDEO_METAL (Wanted: 0): OFF
-- VIDEO_OFFSCREEN (Wanted: OFF): OFF
-- VIDEO_OPENGL (Wanted: ON): ON
-- VIDEO_OPENGLES (Wanted: ON): ON
-- VIDEO_RPI (Wanted: OFF): OFF
-- VIDEO_VIVANTE (Wanted: OFF): OFF
-- VIDEO_VULKAN (Wanted: 0): OFF
-- VIDEO_WAYLAND (Wanted: OFF): OFF
-- VIDEO_WAYLAND_QT_TOUCH (Wanted: OFF): OFF
-- VIDEO_X11 (Wanted: OFF): OFF
-- VIDEO_X11_XCURSOR (Wanted: OFF): OFF
-- VIDEO_X11_XINERAMA (Wanted: OFF): OFF
-- VIDEO_X11_XINPUT (Wanted: OFF): OFF
-- VIDEO_X11_XRANDR (Wanted: OFF): OFF
-- VIDEO_X11_XSCRNSAVER (Wanted: OFF): OFF
-- VIDEO_X11_XSHAPE (Wanted: OFF): OFF
-- VIDEO_X11_XVM (Wanted: OFF): OFF
-- WASAPI (Wanted: OFF): OFF
-- WAYLAND_SHARED (Wanted: OFF): OFF
-- X11_SHARED (Wanted: OFF): OFF
--
-- CFLAGS: -idirafter /Volumes/SSD/Personal/workspace/libray/libs/SDL2/src/video/khronos
-- EXTRA_CFLAGS: -D_THREAD_SAFE -msse3 -msse2 -msse -m3dnow -mmmx -Wshadow -fvisibility=hidden -Wdeclaration-after-statement -Werror=declaration-after-statement -fno-strict-aliasing -Wall
-- EXTRA_LDFLAGS: -Wl,-undefined,error;-Wl,-compatibility_version,1.0.0;-Wl,-current_version,12.0.0
-- EXTRA_LIBS: m;iconv;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreVideo.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Cocoa.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/IOKit.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/ForceFeedback.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Carbon.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreAudio.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AudioToolbox.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AVFoundation.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework
--
-- Build Shared Library: ON
-- Build Static Library: OFF
--
-- If something was not detected, although the libraries
-- were installed, then make sure you have set the
-- CFLAGS and LDFLAGS environment variables correctly.
--
Writing version header for v0.12.0
Using Apple defaults.
Using bundled version of GLEW
-- Checking for module 'libstbi'
-- No package 'libstbi' found
Using bundled version of stb-image
-- Checking for module 'libstbi_write'
-- No package 'libstbi_write' found
Using bundled version of stb-image-write
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Configuring done
CMake Warning (dev):
Policy CMP0068 is not set: RPATH settings on macOS do not affect
install_name. Run "cmake --help-policy CMP0068" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
For compatibility with older versions of CMake, the install_name fields for
the following targets are still affected by RPATH settings:
SDL_gpu_shared
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done
-- Build files have been written to: /Volumes/SSD/Personal/workspace/libray/build/CMake/Debug
[ 1%] Built target SDL2main
[ 16%] Built target Lua
[ 17%] Linking C shared library libSDL2-2.0d.dylib
Undefined symbols for architecture x86_64:
"_HIDAPI_IsDevicePresent", referenced from:
_GetDeviceInfo in SDL_sysjoystick.c.o
"_HIDAPI_UpdateDevices", referenced from:
_SDL_JoystickUpdate_REAL in SDL_joystick.c.o
"_METAL_RenderDriver", referenced from:
_render_drivers in SDL_render.c.o
"_SDL_HIDAPI_JoystickDriver", referenced from:
_SDL_joystick_drivers in SDL_joystick.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libs/SDL2/libSDL2-2.0d.dylib] Error 1
make[1]: *** [libs/SDL2/CMakeFiles/SDL2.dir/all] Error 2
make: *** [all] Error 2
解决方案
推荐阅读
- excel-formula - 想要一个 Excel 2007 公式来执行我的问题
- ansible - 使用 Ansible 访问 LXC 容器
- python - Kivy 从 Windows 服务打开时抛出 Open GL 错误
- linux - 在新版本的 GCC 上编译 Linux 内核 2.6 时出错
- vuejs3 - 如何在 Vue.js 3 中访问动态 ref 标记的 html 元素?
- javascript - 使用 javascript 指令填写转推
- react-native - 如何使用当前状态的路由将 SwitchNavigator 行为与 react-navigation 5 结合使用
- sql - 如何显示没有数据的其余时间段(使用分组和计数) - SQL
- rust - 无法使用 Rust 从 BBC microbit 上的加速度计读取
- powerbi - 当数据集使用 R 脚本时,在 Power BI 服务中保持数据刷新