我下载了SFML,然后将其所有标头复制到usr / local / include /中,并将其所有库复制到usr / local / lib /中。
我要编译的桌面中有一个名为main.cpp的文件。
首先,我这样做:
g++ -c main.cpp
之后,当我尝试执行此操作时:-
g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
它给了我:-
/usr/local/lib/libsfml-window.so: undefined reference to `udev_device_get_action@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_list_entry_get_next@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_unref@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_list_entry_get_name@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_enumerate_unref@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_monitor_unref@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_new@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_monitor_receive_device@LIBUDEV_183'
/usr/local/lib/libsfml-graphics.so: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_device_get_devnode@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_monitor_enable_receiving@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_enumerate_new@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_monitor_get_fd@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_device_unref@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_device_get_property_value@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_monitor_filter_add_match_subsystem_devtype@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_enumerate_get_list_entry@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_enumerate_scan_devices@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_enumerate_add_match_subsystem@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_device_get_syspath@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_device_get_sysattr_value@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_monitor_new_from_netlink@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_device_new_from_syspath@LIBUDEV_183'
/usr/local/lib/libsfml-window.so: undefined reference to `udev_device_get_parent_with_subsystem_devtype@LIBUDEV_183'
我已经正确安装了所有这些必需的依赖项:
https://github.com/SFML/SFML/wiki/Tutorial%3A-Installing-SFML-dependencies
我错过了任何必要的步骤吗?
最佳答案
仅仅因为您已安装依赖项,并不意味着您正在使用它们。
undefined reference to `udev_device_get_action@LIBUDEV_183'
提到
udev
和LIBUDEV
告诉我,您需要链接到libudev。尝试将-ludev
添加到命令行。如果粘贴了所有链接错误,则实际上可以解决它。如果仅粘贴了前20个,则可能需要链接其他库。查看缺少的符号,找出它们来自哪个库,然后添加它们。
/usr/local/lib/libsfml-graphics.so: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20'
不知道有什么交易。您可能需要链接C ++库?
无论如何,您应该查看有关为SFML项目设置makefile的说明:https://github.com/SFML/SFML/wiki/Tutorial%3A-Build-your-SFML-project-with-CMake
关于c++ - 如何在ubuntu中安装SFML?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30696114/