Open petef19 opened 4 years ago
There are few things I would check:
I am not familiar with the windows dev environment. @gocarlos Can you please help by giving some pointers ?
Try the following in the powershell:
cmake -DOPENSSL_ROOT_DIR=/path/lo/lib/openssl/ -DOPENSSL_CRYPTO_LIBRARY=/path/to/lib/lib/ /path/to/project/dir
Do did compile openssl right? You can also try conan which has the openssl already compiled for you: https://conan.io/center/openssl/1.1.1g
@arun11299 @gocarlos
Is the openssl installed correctly and the path you are setting pointing to the expected location ?
I downloaded executables from ICS here, then simply put them in a location and set the Windows env vars.
Try the following in the powershell
CLion uses the CMakeLists.txt in the cpp-jwt project root. And that works well if everything is properly configured. Would be interesting to know what needs to be done to make this work.
Re the command, what does /path/to/lib/lib/
and /path/to/project/dir
refer to ?
Do did compile openssl right?
The executables I downloaded from ICS (see above) were already compiled.
This will not work, the files you downloaded are not for development, there are no headers in the zip file...
You need to download the source code of openssl and compile it by yourself like in the 90s or use a modern package manager ala vcpkg, choco or conan (my favorite)
If you use conan, then you do not have to set any env variables, see https://docs.conan.io/en/latest/howtos/cmake_launch.html
But at the end of the day: cpp-jwt is also in the conan repository, no need to deal with openssl if you just consuming this library, see conan center
@gocarlos
I've not worked w/ Conan before. Is there a step-by-step walk-through on what to do to compile cpp-jwt (via Conan) so that I can use it in my C++ code ?
Thanks !
See the link above and add cpp-jwt@[>=1.2]
to your conanfile or require it directly in the cmake file as per above example behind the link
First pip install conan —upgrade
Then massage your cmake:
cmake_minimum_required(VERSION 3.1)
project(myproject CXX)
# Download automatically, you can also just copy the conan.cmake file
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
# say that you require this package
conan_cmake_run(REQUIRES cpp-jwt/1.2
BASIC_SETUP
BUILD
missing)
# create findPackage.cmake targets
conan_basic_setup(TARGETS)
# tell cmake to find those targets, from here on its normal cmake see this projects readme
find_package(cpp-jwt REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main cpp-jwt::cpp-jwt)
alright, I got conan 1.29.0
installed via pip.
Your last post is a CMakeLists.txt
file. Where does that go ?
Does that replace the CMakeLists.txt
file in the cpp-jwt
root ?
are you developing the cpp-jwt
or just using the cpp-jwt
in your project?
Just using it in my project.
I need to use json webtokens so I was looking into cpp-jwt
.
In that case you take the cmake script above and just add your sources in add executable
Does the script above replace the CMakeLists.txt
file in the cpp-jwt
root ?
it replaces your projects cmakelists, though you need to adapt add_executable
to add your sources
so are you saying I don't need to compile cpp-jwt first to be used in my project, I just simply add the conan set up and requirements to my project's CMakeLists.txt
file ?
If I wanted to compile cpp-jwt
on it's own (I assume via conan), to then simply load the compiled library in my CMakeLists.txt
file, how would that work ?
so are you saying I don't need to compile cpp-jwt first to be used in my project, I just simply add the conan set up and requirements to my project's CMakeLists.txt file ?
yes
If I wanted to compile cpp-jwt on it's own (I assume via conan), to then simply load the compiled library in my CMakeLists.txt file, how would that work ?
dont know what you mean... by using the script above you can use the cpp-jwt
in your cmakelists by linking your library or executable to it e.g. target_link_libraries(myExecutableOrLibrary cpp-jwt::cpp-jwt)
ok, I will try that
Thanks !
ok, I tried but get error. This is my CMakeLists.txt
file:
cmake_minimum_required(VERSION 3.16)
project(untitled)
set(CMAKE_CXX_STANDARD 14)
# Download automatically, you can also just copy the conan.cmake file
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
# say that you require this package
conan_cmake_run(REQUIRES cpp-jwt/1.2
BASIC_SETUP
BUILD
missing)
# create findPackage.cmake targets
conan_basic_setup(TARGETS)
# tell cmake to find those targets, from here on its normal cmake see this projects readme
find_package(cpp-jwt REQUIRED)
add_executable(untitled main.cpp)
target_link_libraries(main cpp-jwt::cpp-jwt)
this is the error I get when building this project:
Unknown CMake command "conan_cmake_run".
I assume it cannot find the conan command.
So how can I point to the conan install dir, which is in my Python venv, while this is a C++ project in a different folder ?
@gocarlos
Following up on my last post, can you please assist how to use conan in my Py venv when building the C++ project ?
Thanks.
First I'd suggest to install globally, not with py env...
i recommend that you join the cpp slack chat: https://cpplang.slack.com/
there you get support on a ton of libraries, conan, cmake, compilers etc... this is less a support channel :(
Right, while this sounds great, my point opening this ticket was rather that I may not be the only one running into this issue...
so for future users, it would be good to a proper guide on how to use this package via conan...
otherwise, why share if peeps can't get it to work.
there are already instructions on how to use this library using conan: https://github.com/arun11299/cpp-jwt#consuming-the-library
though how to use conan itself is not explained here not should it: conan has extensive documentation (https://docs.conan.io/en/latest/) and there are tons of examples on github, see for example https://github.com/expresscpp/expresscpp
Hi,
I'm on Win 10 x64 and I'm trying to compile the cpp-jwt package in CLion, but it throws this error message:
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_INCLUDE_DIR)
so the first confusing thing here is that it refers to two different env vars... (?)
In any case, I have set the Windows env vars
OPENSSL_ROOT_DIR
andOPENSSL_INCLUDE_DIR
and pointed both of them to the path of my OpenSSL executables which are v1.1.1g which I downloaded from the ICS wiki.Could you help me and advise how to provide the OpenSSL path to this package (in order to compile it) or possibly tell me which OpenSSL version/package for Windows I should install ?
Thanks !