abumq / ripe Goto Github PK
View Code? Open in Web Editor NEWLightweight cryptography library wrapper
License: Other
Lightweight cryptography library wrapper
License: Other
Hi Majid Q,
I have successfully compiled #40 on Ubuntu, but I encountered an issue with Windows. As far as I know, for the static build, the file extension should be *.lib.
Highlight
ninja: error: 'cryptopp-cmake/cryptopp/Debug/cryptopp.lib', needed by 'ripe/ripe.dll', missing and no known rule to make it
CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
project(hello_library)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
############################################################
# Create a library
############################################################
# Cryptopp
add_subdirectory(cryptopp-cmake)
set(CryptoPP_USE_STATIC_LIBS ON)
set(CRYPTOPP_ROOT_DIR "${CMAKE_BINARY_DIR}/cryptopp-cmake")
set(CRYPTOPP_LIBRARY "${CMAKE_BINARY_DIR}/cryptopp-cmake")
find_package(CryptoPP REQUIRED) # Check if this package is correctly installed and found.
if(UNIX)
set(CRYPTOPP_LIBRARIES_ENV ${CRYPTOPP_LIBRARIES}/cryptopp/libcryptopp.a) # This will be set for Linux and other Unix-like systems
elseif(WIN32)
set(CRYPTOPP_LIBRARIES_ENV ${CRYPTOPP_LIBRARIES}/cryptopp/Debug/cryptopp.lib) # This will be set for Windows
endif()
# Ripe
add_subdirectory(ripe) # Build the Ripe library first
set(RIPE_USE_STATIC_LIBS ON)
set(LIB_RIPE_SOURCE_FILES "${CMAKE_SOURCE_DIR}/ripe")
set(RIPE_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/ripe")
set(RIPE_LIBRARY "${CMAKE_BINARY_DIR}/ripe") # Point to the build directory of Ripe
find_package(Ripe REQUIRED) # Check if this package is correctly installed and found.
if(UNIX)
set(RIPE_LIBRARY_ENV ${RIPE_LIBRARY}/libripe.so) # This will be set for Linux and other Unix-like systems
elseif(WIN32)
set(RIPE_LIBRARY_ENV ${RIPE_LIBRARY}/Debug/ripe.lib) # This will be set for Windows
endif()
target_link_libraries(ripe
${CRYPTOPP_LIBRARIES_ENV}
${ZLIB_LIBRARIES}
)
target_link_libraries (ripe-bin
${CRYPTOPP_LIBRARIES_ENV}
${ZLIB_LIBRARIES}
)
# Licenspp
add_subdirectory(licensepp) # Build the Licenspp library first
target_include_directories(licensepp-lib
PRIVATE
${CMAKE_SOURCE_DIR}/licensepp # Add the directory containing json-object.h
${CMAKE_SOURCE_DIR}/licensepp/include
${RIPE_INCLUDE_DIR}/include
# Other include directories if needed
)
target_link_libraries(licensepp-lib
${CRYPTOPP_LIBRARIES_ENV}
${RIPE_LIBRARY_ENV}
)
# target_link_libraries(licensepp-lib
# ${RIPE_LIBRARY_ENV}
# )
# Add your main project executable or library
add_executable(hello_library main.cpp) # Replace with your target name
Log
rm -rf build && mkdir build && cmake -B build -G Ninja && cmake --build build/-- The C compiler identification is Clang 15.0.6 with GNU-like command-line
-- The CXX compiler identification is Clang 15.0.6 with GNU-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is Clang with GNU-like command-line
-- Found assembler: C:/Program Files/LLVM/bin/clang.exe
=> Project : cryptopp-cmake v8.8.0
-- Found Git: C:/Program Files/Git/mingw64/bin/git.exe (found version "2.38.1.windows.1")
-- Crypto++ auto fetched at: C:/Users/aa6my/_dev/cmake-test/build/cryptopp-cmake/cryptopp
-- Using branch licensing_mechanism for tests
-- Adding unit test: disable-feature
-- Adding unit test: include-prefix
-- Adding unit test: no-install
-- Adding unit test: standard-cpm
-- Adding install integration test: int-install-default
-- Adding install integration test: int-install-prefix
=> Module : cryptopp
-- [cryptopp] CMake version 3.25.1
-- [cryptopp] System Windows
-- [cryptopp] Processor AMD64
-- [cryptopp] CMAKE_HOST_SYSTEM_PROCESSOR : AMD64
-- [cryptopp] CMAKE_SYSTEM_PROCESSOR : AMD64
-- [cryptopp] Target architecture detected as: x86_64 -> CRYPTOPP_AMD64
-- [cryptopp] Performing Test CRYPTOPP_HAVE_SSE2
-- [cryptopp] Performing Test CRYPTOPP_HAVE_SSE2 - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_SSE3
-- [cryptopp] Performing Test CRYPTOPP_HAVE_SSE3 - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_SSSE3
-- [cryptopp] Performing Test CRYPTOPP_HAVE_SSSE3 - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_SSE41
-- [cryptopp] Performing Test CRYPTOPP_HAVE_SSE41 - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_SSE42
-- [cryptopp] Performing Test CRYPTOPP_HAVE_SSE42 - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_CLMUL
-- [cryptopp] Performing Test CRYPTOPP_HAVE_CLMUL - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_AESNI
-- [cryptopp] Performing Test CRYPTOPP_HAVE_AESNI - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_AVX
-- [cryptopp] Performing Test CRYPTOPP_HAVE_AVX - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_AVX2
-- [cryptopp] Performing Test CRYPTOPP_HAVE_AVX2 - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_SHANI
-- [cryptopp] Performing Test CRYPTOPP_HAVE_SHANI - Success
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - no
-- Found Threads: TRUE
-- [cryptopp] Generating cmake package config files
-- [cryptopp] Generating pkgconfig files
-- [cryptopp] Platform: x86_64
-- [cryptopp] Compiler definitions:
-- [cryptopp] Compiler options:
-- [cryptopp] Build type: Debug
-- Static linking to Crypto++
-- Found CryptoPP: C:/Users/aa6my/_dev/cmake-test/build/cryptopp-cmake (found version "..")
-- Static linking to Crypto++
-- Crypto++ binary: C:/Users/aa6my/_dev/cmake-test/build/cryptopp-cmake
-- Found ZLIB: C:/Program Files/zlib/lib/zlibstat.lib (found version "1.2.3")
-- Looking for C++ include attr/xattr.h
-- Looking for C++ include attr/xattr.h - not found
-- Looking for C++ include sys/xattr.h
-- Looking for C++ include sys/xattr.h - not found
-- Ripe: Static linking
-- Ripe: Include: C:/Users/aa6my/_dev/cmake-test/ripe, Binary: C:/Users/aa6my/_dev/cmake-test/build/ripe
-- Found Ripe: C:/Users/aa6my/_dev/cmake-test/ripe
-- Static linking to Crypto++
-- Crypto++ binary: C:/Users/aa6my/_dev/cmake-test/build/cryptopp-cmake
-- Ripe: Dynamic linking
-- Ripe: Include: C:/Users/aa6my/_dev/cmake-test/ripe, Binary: C:/Users/aa6my/_dev/cmake-test/build/ripe
-- Configuring done
CMake Warning at ripe/CMakeLists.txt:95 (target_link_libraries):
Target "ripe" requests linking to directory
"C:/Users/aa6my/_dev/cmake-test/build/cryptopp-cmake". Targets
may link only to libraries. CMake is dropping the item.
CMake Warning at ripe/CMakeLists.txt:110 (target_link_libraries):
Target "ripe-bin" requests linking to directory
"C:/Users/aa6my/_dev/cmake-test/build/cryptopp-cmake". Targets
may link only to libraries. CMake is dropping the item.
CMake Warning at licensepp/CMakeLists.txt:88 (target_link_libraries):
Target "licensepp-lib" requests linking to directory
"C:/Users/aa6my/_dev/cmake-test/build/cryptopp-cmake". Targets
may link only to libraries. CMake is dropping the item.
CMake Warning at licensepp/CMakeLists.txt:88 (target_link_libraries):
Target "licensepp-lib" requests linking to directory
"C:/Users/aa6my/_dev/cmake-test/build/ripe". Targets may link
only to libraries. CMake is dropping the item.
-- Generating done
-- Build files have been written to: C:/Users/aa6my/_dev/cmake-test/build
ninja: error: 'cryptopp-cmake/cryptopp/Debug/cryptopp.lib', needed by 'ripe/ripe.dll', missing and no known rule to make it
Hi,
When I create the 'licensepp' library directly as a shared library, it works fine. However, when I attempt to use 'add_subdirectory' in the CMakeLists.txt file for the test application and make it static, it shows this error. I've tried several custom alternatives to ensure it works, but it still doesn't.
...
/usr/bin/ld: ripe/CMakeFiles/ripe-bin.dir/lib/Ripe.cc.o: in function `CryptoPP::PKCS1v15_SignatureMessageEncodingMethod::PKCS1v15_SignatureMessageEncodingMethod()':
/home/aa6my/_dev/cmake-test/build/cryptopp/cryptopp/pkcspad.h:87: undefined reference to `vtable for CryptoPP::PKCS1v15_SignatureMessageEncodingMethod'
/usr/bin/ld: ripe/CMakeFiles/ripe-bin.dir/lib/Ripe.cc.o: in function `CryptoPP::PKCS_EncryptionPaddingScheme::PKCS_EncryptionPaddingScheme()':
/home/aa6my/_dev/cmake-test/build/cryptopp/cryptopp/pkcspad.h:23: undefined reference to `vtable for CryptoPP::PKCS_EncryptionPaddingScheme'
/usr/bin/ld: ripe/CMakeFiles/ripe-bin.dir/lib/Ripe.cc.o:(.data.rel.ro._ZTVN8CryptoPP25PK_MessageAccumulatorImplINS_4SHA1EEE[_ZTVN8CryptoPP25PK_MessageAccumulatorImplINS_4SHA1EEE]+0x70): undefined reference to `CryptoPP::HashTransformation::OptimalDataAlignment() const'
/usr/bin/ld: ripe/CMakeFiles/ripe-bin.dir/lib/Ripe.cc.o:(.data.rel.ro._ZTVN8CryptoPP25PK_MessageAccumulatorImplINS_4SHA1EEE[_ZTVN8CryptoPP25PK_MessageAccumulatorImplINS_4SHA1EEE]+0xa0): undefined reference to `CryptoPP::HashTransformation::TruncatedVerify(unsigned char const*, unsigned long)'
/usr/bin/ld: ripe/CMakeFiles/ripe-bin.dir/lib/Ripe.cc.o: in function `CryptoPP::SHA1::SHA1(CryptoPP::SHA1 const&)':
/home/aa6my/_dev/cmake-test/build/cryptopp/cryptopp/sha.h:26: undefined reference to `vtable for CryptoPP::SHA1'
/usr/bin/ld: ripe/CMakeFiles/ripe-bin.dir/lib/Ripe.cc.o: in function `CryptoPP::IteratedHashWithStaticTransform<unsigned int, CryptoPP::EnumToType<CryptoPP::ByteOrder, 1>, 64u, 20u, CryptoPP::SHA1, 0u, false>::HashEndianCorrectedBlock(unsigned int const*)':
/home/aa6my/_dev/cmake-test/build/cryptopp/cryptopp/iterhash.h:196: undefined reference to `CryptoPP::SHA1::Transform(unsigned int*, unsigned int const*)'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
[184/187] Linking CXX shared library ripe/libripe.so.4.2.2
ninja: build stopped: subcommand failed.
Dependencies
CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
project(hello_world)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
# Cryptopp
add_subdirectory(cryptopp)
set(CryptoPP_USE_STATIC_LIBS ON)
set(CRYPTOPP_ROOT_DIR "${CMAKE_BINARY_DIR}/cryptopp/cryptopp")
set(CRYPTOPP_INCLUDE_DIR "${CMAKE_BINARY_DIR}/cryptopp")
set(CRYPTOPP_LIBRARY "${CMAKE_BINARY_DIR}/cryptopp/cryptopp")
find_package(CryptoPP REQUIRED)
add_custom_target(custom_lib
DEPENDS ${CMAKE_BINARY_DIR}/cryptopp/cryptopp/libcryptopp.a
COMMENT "Building myLib"
)
# Ripe
add_subdirectory(ripe)
set(RIPE_USE_STATIC_LIBS ON)
set(RIPE_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/ripe")
set(RIPE_LIBRARY "${CMAKE_SOURCE_DIR}/ripe")
# Include Crypto++ headers for the 'ripe' target
target_include_directories(ripe PRIVATE ${CRYPTOPP_INCLUDE_DIR})
# Create the 'app' executable
add_executable(app main.cpp)
# Link the 'app' target with the 'ripe' library
target_link_libraries(app ripe)
# Include directories for 'app' target
target_include_directories(app PRIVATE ${CRYPTOPP_INCLUDE_DIR})
add_dependencies(app custom_lib)
Since v2.0.0 ripe is not compatible with openssl. We should enhance functionality to add this compatibility back
Implementation using openssl is causing grief with memory leaks (thanks to Valgrind)
We will be moving to Crypto++ for v2.0.0 onwards as it's C++ API makes it easy to integrate yet portable to various platforms.
This is major change and will definitely break existing usages (this is why we're releasing major version)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.