Comments (12)
The error suggests that the version of OpenSSL you use does not include _EVP_sha256 and _HMAC.
Unfortunately, I don't have a Mac to test, but searching for this error it seems this is a common (and known) issue:
https://tor.stackexchange.com/questions/595/tor-compiling-error-undefined-symbols-in-libor-crypto-a
In case it is just the test cases that fail and you're not using any of the HS* algorithms in your project you might not need to change anything since the should not trigger a linker error when not used.
If you need HS256, HS384 or HS512 support it looks like your best bet is recompiling OpenSSL.
Please let me know if you solved it so I can add a note in the Readme to inform users about this.
from jwt-cpp.
the openssl installed by brew
from jwt-cpp.
@DLTech21 Make sure the version installed by brew is actually used when building and if it is, check if it contains those two symbols. I suspect it is using either the wrong library (i.e. system default, not the brew one) or the brew lib does not contain sha256 support.
I'm sorry for not being really helpful. I'll try to compile it once I have access to a Mac again but it might take until the beginning of next month and really hope to solve this issue long before this time.
from jwt-cpp.
solved by link compiled librarys
from jwt-cpp.
thx
from jwt-cpp.
I'll add a note to Readme and link this issue in case of somebody running into the same issue.
from jwt-cpp.
I was also facing the same issues in mu ubuntu 16.04, resolved it by Including -libssl -llibcrypto dependencies in Makefile
from jwt-cpp.
I was also facing the same issues in mu ubuntu 16.04, resolved it by Including -libssl -llibcrypto dependencies in Makefile
Can you make it clearly ? What should i do if use cmake, Thanks very much.
from jwt-cpp.
According to the article, replace brew openssl to the default successfully : https://www.zhihu.com/question/36693783
But the problem still hasn't been solved.
> (base) vmaster@vmasterdeMacBook-Pro:~/Docker/debezium/connector_sosp$ openssl version
LibreSSL 2.8.3
> (base) vmaster@vmasterdeMacBook-Pro:~/Docker/debezium/connector_sosp$ /usr/local/opt/openssl@3/bin/openssl version
OpenSSL 3.0.5 5 Jul 2022 (Library: OpenSSL 3.0.5 5 Jul 2022)
> (base) vmaster@vmasterdeMacBook-Pro:~/Docker/debezium/connector_sosp$ brew link openssl
Warning: Refusing to link macOS provided/shadowed software: openssl@3
If you need to have openssl@3 first in your PATH, run:
echo 'export PATH="/usr/local/opt/openssl@3/bin:$PATH"' >> ~/.profile
For compilers to find openssl@3 you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
For pkg-config to find openssl@3 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
> (base) vmaster@vmasterdeMacBook-Pro:~/Docker/debezium/connector_sosp$ vim /etc/profile
> (base) vmaster@vmasterdeMacBook-Pro:~/Docker/debezium/connector_sosp$ source /etc/profile
vmaster@vmasterdeMacBook-Pro:~/Docker/debezium/connector_sosp$ openssl version
OpenSSL 3.0.5 5 Jul 2022 (Library: OpenSSL 3.0.5 5 Jul 2022)
> (base) vmaster@vmasterdeMacBook-Pro:~/Docker/debezium/connector_sosp$ /usr/bin/openssl version
LibreSSL 2.8.3
The code snippet is as follows:
FIND_PACKAGE(OpenSSL)
if (${OpenSSL_FOUND})
message(${OPENSSL_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
endif ()The output: Using OpenSSL: /usr/local/Cellar/openssl@3/3.0.5/include
> (base) vmaster@vmasterdeMacBook-Pro:~/WorkSpace/CLionProjects/jwt_creator(master)$ make
Using OpenSSL: /usr/local/Cellar/openssl@3/3.0.5/include
/usr/local/Cellar/openssl@3/3.0.5/include
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/vmaster/WorkSpace/CLionProjects/jwt_creator
Consolidate compiler generated dependencies of target libjwt
[ 16%] Built target libjwt
Consolidate compiler generated dependencies of target jwt_creator
[ 33%] Built target jwt_creator
Consolidate compiler generated dependencies of target libjwt_decrypt
[ 41%] Linking CXX shared library ../lib-test/liblibjwt_decrypt.dylib
Undefined symbols for architecture x86_64:
"_EVP_sha256", referenced from:
jwt::algorithm::hs256::hs256(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in jwt_decrypt.cpp.o
"_HMAC", referenced from:
jwt::algorithm::hmacsha::sign(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::error_code&) const in jwt_decrypt.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib-test/liblibjwt_decrypt.dylib] Error 1
make[1]: *** [test/CMakeFiles/libjwt_decrypt.dir/all] Error 2
make: *** [all] Error 2
from jwt-cpp.
The quiet old CMake 🙈
I would strongly recommend using targets instead like
Line 92 in c9a511f
Should look like this
find_package(OpenSSL REQUIRED)
add_executable(your_app_here main.cpp)
target_link_libraries(your_app_here OpenSSL::SSL OpenSSL::Crypto)
from jwt-cpp.
LibreSSL 3.5.3 has the same problem on mac:
> (base) vmaster@vmasterdeMacBook-Pro:~/WorkSpace/CLionProjects/jwt_creator(master)$ openssl version
LibreSSL 3.5.3
> (base) vmaster@vmasterdeMacBook-Pro:~/WorkSpace/CLionProjects/jwt_creator(master)$ cmake .
Using OpenSSL: /usr/local/Cellar/libressl/3.5.3/include
/usr/local/Cellar/libressl/3.5.3/include
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/vmaster/WorkSpace/CLionProjects/jwt_creator
(base) vmaster@vmasterdeMacBook-Pro:~/WorkSpace/CLionProjects/jwt_creator(master)$ make
Consolidate compiler generated dependencies of target libjwt
[ 16%] Built target libjwt
Consolidate compiler generated dependencies of target jwt_creator
[ 33%] Built target jwt_creator
Consolidate compiler generated dependencies of target libjwt_decrypt
[ 41%] Building CXX object test/CMakeFiles/libjwt_decrypt.dir/jwt_decrypt.cpp.o
[ 50%] Linking CXX shared library ../lib-test/liblibjwt_decrypt.dylib
Undefined symbols for architecture x86_64:
"_EVP_sha256", referenced from:
jwt::algorithm::hs256::hs256(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in jwt_decrypt.cpp.o
"_HMAC", referenced from:
jwt::algorithm::hmacsha::sign(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::error_code&) const in jwt_decrypt.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib-test/liblibjwt_decrypt.dylib] Error 1
make[1]: *** [test/CMakeFiles/libjwt_decrypt.dir/all] Error 2
make: *** [all] Error 2
from jwt-cpp.
The quiet old CMake 🙈
I would strongly recommend using targets instead like
Line 92 in c9a511f
Should look like this
find_package(OpenSSL REQUIRED) add_executable(your_app_here main.cpp) target_link_libraries(your_app_here OpenSSL::SSL OpenSSL::Crypto)
Thanks ! but some error occur as follows when using targets instead, what's other should i do ?
(base)
> vmaster@vmasterdeMacBook-Pro:~/WorkSpace/CLionProjects/jwt_creator(master)$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/vmaster/WorkSpace/CLionProjects/jwt_creator
> (base) vmaster@vmasterdeMacBook-Pro:~/WorkSpace/CLionProjects/jwt_creator(master)$ make
Consolidate compiler generated dependencies of target libjwt
[ 8%] Building CXX object src/CMakeFiles/libjwt.dir/jwt_creator.cpp.o
In file included from /Users/vmaster/WorkSpace/CLionProjects/jwt_creator/src/jwt_creator.cpp:1:
/Users/vmaster/WorkSpace/CLionProjects/jwt_creator/src/../include/jwt-cpp/jwt.h:15:10: fatal error: 'openssl/ec.h' file not found
#include <openssl/ec.h>
^~~~~~~~~~~~~~
1 error generated.
make[2]: *** [src/CMakeFiles/libjwt.dir/jwt_creator.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/libjwt.dir/all] Error 2
make: *** [all] Error 2
The sub cmake snippet look like this (by copy jwt-cpp includes and using include_directories command):
find_package(OpenSSL REQUIRED)
include_directories(../include) # jwt-cpp includes, or using command: find_package(jwt-cpp REQUIRED)add_executable(jwt_creator jwt_creator.cpp)
target_link_libraries(jwt_creator INTERFACE LibreSSL::TLS)
When using find_package(jwt-cpp REQUIRED)
> (base) vmaster@vmasterdeMacBook-Pro:~/WorkSpace/CLionProjects/jwt_creator(master)$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/vmaster/WorkSpace/CLionProjects/jwt_creator
> (base) vmaster@vmasterdeMacBook-Pro:~/WorkSpace/CLionProjects/jwt_creator(master)$ make
[ 8%] Building CXX object src/CMakeFiles/libjwt.dir/jwt_creator.cpp.o
/Users/vmaster/WorkSpace/CLionProjects/jwt_creator/src/jwt_creator.cpp:1:10: fatal error: 'jwt-cpp/jwt.h' file not found
#include <jwt-cpp/jwt.h>
^~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [src/CMakeFiles/libjwt.dir/jwt_creator.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/libjwt.dir/all] Error 2
make: *** [all] Error 2
The sub cmake snippet look like this (by find_package):
find_package(OpenSSL REQUIRED)
find_package(jwt-cpp REQUIRED)add_executable(jwt_creator jwt_creator.cpp)
target_link_libraries(jwt_creator INTERFACE LibreSSL::TLS jwt-cpp::jwt-cpp)
from jwt-cpp.
Related Issues (20)
- Create a test for the undefined sanitizer
- HMAC key should be an array of bytes, not a character string HOT 9
- x86/Win32 compilation and using boost json HOT 2
- Private Key Signing vs Signing from Service Account file HOT 5
- undefined reference error in compiling HOT 9
- what secret format should i use for HS512 algorithm HOT 1
- Release status of 0.7.0-rc.0 HOT 3
- Guide to Setting Up jwt-cpp? HOT 4
- Building example: no matching function for call to ‘decode(std::string&)’ HOT 1
- Compilation error: no matching function for call to ‘decode(std::string&)’ HOT 2
- Build Errors For picojson.h? HOT 8
- Getting Error - namespace "jwt" has no member "claims" HOT 6
- Unable to generate token using ed25519 HOT 2
- Use of Builder explicitly
- Need help : How to Implement JWT Operations from Python Using jwt-cpp ? HOT 5
- How to use payload and get the payload data HOT 7
- Boost JSON traits kind of buggy HOT 5
- How to verify a jwt HOT 3
- Invalid input: not within alphabet HOT 6
- Locking in libcrypto in multi threaded app HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jwt-cpp.