项目名为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 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
库文件已安装到
2.使用gcc。
gcc -Wall -I / usr / local / include -L / usr / local / lib / x86_64-linux-gnu -o storeman storeman.c -lrabbitmq
海湾合作委员会退出:
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上从分支主机克隆并构建。