gpt4 book ai didi

c++ - 如何在 C++ 项目中包含托管在 Github 上的库? (新 C++ 用户 - 以前使用包管理器的语言)

转载 作者:行者123 更新时间:2023-11-27 23:51:24 24 4
gpt4 key购买 nike

<分区>

我想包括 uWebSockets在 C++ 项目中,我不清楚如何执行此操作。我已经编译了带有 .so 依赖项的项目,当涉及到 github 上列出的项目时,我仍然感到困惑。

具体来说:

  • 在将第三方存储库包含在我的项目中之前是否需要对其进行编译?
  • 将库存放在源代码目录的什么位置?
  • 如何将源代码链接到第三方库?
  • 是否需要 CMake 等工具?

如果这些问题看起来很明显或很愚蠢,请提前致歉,我来自一种有包管理器的语言,所以这对我来说相当陌生。

更新

按照 Github 存储库中的“入门”说明,克隆存储库后,确保已安装依赖项并运行 make,观察到以下输出:

dave@desktop:~/gitrepositories/uWebSockets$ make
make `(uname -s)`
make[1]: Entering directory '/home/dave/gitrepositories/uWebSockets'
g++ -std=c++11 -O3 -I src -shared -fPIC src/Extensions.cpp src/Group.cpp src/Networking.cpp src/Hub.cpp src/Node.cpp src/WebSocket.cpp src/HTTPSocket.cpp src/Socket.cpp src/Epoll.cpp -s -o libuWS.so
In file included from src/WebSocketProtocol.h:5:0,
from src/WebSocket.h:4,
from src/Group.h:4,
from src/Group.cpp:1:
src/Networking.h:7:30: fatal error: openssl/opensslv.h: No such file or directory
#include <openssl/opensslv.h>
^
compilation terminated.
In file included from src/Networking.cpp:1:0:
src/Networking.h:7:30: fatal error: openssl/opensslv.h: No such file or directory
#include <openssl/opensslv.h>
^
compilation terminated.
In file included from src/WebSocketProtocol.h:5:0,
from src/WebSocket.h:4,
from src/Group.h:4,
from src/Hub.h:4,
from src/Hub.cpp:1:
src/Networking.h:7:30: fatal error: openssl/opensslv.h: No such file or directory
#include <openssl/opensslv.h>
^
compilation terminated.
In file included from src/Socket.h:4:0,
from src/Node.h:4,
from src/Node.cpp:1:
src/Networking.h:7:30: fatal error: openssl/opensslv.h: No such file or directory
#include <openssl/opensslv.h>
^
compilation terminated.
In file included from src/WebSocketProtocol.h:5:0,
from src/WebSocket.h:4,
from src/WebSocket.cpp:1:
src/Networking.h:7:30: fatal error: openssl/opensslv.h: No such file or directory
#include <openssl/opensslv.h>
^
compilation terminated.
In file included from src/Socket.h:4:0,
from src/HTTPSocket.h:4,
from src/HTTPSocket.cpp:1:
src/Networking.h:7:30: fatal error: openssl/opensslv.h: No such file or directory
#include <openssl/opensslv.h>
^
compilation terminated.
In file included from src/Socket.h:4:0,
from src/Socket.cpp:1:
src/Networking.h:7:30: fatal error: openssl/opensslv.h: No such file or directory
#include <openssl/opensslv.h>
^
compilation terminated.
Makefile:8: recipe for target 'Linux' failed
make[1]: *** [Linux] Error 1
make[1]: Leaving directory '/home/dave/gitrepositories/uWebSockets'
Makefile:6: recipe for target 'default' failed
make: *** [default] Error 2

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