rocksdb添加java API,修复c++动态库使用ldd查询显示未定义符号问题

Signed-off-by: He Rengui <herengui@uniontech.com>
This commit is contained in:
He Rengui 2021-05-07 10:16:14 +08:00
parent eb645eb5af
commit a952ab93ca

View File

@ -1,12 +1,12 @@
Name: rocksdb
Version: 6.8.1
Release: 1
Release: 2
Summary: A Persistent Key-Value Store for Flash and RAM Storage
License: GPLv2 and Apache 2.0 License
URL: https://github.com/facebook/rocksdb.git
BuildRequires: gcc make rpm-build gcc-c++ gtest-devel
BuildRequires: gcc make rpm-build gcc-c++ gtest-devel maven java-1.8.0-openjdk-devel
# enable debuginfo pacakges by default, then we need gdb package
BuildRequires: gdb
@ -34,7 +34,15 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
Development files for rocksdb
%package -n %{name}jni
Summary: A Java JNI driver to rocksdb
# rocksdbjni.jar contains a shared object, that requires some packages
Requires: java-1.8.0-openjdk glibc snappy zlib bzip2 lz4 zstd libstdc++
%description -n %{name}jni
RocksDB JNI gives you a Java interface to the RocksDB C++ library which is an
embeddable persistent key-value store for fast storage.
%prep
%autosetup
@ -44,15 +52,26 @@ rm build_tools/gnu_parallel
%build
export CFLAGS="%{optflags}"
export EXTRA_CXXFLAGS=" -std=c++11 %{optflags}"
make %{?_smp_mflags} shared_lib
# librocksdb*.so* has undefined symbols dlopen and so on, “-ldl” needs to be added here
export EXTRA_CXXFLAGS=" -std=c++11 %{optflags} -ldl"
%make_build shared_lib
# build rocksdbjni
export JAVA_HOME=%{_jvmdir}/java-1.8.0-openjdk
export EXTRA_CXXFLAGS="${EXTRA_CXXFLAGS} -I${JAVA_HOME}/include/ -I${JAVA_HOME}/include/linux"
sed -i 's#\(^DEBUG_LEVEL.*=\).*$#\10#' Makefile
PORTABLE=1 %make_build rocksdbjava
%install
make install-shared \
INSTALL_PREFIX=%{buildroot}\
LIB_INSTALL_DIR=%{_libdir}\
INCLUDE_INSTALL_DIR=%{_includedir}
# install rocksdbjni
install -d -p -m 0755 %{buildroot}%{_javadir}/%{name}jni
install -D -m 0644 java/target/%{name}jni-%{version}-linux$(getconf LONG_BIT).jar \
%{buildroot}%{_javadir}/%{name}jni/%{name}jni.jar
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
@ -68,6 +87,14 @@ make install-shared \
%{_libdir}/librocksdb.so
%{_includedir}/*
%files -n %{name}jni
%dir %{_javadir}/%{name}jni
%{_javadir}/%{name}jni/%{name}jni.jar
%changelog
* Thu May 06 2021 herengui <herengui@uniontech.com> - 6.8.1-2
- add java-api: rocksdbjni
- fix undefined symbol issue for c++ API
* Thu May 28 2020 openEuler Buildteam <buildteam@openeuler.org> - 6.8.1-1
- Package init