我在ubuntu 12.04中遇到了一些问题。
我想在我的代码:: blocks project中使用SFML库。
在SFML文件夹中有两个子文件夹 - 包含和 lib 。 include包含头文件(.h文件)。 lib包含库文件(.so文件)。
我无法直接将库链接到我的项目,因为编译器找不到文件。
我在谷歌研究并发现我必须将sfml文件放在标准路径中,以便在代码块中正确链接它们。 那么我应该把这些文件放在哪个默认标准位置?
编辑:在进行了大量的谷歌搜索之后,我开始知道如何将标题和模块放在正确的标准位置。但是在编译和运行后(从代码块或从终端),这些未定义的引用错误即将来临: -
/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'
collect2: ld returned 1 exit status
答案 0 :(得分:0)
您可以将 include 文件夹的内容放在 / usr / include 或 / usr / local / include 中,以及 / usr / lib 或 / usr / local / lib
中的 lib 文件夹您还可以在编译代码时指定include和libraries路径。例如,如果您使用gcc
,则可以执行此操作:
gcc prog.c -oprog -I/path/to/include/folder -L/path/to/libraries/folder -lLibraryName.so