【问题标题】:Linking to lib on Linux without headers在没有头文件的情况下链接到 Linux 上的 lib
【发布时间】:2021-12-28 06:33:24
【问题描述】:

您好,我正在尝试链接到没有标题的库。我完全按照库中的定义编写了原型,但 ld 无法链接它。

readelf -Ws 发布/libcef.so | grep KeyStringToDomKey

386822: 00000000066d73d0 328 FUNC LOCAL HIDDEN 17 _ZN2ui16KeycodeConverter17KeyStringToDomKeyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE

readelf -Ws main-6cf4e2.o | grep KeyStringToDomKey

 13: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND _ZN2ui16KeycodeConverter17KeyStringToDomKeyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE
#include <iostream>
#include <string>
#include "domkey.h"

namespace ui {
    class KeycodeConverter {
    public:
        static DomKey KeyStringToDomKey(const std::string&);
    };
}

using namespace std;

int main()
{
    auto t = ui::KeycodeConverter::KeyStringToDomKey("t");
    cout << "Hello World!" << endl;
    return 0;
}

【问题讨论】:

  • 链接到没有标题的库你是什么意思?

标签: c++ linux linkage


【解决方案1】:

386822: 00000000066d73d0 328 FUNC LOCAL HIDDEN 17 _ZN2u...

HIDDEN 是这里的:这个符号在共享库之外是不可见的(静态链接器/usr/bin/ld 和动态加载器都不可见) .

【讨论】:

    猜你喜欢
    • 2021-06-07
    • 2023-04-07
    • 2018-02-12
    • 1970-01-01
    • 2013-05-23
    • 2012-10-05
    • 2012-07-25
    • 1970-01-01
    • 2013-11-07
    相关资源
    最近更新 更多