Comments (2)
@linxGnu Thanks very much for your response. After add CGO_CFLAGS and CGO_LDFLAGS, it works.
Dockerfile:
FROM registry.cn-shanghai.aliyuncs.com/xm69/alpine-rocksdb-apk AS app
WORKDIR /home
COPY code .
ENV GOPROXY=https://goproxy.cn
RUN set -eux && \
#设置源
echo "http://mirrors.ustc.edu.cn/alpine/edge/main/" > /etc/apk/repositories && \
echo "http://mirrors.ustc.edu.cn/alpine/edge/community/" >> /etc/apk/repositories && \
echo "http://mirrors.ustc.edu.cn/alpine/edge/testing/" >> /etc/apk/repositories && \
apk update && \
#安装RocksDB
apk add --allow-untrusted /rocksdb.apk /rocksdb-dev.apk && \
#打印编译环境
echo "编译环境:$(uname -a)" && \
#安装Golang环境
apk add build-base go && \
#下载并校验Golang模块
go mod download && go mod verify && \
#编译Golang应用
# https://github.com/linxGnu/grocksdb/issues/24#issuecomment-752988851
CGO_CFLAGS="-I/usr/include/rocksdb" \
CGO_LDFLAGS="-L/usr/lib -lrocksdb -lstdc++ -lm -lz -lsnappy -llz4 -lzstd" \
go build -o /home/main
If your CPU support SSE4.2, you can use rocksdb packages in alpine.
Shared library is smaller than static lib, especially in alpine. And rocksdb packages in alpine is also compiles shared library.
No need to go get -u github.com/linxGnu/grocksdb
when Using Go Modules. Just install RocksDB first.
Ubuntu Install RocksDB:
$ sudo apt install -y libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
$ PORTABLE=1 make -j32 shared_lib
$ sudo make install-shared
$ sudo su
# echo "/usr/local/lib" >> /etc/ld.so.conf
# ldconfig
from grocksdb.
@alx696 thank you very much for trying grocksdb.
Yeah, builtin static lib at the moment is limited to libc, not musl compatible with alpine.
So, I think you could:
- Build rocksdb as static lib inside your alpine image
- Build grocksdb and your application:
go build -tags static
Or, if you want shared lib:
- Build rocksdb as shared lib inside your alpine image
- Build grocksdb and your applicaion:
CGO_CFLAGS="-I/path/to/rocksdb/include" \
CGO_LDFLAGS="-L/path/to/rocksdb -lrocksdb -lstdc++ -lm -lz -lsnappy -llz4 -lzstd" \
go build
Please tell me if that works for you.
from grocksdb.
Related Issues (20)
- no ability to set track_and_verify_wals_in_manifest option HOT 1
- support a non-hacky way to override link flags HOT 3
- failed to compile: library not found for -lsnappy HOT 3
- ld: library not found for -lrocksdb HOT 2
- installed latest rocksdb HOT 1
- Include library files in repository HOT 1
- no dboption delayed_write_rate HOT 1
- `options.SetPrefixExtractor(grocksdb.NewNoopPrefixTransform())` maybe coredump HOT 2
- Documentation improvments: When should Destroy be called for db option types ? HOT 1
- Error: Library Not Found HOT 12
- Is it possible to implement CompactFiles ? HOT 1
- (*WriteBatchIterator).decodeVarint unfortunately doesn’t correctly detect invalid varint sequences and can consume the entire buffer HOT 1
- Incorrect binding for MultiGetWithCF HOT 4
- Help for dummies? ./cache.go:25:12: could not determine kind of name for C.rocksdb_cache_create_hyper_clock HOT 1
- Is it safe enough to use refGoBytes() HOT 3
- could not determine kind of name for C.rocksdb_backup_engine_open_opts HOT 2
- Add rocksdb sources to the go package HOT 4
- Documentation fix: Add -lbz2 link flag HOT 2
- cannot use _Ctype_ulong(s) (value of type _Ctype_ulong) as type _Ctype_ulonglong in variable declaration HOT 1
- need rocksdb_column_family_handle_get_name HOT 3
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 grocksdb.