我正在尝试在我的ubuntu中安装libwebsocket。
所以我下载了项目https://github.com/warmcat/libwebsockets 拉开它并按照安装说明进行操作。
我输入命令cmake FH并获取以下消息。
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:State or Province Name (full name) [Some-State]:Locality Name (eg, city) []:Organization Name (eg, company) [Internet Widgits Pty Ltd]:Organizational Unit Name (eg, section) []:Common Name (e.g. server FQDN or YOUR name) []:Email Address []:SUCCSESFULLY generated SSL certificate
Generating API documentation
-- Looking for RPMTools... - rpmbuild NOT FOUND
---------------------------------------------------------------------
Settings: (For more help do cmake -LH <srcpath>
---------------------------------------------------------------------
LWS_WITH_SSL = ON (SSL Support)
LWS_SSL_CLIENT_USE_OS_CA_CERTS = 1
LWS_USE_CYASSL = OFF (CyaSSL replacement for OpenSSL)
LWS_WITHOUT_BUILTIN_GETIFADDRS = OFF
LWS_WITHOUT_CLIENT = OFF
LWS_WITHOUT_SERVER = OFF
LWS_LINK_TESTAPPS_DYNAMIC = OFF
LWS_WITHOUT_TESTAPPS = OFF
LWS_WITHOUT_TEST_SERVER = OFF
LWS_WITHOUT_TEST_SERVER_EXTPOLL = OFF
LWS_WITHOUT_TEST_PING = OFF
LWS_WITHOUT_TEST_CLIENT = OFF
LWS_WITHOUT_TEST_FRAGGLE = OFF
LWS_WITHOUT_DEBUG = OFF
LWS_WITHOUT_EXTENSIONS = OFF
LWS_WITH_LATENCY = OFF
LWS_WITHOUT_DAEMONIZE = OFF
LWS_USE_LIBEV =
LWS_IPV6 = OFF
LWS_WITH_HTTP2 = OFF
---------------------------------------------------------------------
-- Configuring done
-- Generating done
-- Build files have been written to: /home/maroua/libwebsocket/libwebsockets-master
-- Cache values
// Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.
CMAKE_BUILD_TYPE:STRING=
// Install path prefix, prepended onto install directories.
CMAKE_INSTALL_PREFIX:PATH=/usr/local
// Libwebsockets include directories
LIBWEBSOCKETS_INCLUDE_DIRS:PATH=/home/maroua/libwebsocket/libwebsockets-master/lib;/home/maroua/libwebsocket/libwebsockets-master
// Libwebsocket libraries
LIBWEBSOCKETS_LIBRARIES:STRING=websocket;websockets_shared
// Libwebsocket shared library
LIBWEBSOCKETS_LIBRARIES_SHARED:STRING=websockets_shared
// Libwebsocket static library
LIBWEBSOCKETS_LIBRARIES_STATIC:STRING=websocket
// Path to the CyaSSL include directory
LWS_CYASSL_INCLUDE_DIRS:PATH=
// Path to the CyaSSL library
LWS_CYASSL_LIB:PATH=
// Installation directory for executables
LWS_INSTALL_BIN_DIR:PATH=bin
// Installation directory for CMake files
LWS_INSTALL_CMAKE_DIR:PATH=lib/cmake/libwebsockets
// Installation directory for example files
LWS_INSTALL_EXAMPLES_DIR:PATH=bin
// Installation directory for header files
LWS_INSTALL_INCLUDE_DIR:PATH=include
// Installation directory for libraries
LWS_INSTALL_LIB_DIR:PATH=lib
// Compile with support for ipv6
LWS_IPV6:BOOL=OFF
// Link the test apps to the shared version of the library. Default is to link statically
LWS_LINK_TESTAPPS_DYNAMIC:BOOL=OFF
// Server SSL certificate directory
LWS_OPENSSL_CLIENT_CERTS:PATH=../share
// SSL support should make use of OS installed CA root certs
LWS_SSL_CLIENT_USE_OS_CA_CERTS:BOOL=ON
// Use CyaSSL replacement for OpenSSL. When settings this, you also need to specify LWS_CYASSL_LIB and LWS_CYASSL_INCLUDE_DIRS
LWS_USE_CYASSL:BOOL=OFF
// Search the system for ZLib instead of using the included one (on Windows)
LWS_USE_EXTERNAL_ZLIB:BOOL=OFF
// Don't use BSD getifaddrs implementation from libwebsockets if it is missing (this will result in a compilation error) ... Default is your libc provides it. On some systems such as uclibc it doesn't exist.
LWS_WITHOUT_BUILTIN_GETIFADDRS:BOOL=OFF
// Don't build the client part of the library
LWS_WITHOUT_CLIENT:BOOL=OFF
// Don't build the daemonization api
LWS_WITHOUT_DAEMONIZE:BOOL=OFF
// Don't compile debug related code
LWS_WITHOUT_DEBUG:BOOL=OFF
// Don't compile with extensions
LWS_WITHOUT_EXTENSIONS:BOOL=OFF
// Don't build the server part of the library
LWS_WITHOUT_SERVER:BOOL=OFF
// Don't build the libwebsocket-test-apps
LWS_WITHOUT_TESTAPPS:BOOL=OFF
// Don't build the client test application
LWS_WITHOUT_TEST_CLIENT:BOOL=OFF
// Don't build the ping test application
LWS_WITHOUT_TEST_FRAGGLE:BOOL=OFF
// Don't build the ping test application
LWS_WITHOUT_TEST_PING:BOOL=OFF
// Don't build the test server
LWS_WITHOUT_TEST_SERVER:BOOL=OFF
// Don't build the test server version that uses external poll
LWS_WITHOUT_TEST_SERVER_EXTPOLL:BOOL=OFF
// Compile with support for http2
LWS_WITH_HTTP2:BOOL=OFF
// Build latency measuring code into the library
LWS_WITH_LATENCY:BOOL=OFF
// Compile with support for libev
LWS_WITH_LIBEV:BOOL=OFF
// Include SSL support (default OpenSSL, CyaSSL if LWS_USE_CYASSL is set)
LWS_WITH_SSL:BOOL=ON
// The RPM builder tool
RPMTools_RPMBUILD_EXECUTABLE:FILEPATH=RPMTools_RPMBUILD_EXECUTABLE-NOTFOUND
我尝试编译一个使用libwebsocket.h的C程序,它告诉我它不存在。 任何人都可以向我展示安装此lib的正确方法。 谢谢你的帮助。
答案 0 :(得分:29)
在Ubuntu中安装libwebsocket的一种简单方法是在终端中使用此命令:
sudo apt-get install libwebsockets-dev
此命令将安装 1.2 版本
libwebsockets.h
文件位于/usr/include/libwebsockets.h
拥有此库的另一种方法是从GitHub获取最新版本( 1.4 )。为此,打开终端并进入您想要获取库的目录(我将其称为lib_dir
)。
当您在lib_dir
目录中时,请输入此命令以获取代码:
命令完成后,您将找到名为 libwebsockets 的目录
libwebsockets.h
文件位于lib_dir/libwebsockets/lib
如果您需要/想要构建库并将其安装到系统中,请转到lib_dir
,然后输入以下命令:
sudo apt-get install libssl-dev
mkdir build
cd build
cmake ..
使
sudo make install
LDCONFIG
这将在/usr/local/include
中安装库。
并确保您刚刚安装的版本:
pkg-config --modversion libwebsockets
最后,您需要在编译器中包含(包含路径-I):
的/ usr /本地/包括
在链接库(Libraries -l)中:
的WebSockets
最后(图书馆搜索路径-L):
的/ usr /本地/ lib中