AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题

问题[c++](unix)

Martin Hope
ashok449
Asked: 2024-07-24 18:50:16 +0800 CST

libwebsockets api 中的文件服务响应中缺少 http 标头 Content-Disposition

  • 5

我正在使用 libwebsockets 库来实现 https 服务器。以下是通过 HTTPS 提供文件的代码,但我收到的 HTTPS 响应没有标头变量

Content-Disposition:attachment; filename=logs.zip

并在响应主体中收到文件的内容!

我这里遗漏了什么吗?我希望添加Content-Disposition将使浏览器客户端能够下载文件。

这是我的坐骑:

struct lws_http_mount mount = {
    /* .mount_next */               NULL,               /* linked-list "next" */
    /* .mountpoint */               "/",                /* mountpoint URL */
    /* .origin */                   "var/www/",     /* serve from dir */
    /* .def */                      NULL,               /* default filename */
    /* .protocol */                 NULL,
    /* .cgienv */                   NULL,
    /* .extra_mimetypes */          "application/zip", //NULL,
    /* .interpret */                NULL,
    /* .cgi_timeout */              0,
    /* .cache_max_age */            0,
    /* .auth_mask */                0,
    /* .cache_reusable */           0,
    /* .cache_revalidate */         0,
    /* .cache_intermediaries */     0,
    /* .origin_protocol */          LWSMPRO_FILE,       /* files in a dir */
    /* .mountpoint_len */           1,                  /* char count */
    /* .basic_auth_login_file */    NULL,
};


    if (lws_serve_http_file(wsi, "/tmp/log.zip", "application/zip", NULL, 0) < 0) {
        lwsl_err("Failed to serve file: %s\n", "/tmp/log.zp");
        lws_return_http_status(wsi, HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL);
        return ;
    }

以下是响应标头 http 的 postman 响应

感谢您的支持

c++
  • 1 个回答
  • 28 Views
Martin Hope
Vishal Sharma
Asked: 2022-01-25 21:30:36 +0800 CST

从给定的共享库中找出代码中使用的函数/变量

  • 0

我正在分析 linux 平台(redhat)上的一个大型 C++ 项目,特别是其中使用的共享库。如何从特定的共享库中找到该项目中使用了哪些符号(函数/变量)?

首先,我在我的二进制文件上运行了以下命令:

readelf -d binaryName | grep -i "Shared library"

我得到了在我的项目中使用的共享库列表(ldd 显示更长的列表,因为这些共享库也有自己的依赖项)例如

 0x0000000000000001 (NEEDED)             Shared library: [librt.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libuv.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libssl.so.1.1]
 0x0000000000000001 (NEEDED)             Shared library: [libcrypto.so.1.1]
 0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

现在有一种方法可以找出libuv.so.1项目代码库中使用了哪些符号。任何人都可以提出一些路线图吗?

linux c++
  • 2 个回答
  • 732 Views
Martin Hope
itsKia2
Asked: 2021-11-03 05:13:39 +0800 CST

GCC 和 Clang 无法编译 C++ 代码

  • 1

尝试运行命令gcc code.cpp -o runthis

但是它给了我这种格式的错误:

/usr/bin/ld: /tmp/cco6J3Vh.o: warning: relocation against `_ZSt4cout' in read-only section `.text'
/usr/bin/ld: /tmp/cco6J3Vh.o: in function `main':
code.cpp:(.text+0x28): undefined reference to `std::cout'
/usr/bin/ld: code.cpp:(.text+0x30): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/bin/ld: code.cpp:(.text+0x3e): undefined reference to `std::cin'
/usr/bin/ld: code.cpp:(.text+0x46): undefined reference to `std::istream::operator>>(int&)'
/usr/bin/ld: code.cpp:(.text+0x9e): undefined reference to `std::cout'
/usr/bin/ld: code.cpp:(.text+0xa6): undefined reference to `std::ostream::operator<<(int)'
/usr/bin/ld: code.cpp:(.text+0xbb): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/bin/ld: code.cpp:(.text+0xc9): undefined reference to `std::cout'
/usr/bin/ld: code.cpp:(.text+0xd1): undefined reference to `std::ostream::operator<<(int)'
/usr/bin/ld: code.cpp:(.text+0xe6): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/bin/ld: /tmp/cco6J3Vh.o: in function `__static_initialization_and_destruction_0(int, int)':
code.cpp:(.text+0x12d): undefined reference to `std::ios_base::Init::Init()'
/usr/bin/ld: code.cpp:(.text+0x148): undefined reference to `std::ios_base::Init::~Init()'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status

从网上查看,这似乎是一个链接器问题。我在 Arch Linux 上。Clang 给了我与 gcc 相同的错误,但是我可以使用 c++ 进行编译。任何帮助表示赞赏

c++ cpp
  • 1 个回答
  • 1201 Views
Martin Hope
Vishal Sharma
Asked: 2019-12-11 23:59:12 +0800 CST

跨不同主要和次要版本的库稳定性

  • 0

我正在使用我在RHEL AB上的 C++ 代码构建一个共享库(主要版本是 A,次要版本是 B)。

在以下多少种情况下,当我将共享库从RHEL AB复制到:

我想知道这个共享库

  1. RHEL AC,其中 C<B。
  2. RHEL AC,其中 C>B。
  3. RHEL DB,其中 D>A
  4. RHEL DB,其中 D<A。

如果可能,请让我参考相关文档以获取更多信息。

请注意,我的 C++ 代码没有任何依赖关系,即当我在 RHEL AB 上构建它时,我没有将它与任何外部库链接

rhel c++
  • 1 个回答
  • 98 Views
Martin Hope
Jeremiah Perdue
Asked: 2019-11-26 06:33:23 +0800 CST

如何在 chromebook 上使用 Linux 在 root 中显示图形?

  • 1

我对 Linux 非常陌生,我正在使用 Chromebook 的 Linux 测试版,我相信它是 ubuntu。我正在尝试使用 CERN 的根软件来显示一个函数的图表,但是当它试图给我实际的图表时它给了我一个巨大的错误。我的语法是正确的我只是不知道如何让 Chromebook 让 Linux 向我显示图形。

这是我输入的代码

f = new TF1("f","x^2",-2,2)
f->Draw()

这是错误消息的链接

https://paste.ubuntu.com/p/FyMb4yvB8X/

根使用 C++

如果您想知道我是如何安装 ROOT 的,我在 30.4 下使用了本指南

https://root.cern.ch/root/html534/guides/users-guide/InstallandBuild.html#installing-precompiled-binaries

我从此页面下载了 ROOT 先决条件

https://root.cern.ch/build-prerequisites

然后我用它来启动它

. <pathname>/root/bin/thisroot.sh
root
ubuntu c++
  • 1 个回答
  • 176 Views
Martin Hope
rranjik
Asked: 2018-11-26 14:23:40 +0800 CST

在 Windows 上为 Linux 开发 Mozilla Firefox

  • 0

我想为 Mozilla Firefox 做出一些贡献(用我知道的一点点 C++)。我可以使用 WSL(适用于 Linux 的 Windows 子系统)构建、运行和调试适用于 Linux 的 Firefox 吗?如果是,我应该为此安装任何特定的东西(例如:Window 系统)吗?

firefox c++
  • 1 个回答
  • 52 Views
Martin Hope
Adam Sperry
Asked: 2018-11-19 21:26:07 +0800 CST

为什么 /usr/include 中有多个头文件副本?

  • 6

我一直在浏览我的 /usr/include 文件夹,试图熟悉布局,我注意到头文件有多个副本(至少按名称,我实际上并没有区分它们是否准确副本)在 /usr/include 的几个子目录中找到。对于标准 C 和 C++ 头文件以及 POSIX/LSB 标准头文件尤其如此。

一些示例包括(注意 ./ 指的是 /usr/include):

./asm-generic/unistd.h
./linux/unistd.h
./unistd.h
./x86_64-linux-gnu/sys/unistd.h
./x86_64-linux-gnu/bits/unistd.h
./x86_64-linux-gnu/asm/unistd.h

./stdlib.h
./x86_64-linux-gnu/bits/stdlib.h
./c++/7/stdlib.h
./c++/7/tr1/stdlib.h

./c++/7/cmath
./c++/7/ext/cmath
./c++/7/tr1/cmath

./asm-generic/termios.h
./linux/termios.h
./x86_64-linux-gnu/sys/termios.h
./x86_64-linux-gnu/bits/termios.h
./x86_64-linux-gnu/asm/termios.h
./termios.h

./linux/time.h
./time.h
./x86_64-linux-gnu/sys/time.h
./x86_64-linux-gnu/bits/time.h

为什么是这样?为什么一些 C 标准头文件会出现在 C++ 位置?

我只安装了一个编译器(GCC 7)。

c c++
  • 1 个回答
  • 2771 Views
Martin Hope
golobitch
Asked: 2018-09-19 01:48:21 +0800 CST

进程 ID 到 loginctl 会话 ID

  • 3

我有一个“小”问题:)

如果我运行命令

loginctl list-session

我将获得包含会话、uid、用户和座位列的输出。所以我在这里有 c6、c2、c4 等会话。

另外,我有一个带有一些 id 的进程,我想知道它在哪个会话中运行?

例如

cat /proc/<pid>/sessionid

将返回一些像 4294967295 这样的数字,这与 loginctl 会话完全不同。

现在我的主要问题是:如何从进程 ID 获取 loginctl 会话 ID。

是的,我知道我可以运行它

ps aux | grep -i <pid> | awk '{print $1}'

并获取用户,然后将此用户映射到 loginctl 并获取会话 ID ...但我认为这不是正确的解决方案。例如,在 loginctl 中是否只有一个 UserA 实例?因为我可以看到 lightdm(x 显示管理器)的实例很少,我不能确定哪个会话 id 是正确的。

是的,我将在 C++ (c++11) 中实现它,所以我也会接受 C++ 的答案:)

谢谢你。

问候,golobitch

systemd c++
  • 1 个回答
  • 6149 Views
Martin Hope
T. K.
Asked: 2018-08-22 08:39:24 +0800 CST

使用 Mesa v18.0.5,但只获得 OpenGL v3.0

  • 0

我正在尝试使用 OpenGL 开发 C/C++ 应用程序。不幸的是,我无法访问 OpenGL 3.0 之后的任何功能。我有 Mesa 版本 18.0.5、Linux Mint 18 64 位、4.18.1 内核和英特尔集成显卡。

终端输出:

 ~ $ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation Broadwell-U 
Integrated Graphics (rev 09)
 ~ $ glxinfo | grep OpenGL
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 5500 (Broadwell 
GT2) 
OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.0.5
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 18.0.5
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 18.0.5
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 
3.10
OpenGL ES profile extensions:

我确信我的硬件最高支持 OpenGL 4.4,因为这台机器在 MS 推送/强制更新之前是 Windows 10 机器,并且在那段时间我使用 OpenGL 4.4 和 GLSL 440 进行开发。

此外,我可以通过 JOGL 在 Java 上运行 OpenGL 4.4 程序,JOGL 将所有必需的 OpenGL 库打包在一起,似乎根本不依赖系统版本。

那么基本上,为什么 Mesa 说核心版本是 4.5,然后给出了 3.0 的版本字符串呢?(相同版本的 glGetString(GL_VERSION) 返回。)我怎样才能重新获得对 OpenGL 4.4 的访问权限?(如果不是 4.5!)

linux-mint c++
  • 1 个回答
  • 2590 Views
Martin Hope
Aleksey Kontsevich
Asked: 2018-06-17 13:17:36 +0800 CST

命令行 HMAC 计算不同于 Node.JS crypto.createHmac('sha256')

  • -1

在 Node.js 中,我使用以下代码

hash = crypto.createHmac('sha256', SECRET).update(fileContent).digest('hex');

计算 HMAC。C++/Qt 代码模拟

QByteArray hash = QMessageAuthenticationCode::hash(
           fileContent, SECRET, QCryptographicHash::Sha256).toHex();

为文本 JSON 文件内容生成与 Node.JS 中相同的结果。但是 Linux 命令行 HMAC 计算会产生不同的哈希码:

> openssl sha256 -hmac "SECRET" filename

命令行有什么问题?什么是正确的openssl论点?

c++ openssl
  • 1 个回答
  • 1269 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve