简体   繁体   English

如何在 VS2015 中的 windows 10 上构建 snappy?

[英]How to build snappy on windows 10 in VS2015?

I hava download snappy 1.1.8 on here ,and follow the readme to compile on my computer,我在这里下载了 snappy 1.1.8,然后按照自述文件在我的电脑上编译,

mkdir build mkdir 构建

cd build && cmake../ cd build && cmake../

then I open the .sln file in VS2015,build the lib ,there are no errors.然后我在VS2015中打开.sln文件,构建lib ,没有错误。

then I write an example like below,and add the lib to my project:然后我写一个像下面这样的例子,并将lib添加到我的项目中:

class Sna
{
public:
    Sna(string &data) :data_(data)
    {
    }

    void compress()
    {
        auto start = high_resolution_clock::now();
        snappy::Compress(data_.data(), data_.size(), &compressed_);

        auto end = high_resolution_clock::now();
        cout << "compress use time: " << duration_cast<microseconds>(end - start).count() << " microseconds" << endl;
    }

    void unCompress()
    {
        auto start = high_resolution_clock::now();
        snappy::Uncompress(compressed_.data(),compressed_.size(),&recoverd_);
        auto end = high_resolution_clock::now();
        cout << "unCompress use time: " << duration_cast<microseconds>(end - start).count() << " microseconds" << endl;
    }

    bool check()
    {
        return !data_.compare(recoverd_) ? true : false;
    }

    double ratio()
    {
        int temp = int(data_.length() - compressed_.length());
        double d = (double)temp / data_.length();
        return d * 100;
    }

private:
    string data_, compressed_, recoverd_;
};

int main()
{
    //read data from file
    //...

    Sna sna(data);
    sna.compress();
    sna.unCompress();

    return 0;
}

the compress function is ok,but when execute the unCompress function,the program crashed,it gave me this error: compress function 是可以的,但是当执行unCompress function 时,程序崩溃了,它给了我这个错误:

0xC000001D: Illegal Instruction。 0xC000001D:非法指令。

on snappy.cc line 720:snappy.cc第 720 行:

 #if SNAPPY_HAVE_BMI2
  return _bzhi_u32(v, 8 * n);

I have tried:我努力了:

  1. fallback the version of snappy 1.1.7,it works well for me,don't have this problem.回退 snappy 1.1.7 的版本,对我来说效果很好,没有这个问题。
  2. when compile the lib,set the Enable Enhanced Instruction Set to Advanced Vector Extensions 2 (/arch:AVX2) ,but it still had other problems.编译 lib 时,将Enable Enhanced Instruction SetAdvanced Vector Extensions 2 (/arch:AVX2) ,但仍然存在其他问题。

I don't know which step I did wrong?不知道是哪一步做错了? and how to solve this problem?以及如何解决这个问题?

Thanks to @rpress, solved this problem.感谢@rpress,解决了这个问题。

found the file CMakeLists.txt .and comment out the line 118 to 112 like below找到文件CMakeLists.txt并注释掉第 118 到 112 行,如下所示

# check_cxx_source_compiles("
# #include <immintrin.h>
# int main() {
#   return _bzhi_u32(0, 1);
# }" SNAPPY_HAVE_BMI2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Windows 10 VS2015上构建Boost-无法打开* .lib - Build Boost on Windows 10 VS2015 - Cannot Open *.lib 使用 VS2015 在 Windows 10 上构建 Fortran .lib x64 位并将其链接到 C++ - build Fortran .lib x64 bit on windows 10 using VS2015 and link it to C++ vs2015下Windows 10中的容错堆 - Fault Tolerant Heap in Windows 10 under vs2015 OpenCV:在VS2015 x64版本的Windows 10上将Qt库与cvFontQt和cvAddText一起使用时,不会显示文本 - OpenCV: Text does not display when using the Qt library with cvFontQt and cvAddText on Windows 10 in VS2015 x64 build 在VS2015中无法以ARM模式构建C ++静态库(Windows Phone 8.1) - Cannot build C++ Static Library (Windows Phone 8.1) in ARM mode in VS2015 如何在VS2015项目中包含libcds? - How to include libcds in VS2015 project? 如何使用“ Microsoft Excel SDK 2013”​​和VS2015社区构建Excel外接程序? - How to build an Excel Addin with "Microsoft Excel SDK 2013” and VS2015 community? 如何从命令行使用 MSBuild VS2015 构建所有配置? - How can I build all configurations with MSBuild VS2015 from the command line? VS2015 Build Agent请求失败,未设置URI - VS2015 Build agent request has failed, URI not set 构建时vs2015和vc ++外部依赖项错误 - vs2015 and vc++ external dependencies error on build
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM