Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uSockets header and lib not installed system-wide #1600

Open
robosina opened this issue Apr 24, 2023 · 2 comments · May be fixed by #1702
Open

uSockets header and lib not installed system-wide #1600

robosina opened this issue Apr 24, 2023 · 2 comments · May be fixed by #1702

Comments

@robosina
Copy link

robosina commented Apr 24, 2023

Problem description:

I have installed uWebSockets on my Ubuntu system, but I noticed that the libusockets.h header file and the uSockets.a archive file from the uSockets dependency are not installed system-wide. This causes problems when trying to use uWebSockets in my CMake project, as the required header and archive files are not found.

Steps to reproduce:

  1. Clone and build uWebSockets using the provided instructions in the README.
  2. Install uWebSockets using sudo make install.
  3. Notice that libusockets.h and uSockets.a files are not installed in the system include directories (e.g., /usr/local/include/uWebSockets) and library directories (e.g., /usr/local/lib or /usr/lib).

Expected behavior:

The libusockets.h header file and the uSockets.a archive file should be installed system-wide along with the uWebSockets headers so that they are available for use in projects that depend on uWebSockets.

Possible solutions:

  • Update the uWebSockets Makefile to install the libusockets.h header file and the uSockets.a archive file when installing uWebSockets.
  • Provide an installation target in the uSockets Makefile to allow for system-wide installation of uSockets headers and library files.

Additional context:

I was able to manually copy the libusockets.h file to my system include directory, and also copy the uSockets.a archive file as a workaround. However, this is not an ideal solution, as it requires manual work to be done(I wrote a script to do all things).

Please let me know if there is a better solution or if this issue can be addressed in future updates of uWebSockets/uSockets. Thank you!

@HarshaVardhanNakkina
Copy link

how did you copy libusockets.h and uSockets.a files? where are they?

@talksik
Copy link

talksik commented Jan 27, 2024

Make sure you clone with the git submodule. I did this:

git clone --recurse-submodules https://github.com/uNetworking/uWebSockets

Then, you want to run make and then make install. The libusockets.h and uSockets.a will be in the subdirectory uSockets of the repository that we cloned. libusockets.h is in uWebSockets/uSockets/src and the uSockets.a is in uWebSockets/uSockets.

I did the following:

  1. Copy the libusockets.h to /usr/local/include
  2. Copy the uSockets.a to /usr/local/lib

Then, to get my project to compile, the following CMakeLists.txt worked for me:

cmake_minimum_required(VERSION 3.15)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

project(HomechatServer)

find_library(USOCKETS_LIBRARY uSockets.a PATHS /usr/local/lib REQUIRED)
find_package(ZLIB REQUIRED)

set(source_dir ${CMAKE_CURRENT_SOURCE_DIR}/src)
file(GLOB source_files
    ${source_dir}/*.cpp
)
add_executable(${PROJECT_NAME} ${source_files})

target_include_directories(${PROJECT_NAME} PUBLIC ${source_dir}/include)
target_link_libraries(${PROJECT_NAME} ${USOCKETS_LIBRARY})
target_link_libraries(${PROJECT_NAME} ZLIB::ZLIB)

Note: I needed ZLIB as a dependency to make it work because one of the uWebSocket headers uses it.

Here is the project that I am using it for (work in progress as of time of this comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants