小编agr*_*l-d的帖子

当 C++ 没有稳定的 ABI 时,为什么可以链接到 C++ 动态库?

以 Boost 为例,boost::filesystem当 C++ 没有稳定的 ABI 时,为什么我能够从我的 C++ 程序进行链接。

我的系统中安装了 Boost,并且玩具程序能够使用 进行链接-lboost_filesystem,即使boost::filesystem公开了 C++ API(没有 extern 'C' )。

那么,是否可以创建可以被各种编译器版本链接的C++共享库呢?Boost 如何在没有“extern C”的情况下实现这一目标?

我试过:

#include <iostream>
#include <boost/filesystem.hpp>

namespace fs = boost::filesystem;

int main() {
    // Replace "/path/to/directory" with the path to the directory you want to list
    std::string directory_path = "/path/to/directory";

    try {
        // Check if the given path exists and is a directory
        if (fs::exists(directory_path) && fs::is_directory(directory_path)) {
            std::cout << "Listing files in directory: " …
Run Code Online (Sandbox Code Playgroud)

c++ boost ffi abi

4
推荐指数
1
解决办法
105
查看次数

标签 统计

abi ×1

boost ×1

c++ ×1

ffi ×1