How to configure the snappy installation to a custom directory

Source: Internet
Author: User

1. Go to the official website http://code.google.com/p/snappy/Download snappy-1.1.1.tar.gz installation package.


2. Pressure to the specified directoryCD ~/snappy
TAR-ZXVF snappy-1.1.1.tar.gz
CD snappy-1.1.1
./configure
Make
At this point, if you continue to make install, the associated library will be installed under/usr/local/lib/, to be customized. Reading Makefile will find everything in
Exec_prefix = ${prefix}
Libdir = ${exec_prefix}/lib
prefix =/usr/local
Next, you know, modify the prefix for you to customize the directory.
Here I set to
prefix = ~/bin

3. Use of SnappyIt's easy to talk about how to use
As I set it above, the header file is under ~/include,. A and. So are all under ~/bin
C Style using snappy-c.h
C + + Use Snappy.h

#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <iostream>
#include <strings.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ time.h>
#include "snappy.h"
using namespace std;
String generatordata (int len)
{
string ss;
for (int i=0;i<len;++i)
{
ss = "2";
}
ss+= "finsih!!";
return SS;
}
int main ()
{
string s = generatordata (1024);
string compress_s;
int compress_len = snappy::compress (S.c_str (), S.length (), &compress_s);
printf ("inlen:%d,outlen:%d,ret:%d,compress_s:%s\n", S.length (), Compress_s.length (), compress_len,compress_s.c_ STR ());
string srcovery;
BOOL bucom = snappy::uncompress (Compress_s.c_str (), Compress_len, &srcovery);
printf ("srcovery.len:%d,srcovery:%s\n", Srcovery.length (), Srcovery.c_str ());
return 0;
}




Compile:
g++-i$local_inc-o Main Main.cpp-l$local_lib-lsnappy
Local_inc and Local_lib are the directories you install.
Get the executable test 2 file. Whether it's done. No,compress and other APIs rely on libsnappy.so.1 this dynamic library, direct execution will not find the dynamic library.
2 options:
1. Set environment variable in ~/.profile export ld_library_path= $LD _library_path:~/lib
2. Designation of ~/lib in/etc/ld.so.conf

So far, done, can be tested.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.