xz Utilsの導入方法
Posted: 2013年11月17日(日) 19:54
lzmaがパブリックドメインということで興味を持ち、xz utilsをダウンロード(*1)し、こちら(*2)を参考に試してみたのですが、リンクエラーが発生します。
なにかライブラリを含めなければいけないはずですが、どうすればいいのでしょうか。liblzma.aというのが怪しいのですが、使い方がわかりません。
環境: win7, VS2012, C++
*1 http://tukaani.org/xz/ の xz-5.0.5-windows.zip
*2 http://s-yata.jp/docs/xz-utils/
1>main.obj : error LNK2019: 未解決の外部シンボル __imp__lzma_code が関数 _main で参照されました。
1>main.obj : error LNK2019: 未解決の外部シンボル __imp__lzma_easy_encoder が関数 _main で参照されました。
P.S. IEだとコードが一行で表示されるのですが私だけでしょうか。火狐だと大丈夫なんですが...
なにかライブラリを含めなければいけないはずですが、どうすればいいのでしょうか。liblzma.aというのが怪しいのですが、使い方がわかりません。
環境: win7, VS2012, C++
*1 http://tukaani.org/xz/ の xz-5.0.5-windows.zip
*2 http://s-yata.jp/docs/xz-utils/
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <assert.h>
#include "lzma.h"
int main()
{
std::ifstream ifs("main.cpp");
std::ofstream ofs("main.xz");
lzma_stream strm = LZMA_STREAM_INIT;
lzma_ret ret = lzma_easy_encoder(&strm, 6, LZMA_CHECK_CRC64);
assert(ret == LZMA_OK);
lzma_action action = LZMA_RUN;
do {
static uint8_t inbuf[32];
static uint8_t outbuf[32];
ifs.read((char*)inbuf, sizeof(inbuf));
strm.next_in = inbuf;
strm.avail_in = (size_t)ifs.gcount();
if (ifs.eof()) {
action = LZMA_FINISH;
}
do {
strm.next_out = outbuf;
strm.avail_out = _countof(outbuf);
ret = lzma_code(&strm, action);
assert((ret == LZMA_OK) || (ret == LZMA_STREAM_END));
ofs.write((char*)outbuf, (char*)strm.next_out-(char*)outbuf);
} while (strm.avail_out == 0);
assert(strm.avail_in == 0);
} while (action != LZMA_FINISH);
assert(ret == LZMA_STREAM_END);
return 0;
}
1>main.obj : error LNK2019: 未解決の外部シンボル __imp__lzma_easy_encoder が関数 _main で参照されました。
P.S. IEだとコードが一行で表示されるのですが私だけでしょうか。火狐だと大丈夫なんですが...