websocketpp icon indicating copy to clipboard operation
websocketpp copied to clipboard

How to compile projects?

Open jackywei1228 opened this issue 6 years ago • 15 comments

I use command as blow:

git clone https://github.com/zaphoyd/websocketpp.git
cd websocketpp/websocketpp
mkdir build
cd build
cmake ..

It show:

-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:1 (init_target):
  Unknown CMake command "init_target".

Who can tell me why it throw error 'Unknown CMake command "init_target"' ???

Thank you , I am a newbie on cmake.

My compiling environment:

  1. cmake version 3.13.0-rc2

jackywei1228 avatar Oct 31 '18 07:10 jackywei1228

websocketpp/websocketpp is one subdirectory to deep, please use:

git clone https://github.com/zaphoyd/websocketpp.git
cd websocketpp
mkdir build
cd build
cmake ..

c72578 avatar Oct 31 '18 08:10 c72578

websocketpp/websocketpp is one subdirectory to deep, please use:

git clone https://github.com/zaphoyd/websocketpp.git
cd websocketpp
mkdir build
cd build
cmake ..

Thank you for your reply, I use your comment:

android@NSGWD180021:~/websocketpp/build$ cmake ..
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
** websocketpp

=========== Used Build Configuration =============

-- ENABLE_CPP11        = ON
-- BUILD_EXAMPLES      = OFF
-- BUILD_TESTS         = OFF

-- WEBSOCKETPP_ROOT    = /home/android/websocketpp
-- WEBSOCKETPP_BIN     = /home/android/websocketpp/build/bin
-- WEBSOCKETPP_LIB     = /home/android/websocketpp/build/lib
-- Install prefix      = /usr/local

-- WEBSOCKETPP_BOOST_LIBS        = 
-- WEBSOCKETPP_PLATFORM_LIBS     = 
-- WEBSOCKETPP_PLATFORM_TLS_LIBS = 

-- OPENSSL_FOUND        = 
-- OPENSSL_INCLUDE_DIR     = 
-- OPENSSL_LIBRARIES = 
-- OPENSSL_VERSION = 

-- Configuring done
-- Generating done
-- Build files have been written to: /home/android/websocketpp/build
android@NSGWD180021:~/websocketpp/build$ ls
CMakeCache.txt  CMakeFiles  Makefile  cmake_install.cmake  websocketpp
android@NSGWD180021:~/websocketpp/build$ make

and then I run make , There is nothing to be done. like this:

android@NSGWD180021:~/websocketpp/build$ make
android@NSGWD180021:~/websocketpp/build$ 

Why ?

Do you have the document for complie the websocketpp? Thank you for your help.

jackywei1228 avatar Oct 31 '18 08:10 jackywei1228

My os is ubuntu. And I use the scons to complie is OK... Thank you for your help @c72578

jackywei1228 avatar Oct 31 '18 08:10 jackywei1228

Make is not working! Can you please include the whole compile, build and install procedure into read.me, please?

alexiicon avatar Nov 06 '18 09:11 alexiicon

I looked up through Makefile - so finally to install it you should use this: git clone https://github.com/zaphoyd/websocketpp.git cd websocketpp mkdir build cd build cmake .. make install

So default make is NOT working now

alexiicon avatar Nov 06 '18 09:11 alexiicon

Websocketpp is a header only library. You only need to install the headers via make install as shown by @alexiicon to use them. Then you can include them in your own projects and build with them.

If you want to build the examples and tests for websocketpp, you need to enable those options with cmake before running make will do anything.

From websocketpp/CMakeLists.txt:

# Override from command line "CMake -D<OPTION>=TRUE/FALSE/0/1/ON/OFF"
option (ENABLE_CPP11 "Build websocketpp with CPP11 features enabled." TRUE)
option (BUILD_EXAMPLES "Build websocketpp examples." FALSE)
option (BUILD_TESTS "Build websocketpp tests." FALSE)

So by default, make does not build the examples. You would need to do something like this to build them:

git clone https://github.com/zaphoyd/websocketpp.git
cd websocketpp
mkdir build
cd build
cmake -DBUILD_EXAMPLES=TRUE ..
make

Araevin avatar Nov 27 '18 19:11 Araevin

I looked up through Makefile - so finally to install it you should use this: git clone https://github.com/zaphoyd/websocketpp.git cd websocketpp mkdir build cd build cmake .. make install

So default make is NOT working now

Thank you~

jackywei1228 avatar Dec 07 '18 02:12 jackywei1228

my os is ubuntu 16.04.

git clone https://github.com/zaphoyd/websocketpp.git cd websocketpp mkdir build cmake -DENABLE_CPP11=TRUE -DBUILD_EXAMPLES=TRUE -DBUILD_TESTS=TRUE -DBOOST_ROOT=../../boost_1_63_0 make make install

try it~

sbkim9 avatar Dec 10 '18 09:12 sbkim9

When I run cmake -DBUILD_EXAMPLES=TRUE .., I get the error message

CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindBoost.cmake:1357 (file):
  file STRINGS file
  "C:/Program1/GDAL/release-1911-x64-dev/release-1911-x64/include/boost/version.hpp"
  cannot be read.
Call Stack (most recent call first):
  CMakeLists.txt:214 (find_package)

Why does CMake look in my GDAL installation? To me, this doesn't really seem appropriate as GDAL is not a dependency and since I just happen to have GDAL installed. How can this be considered desired behavior? (I'm aware that this is mainly a CMake characteristic, but still)

Anyway, what do I do about this error?

krikr42 avatar Feb 20 '19 17:02 krikr42

thanks for this topic, i'm build ok. hope to add to README file tell the newer.

fml927 avatar Nov 11 '19 07:11 fml927

How can i include and compile my .cpp n .hpp file here ?? i am using websocketpp library in my code . i am able to perform procedure mentioned by @alexiicon . but it not including my files for compilation.

kjaisinghyadav avatar Jan 23 '20 04:01 kjaisinghyadav

MINGW64:/websocketpp/build

I could not finish. the websocketpp.sln is empty.

williamXDB avatar Feb 02 '21 07:02 williamXDB

  • [ ] image

williamXDB avatar Feb 02 '21 07:02 williamXDB

When I run cmake -DBUILD_EXAMPLES=TRUE .., I get the error message /data/tmp/websocketpp/examples/print_client_tls/print_client_tls.cpp: In function ‘bool verify_subject_alternative_name(const char*, X509*)’: /data/tmp/websocketpp/examples/print_client_tls/print_client_tls.cpp:64:93: error: ‘ASN1_STRING_get0_data’ was not declared in this scope nst * dns_name = (char const ) ASN1_STRING_get0_data(current_name->d.dNSName); ^ /data/tmp/websocketpp/examples/print_client_tls/print_client_tls.cpp:67:57: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (ASN1_STRING_length(current_name->d.dNSName) != strlen(dns_name)) { ^ /data/tmp/websocketpp/examples/print_client_tls/print_client_tls.cpp: In function ‘bool verify_common_name(const char, X509*)’: /data/tmp/websocketpp/examples/print_client_tls/print_client_tls.cpp:98:89: error: ‘ASN1_STRING_get0_data’ was not declared in this scope nst * common_name_str = (char const *) ASN1_STRING_get0_data(common_name_asn1); ^ /data/tmp/websocketpp/examples/print_client_tls/print_client_tls.cpp:101:46: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (ASN1_STRING_length(common_name_asn1) != strlen(common_name_str)) { ^ examples/print_client_tls/CMakeFiles/print_client_tls.dir/build.make:62: recipe for target 'examples/print_client_tls/CMakeFiles/print_client_tls.dir/print_client_tls.cpp.o' failed make[2]: *** [examples/print_client_tls/CMakeFiles/print_client_tls.dir/print_client_tls.cpp.o] Error 1 CMakeFiles/Makefile2:948: recipe for target 'examples/print_client_tls/CMakeFiles/print_client_tls.dir/all' failed make[1]: *** [examples/print_client_tls/CMakeFiles/print_client_tls.dir/all] Error 2 Makefile:140: recipe for target 'all' failed make: *** [all] Error 2

gocpplua avatar Apr 09 '21 04:04 gocpplua

websocketpp/websocketpp is one subdirectory to deep, please use:

git clone https://github.com/zaphoyd/websocketpp.git
cd websocketpp
mkdir build
cd build
cmake ..

execellent job, sir!

hunter2009pf avatar Jan 16 '23 00:01 hunter2009pf