【问题标题】:In ubuntu, where should I place these files?在 ubuntu 中,我应该将这些文件放在哪里?
【发布时间】:2015-08-21 04:57:56
【问题描述】:

我在 ubuntu 12.04 中遇到了一些问题。

我有想要在我的 code::blocks 项目中使用的 SFML 库。

在 SFML 文件夹中有两个子文件夹 - includelib。 include 包含头文件(.h 文件)。 lib 包含库文件(.so 文件)。

我无法直接将库与我的项目链接,因为编译器找不到文件。

我在 google 中进行了研究,发现我必须将 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

【问题讨论】:

    标签: ubuntu path sfml undefined-reference


    【解决方案1】:

    您可以将include文件夹的内容放在/usr/include/usr/local/include中, /usr/lib/usr/local/lib

    中的 lib 文件夹

    您还可以在编译代码时指定包含和库路径。例如,如果您使用gcc,您可以这样做:

    gcc prog.c -oprog -I/path/to/include/folder -L/path/to/libraries/folder -lLibraryName.so

    【讨论】:

    • /usr/include & /usr/local/include 都在那里。我可以把它们放在其中任何一个中吗?
    • @Raj 是的,这取决于编译器,它们中的大多数会同时查看这两个位置。
    • okey 所以我将include 复制到/usr/include 并将lib 复制到/usr/lib,但代码块仍然给出许多undefined reference 错误。我需要在代码块中做些什么吗?
    • @Raj 如果头文件在文件夹中,您可能必须更改代码中的#include 语句,例如:如果头文件在/usr/include/newHeaders 文件夹中,请使用#include "newHeaders/header.h"
    • 我查过了。 include 文件夹包含另一个名为 SFML 的文件夹,其中包含头文件。因此,在我在代码块中的 main.cpp 文件中执行此操作后: #include 并显示: fatal error: SFML/Graphics.hpp: No such file或目录
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-26
    • 2010-12-01
    • 2018-09-28
    • 2019-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多