gpt4 book ai didi

c - Rabbitmq-c 库在 Debian 8 中未动态链接

转载 作者:行者123 更新时间:2023-11-30 16:42:16 27 4
gpt4 key购买 nike

目标:通过 gcc 动态链接 Rabbitmq-c ( https://github.com/alanxz/rabbitmq-c )。

项目名为storeman:

#include <stdarg.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <amqp_tcp_socket.h>
#include <amqp.h>
#include <amqp_framing.h>
#include <assert.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>

int main(int argc, char const *const *argv)
{
amqp_connection_state_t conn;
conn=amqp_new_connection();
exit(0); //Everything else is deleted for testing
}

<强>1。下载、编译并安装库。

在rabbitmq-c下载路径内的新build文件夹中:

cmake ..

cmake --build .

cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..

make

make install

最后它成功输出了以下内容:

[ 15%] Built target rabbitmq
...
[100%] Built target test_tables
Install the project...
-- Install configuration: "Release"
-- Up-to-date: /usr/local/lib/x86_64-linux-gnu/pkgconfig/librabbitmq.pc
-- Up-to-date: /usr/local/lib/x86_64-linux-gnu/librabbitmq.so.4.2.1
-- Up-to-date: /usr/local/lib/x86_64-linux-gnu/librabbitmq.so.4
-- Up-to-date: /usr/local/lib/x86_64-linux-gnu/librabbitmq.so
-- Up-to-date: /usr/local/lib/x86_64-linux-gnu/librabbitmq.a
-- Up-to-date: /usr/local/include/amqp.h
-- Up-to-date: /usr/local/include/amqp_framing.h
-- Up-to-date: /usr/local/include/amqp_tcp_socket.h
-- Up-to-date: /usr/local/include/amqp_ssl_socket.h

库文件安装到

  • /usr/local/lib/x86_64-linux-gnu/(librabbitmq.so和librabbitmq.so.4指向librabbitmq.so.4.2.1的链接,并且有librabbitmq.a)

  • /usr/local/include/,所有需要的头文件都驻留在其中(amqp.hamqp_framing.h amqp_ssl_socket.h amqp_tcp_socket.h)

<强>2。使用 gcc。

gcc -Wall -I/usr/local/include -L/usr/local/lib/x86_64-linux-gnu -o storeman storeman.c -lrabbitmq

GCC 退出时:

error while loading shared libraries: librabbitmq.so.4: cannot open shared object file: No such file or directory

同时,它可能会使用 librabbitmq.a 成功编译为静态,这让我很困惑......将非常感谢任何帮助。

最佳答案

在我看来,问题可能是文件/etc/ld.so.conf.d/rabbitmq.conf 的内容中缺少 .../lib/... 子目录。当我将该文件的内容更新为此时,它对我有用(找到rabbitmq共享库):

/usr/local/lib/x86_64-linux-gnu 

注意,保存更改后运行sudo ldconfig

这似乎是一个rabbitmq git安装错误 - 我于2018年2月22日在Ubu-17上从分支master克隆并构建。

关于c - Rabbitmq-c 库在 Debian 8 中未动态链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45902974/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com