ホーム » 2022 » 12月 » 09

日別アーカイブ: 2022/12/09

2022年12月
 123
45678910
11121314151617
18192021222324
25262728293031

カテゴリー

アーカイブ

ブログ統計情報

  • 80,232 アクセス



.NET ZipFile C++/CLI

ZipFile クラスのサンプル を C++/CLI で.
Win32 コンソール AP としてプロジェクトを作成.
CPP を次の様に変更.

#include	<stdio.h>
#include	<tchar.h>

//	using	System;
//	using	System.IO.Compression;
#using  	<System.dll>
#using		<System.IO.Compression.FileSystem.dll>

//	class Program
//	{
//		static void Main(string[] args)
//		{

int _tmain(int argc, _TCHAR* argv[])
{
//			string  startPath	= @"./start";
//			string  zipPath  	= @"./result.zip";
//			string  extractPath	= @"./extract";
		System::String^	startPath	= _T("./start") ;
		System::String^	zipPath  	= _T("./result.zip") ;
		System::String^	extractPath	= _T("./extract") ;

//		                         ZipFile. CreateFromDirectory(startPath, zipPath);
		System::IO::Compression::ZipFile::CreateFromDirectory(startPath, zipPath);

//		                         ZipFile. ExtractToDirectory(zipPath, extractPath);
		System::IO::Compression::ZipFile::ExtractToDirectory(zipPath, extractPath);

	return 0;
	}

//			}
//		}

そのままビルドすると…

1>------ ビルド開始: プロジェクト: T_ZIP_C, 構成: Debug Win32 ------
1>  T_ZIP_C.cpp
1>d:\document\vs\vs\2012\t_clr\t_zip_c\t_zip_c.cpp(6): fatal error C1190: マネージ ターゲット コードには '/clr' が必要です。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========

fatal error C1190: マネージ ターゲット コードには '/clr' が必要です。
プロジェクトの設定で「/clr」に.

1>------ ビルド開始: プロジェクト: T_ZIP_C, 構成: Debug Win32 ------
1>  T_ZIP_C.cpp
1>T_ZIP_C.cpp(7): fatal error C1107: アセンブリ 'System.IO.Compression.FileSystem.dll' がみつかりませんでした: /AI または LIBPATH 環境変数を使用してアセンブリ検索パスを指定してください。
========== ビルド: 0 正常終了、1 失敗、3 更新不要、0 スキップ ==========

「追加の #using ディレクトリ」に dll の場所を指定して通る様にはなったが,これで良いかがわからない.
fatal error C1107: アセンブリ 'System.IO.Compression.FileSystem.dll' がみつかりませんでした:


ほとんど何も入っていない環境で実行すると,

---------------------------
T_ZIP_C.exe - システム エラー
---------------------------
MSVCR110.dll が見つからないため、コードの実行を続行できません。プログラムを再インストールすると、この問題が解決する可能性があります。 
---------------------------
OK   
---------------------------

MSVCR110.dll が見つからないため、コードの実行を続行できません。
VC 2013 や 2015 でビルドしたものも試してみたが,この環境では実行できなかった.
対応するものを入れる必要があるのか?
https://jml.mish.work/index.php/cpp/ref-vcredist-xxx-exe.html


zip_CLI.hxx

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.