ホーム » Linux

Linux」カテゴリーアーカイブ

2025年6月
1234567
891011121314
15161718192021
22232425262728
2930  

カテゴリー

アーカイブ

ブログ統計情報

  • 117,630 アクセス


mount 先への書き込み

引き続き,環境をどうするか?
現状 Win32 の AP の開発は,次の様に分けている.
Server_TS : 共通のコード(_.SRC 以下)
Server_DS : プロジェクトのソースなど(AppWizard の生成物).
Server_AS : ビルド結果(*.obj,*.exe).
Win11 PC : 一時的なテスト用プロジェクトなど.
今まで,共通のコードは mount して,Linux 固有の部分はそれぞれの環境に置いていた.


Server_DS のテスト環境に,Win10 PC の仮想マシンにあった Linux 環境のファイルをコピー.
次の様に mount .
mount -t cifs //192.168.1.xx/Public/Temp/linux/gcc /home/wao/test/gcc …
コンパイルするとエラーになる.
g++ c84.cpp -lglut -lGL -lGLU
Linux  マウント先への書き込み
コンパイル時に sudo をつければ良い.
ソースの編集は,他環境からのことが多いので,これで良しとするか?


さらに調べていると,よくわからない状態に.
 fatal error: i_define.hxx: No such file or directory
sudo g++ src.cpp とするとエラーになってしまう.
PC の D ドライブにソースを入れた場合や,Linux 環境にコピーした場合などは OK .
PC の D ドライブのソースは OK


この1ページで一通りわかる!Linuxのマウント(mount)について
マウントしたディレクトリを一般ユーザー権限にする
LinuxでNTFSファイルシステムのマウントでアクセス権限やファイルの所有者変更で悩まないために

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

NAS への mount

VirtualBox の Fedora では,次の様なコマンドで Win10 環境の _.src を参照していた.
sudo mount -t cifs -o username=user,password=pass //Z170S0/Public/…/_.SRC /mnt/_.src
今回 Win11 に VHD を移して,この辺りをどうするか調査中…
NAS への mount は,IP で指定しなければうまくいかない?
sudo mount -t cifs -o username=user,password=pass //192.168.1.xx/Public/ /mnt/public
Fedora  mount NAS


WSL で入れた Fedora の環境も同じようにできる.
ll  /mnt/public/
\\wsl.localhost\FedoraLinux-42\mnt\public


同様に Docker で入れた dorowu/ubuntu-desktop-lxde-vnc もやってみたが,こちらはうまくいかない.
mount: /mnt/public: permission denied.
mount: /mnt/public: cannot mount //192.168.1.xx/Public/ read-only.
Unable to apply new capability set.
それならばと思い Nautilus を入れてやってみたが,よくわからない.
dorowu/ubuntu-desktop-lxde-vnc   Nautilus


これらをやっていて久しぶりに思い出したのが「Ctrl」+「Z」や,nautilus & .
コマンドの後ろに & を付加すると bg で動作する.
他に fg や jobs .
xeyes   bg jobs fg
40 年近く前,アセンブルやストックフォームに印刷などで他の人に迷惑をかけた記憶がよみがえってきた.


【SMB / CIFS】LinuxでNASドライブをマウントする
LinuxでのNASへの自動マウントの方法@2024
UbuntuでNASのマウントと注意点
【Linux】【Windows】【CIFS】Windows の共有フォルダを Linux でマウント(mount)する手順
WindowsとLinuxでCIFSを使って簡単にファイル共有する方法

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

Windows で Docker

Win11 環境での続き…
先日から NAS 環境でいろいろとやったので,ある程度すんなりできた.
dorowu/ubuntu-desktop-lxde-vnc を検索してインストール.
「Ubuntu Desktop with noVNC」
「dorowu/ubuntu-des…」を選択してインストール.
「RUN」して「Optional settings」を「↓」.
ポートを 60080 に
「Host port」に「60080」などと入力し「Run」.
60080:80 のリンクをクリック
「60080:80」のリンクをクリックするとブラウザが開く.
ブラウザの中でデスクトップが操作できる
gcc などをインストール.
GLUT を使用したコードビルドして動作することを確認.


Windows 10 homeでWSL2 + DockerDesktopでDocker環境を構築する手順
Comprehensive Guide to dorowu/ubuntudesktoplxdevnc:latest
Windows 11 + Docker + Linux開発の落とし穴
AIロボット入門2024:LXDEデスクトップ環境の使い方
【Docker】公式イメージでUbuntuデスクトップ構築手順

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

Windows で Docker ?

Ubuntu と同様wsl ––install fedora で Fedora をインストールできた(この環境では既に入っている ).

Microsoft Windows [Version 10.0.26100.4349]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Iwao\AppData\Local\Temp>wsl --install fedora
ダウンロードしています: Fedora Linux 42
インストールしています: Fedora Linux 42
指定された名前のディストリビューションは既に存在します。--name を使用して別の名前を選択してください。
エラー コード: Wsl/InstallDistro/Service/RegisterDistro/ERROR_ALREADY_EXISTS

C:\Users\Iwao\AppData\Local\Temp>

wsl --install fedora


gccglut などもインストール.
2014/09 の GLUT のコードを,2019/09 に a.out にしたものがあった.
Fedora から参照できるようにして,起動するとうまく動いた.
WSL 上の Fedora で glut の a.out を実行
ここまで特に何も考えないでやっていたが,Fedora 42 は最近になって WSL から簡単に利用できるようになったみたい.


Fedora in Windows Subsystem for Linux
WSL に標準で対応した Fedora 42 がリリースされたので試してみる(WSL 2 編)


2025/06/13
同様に Ubuntu で GLUT 関係をやったが,freeglut3 がインストールできない.freeglut3-dev は可能.

wao@B660M:~$ sudo apt install freeglut3
[sudo] password for wao:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package freeglut3
wao@B660M:~$ sudo apt install freeglut3-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libegl-dev libgl-dev libgl1-mesa-dev libgles-dev libgles1 libglu1-mesa libglu1-mesa-dev libglut-dev libglut3.12
  libglvnd-core-dev libglvnd-dev libglx-dev libice-dev libopengl-dev libopengl0 libpthread-stubs0-dev libsm-dev libx11-dev
  libxau-dev libxcb1-dev libxdmcp-dev libxext-dev libxt-dev x11proto-dev xorg-sgml-doctools xtrans-dev
Suggested packages:
  libice-doc libsm-doc libx11-doc libxcb-doc libxext-doc libxt-doc
The following NEW packages will be installed:
  freeglut3-dev libegl-dev libgl-dev libgl1-mesa-dev libgles-dev libgles1 libglu1-mesa libglu1-mesa-dev libglut-dev
  libglut3.12 libglvnd-core-dev libglvnd-dev libglx-dev libice-dev libopengl-dev libopengl0 libpthread-stubs0-dev libsm-dev
  libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxext-dev libxt-dev x11proto-dev xorg-sgml-doctools xtrans-dev
0 upgraded, 27 newly installed, 0 to remove and 3 not upgraded.
Need to get 2970 kB of archives.
After this operation, 12.7 MB of additional disk space will be used.
Do you want to continue? [Y/n]

apt install freeglut3


2019/09 の a.out は libglut.so.3 がないため実行できなかった.
libglut.so.3: cannot open shared object file: No such file or directory
GLUT を使用したコードは,Ubuntu 環境でビルドし直すことで起動できるようになった.
g++ c1032.cpp -lglut -lGL -lGLU


【初心者向け】WindowsにDockerをインストールする方法|Docker Desktop編


WSL(Windows Subsystem for Linux)向けにFedoraディストリビューション登場
How to install Fedora on WSL for Windows 10 and Windows 11
MicrosoftがWSLにFedora Linuxを追加、tarベース新アーキテクチャの採用でディストリビューション拡充へ
WSLg を使って Docker 上で GUI アプリを動かす(GPUサポート付き)

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

フォルダの更新日時の設定

以前に作成した mtime を更新するツール
データファイルなどの更新日時を揃えるために作成したもの.
更新日時の設定は CFile::SetStatus で行っている.

	CString		file = UpdateFiles[index] ;
	CFileStatus	fs ;
	CFile::GetStatus(file,fs) ;
	fs.m_mtime = newTime ;
	CFile::SetStatus(file,fs) ;

このツールではフォルダの更新日時は変更できない.


その後 Linux 環境などでも動作する様なコードを作成
utime を使用したもの.
Linux 環境ではフォルダに対してもうまく動作するが,Windows 環境では相変わらず.
DS220  utime
ここまでは,以前調べたもの


2ヶ月ほど前だったと思うが,検索していて次のページを見つけた.
ファイル・フォルダーの更新日時を変更


改めて CFile::SetStatus や _utime の中身を見ると,動作は同じで ::CreateFile と ::SetFileTime を呼出している.
デバッガで追いかけていると ::CreateFile で失敗している.errno は 13 .
::CreateFile を次の様に指定して呼出すと,ファイルの場合は問題ないがフォルダは NG .

HANDLE  hFile = ::CreateFile(file_name,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,     NULL) ;

フォルダの場合 FILE_FLAG_BACKUP_SEMANTICS が指定されていなければならないみたい.

HANDLE  hFile = ::CreateFile(file_name,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL) ;

time_t から FILETIME への変換は次の所.
https://learn.microsoft.com/ja-jp/windows/win32/sysinfo/converting-a-time-t-value-to-a-file-time
SetFTime.hxx


2024/08/09
https://itl.mish.work/i_Tools/Doc/blog/vc/UpdateMT.zip

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

Linux での GLUT 3D データ表示

昨日のコードをもう少し汎用的に修正.そしてそれを他から呼出せるように変更.
次の様なコードで 3D データを生成して,GLUT で表示できる様にした.

bool	test	(void)
{
	Vd2A	pts ;
	{
		pts.push_back(Vd2(  0,  0)) ;
		pts.push_back(Vd2( 70,  0)) ;
		pts.push_back(Vd2( 90, 50)) ;
		pts.push_back(Vd2(100,100)) ;
		pts.push_back(Vd2( 50,100)) ;
		pts.push_back(Vd2( 30, 70)) ;
		pts.push_back(Vd2( 40, 30)) ;
		pts.push_back(Vd2(  0,  0)) ;
		}
	vv_PLF	vvplf ;
	{
		Vd3A	v3a = ::ToVd3A(pts) ;
		Vd4A	v4a = ::ToVd4A(v3a) ;
		PLF	plf_l__ (PLF::line,v4a) ;
		PLF	plf_f__ (PLF::face,v4a) ;
		v_PLF	v_plf ;
			v_plf.push_back(plf_l__) ;
			v_plf.push_back(plf_f__) ;
			vvplf.push_back(v_plf) ;
		}
	tstring	txt_name = ::g3_d_get_txt_name() ;
	{
		tstring	tmp_path = ::Get_i_Tools_tmp_date() ;
		tstring	ipl_name = ::Path_AddLastSP(tmp_path) + ::Now_Format(_T("%H%M%S")) + _T(".ipl") ;
		::To_ipl  (vvplf,ipl_name.c_str()) ;
		::SaveText(txt_name.c_str(),ipl_name) ;
		}
	{
		::exec_g3_d(txt_name.c_str()) ;
		}
	return	true ;
	}

g3_d_gl

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

GLUT を使用した 3D データの表示

個人的なメモです.
4 年位前に作成したコードで,凹多角形がうまく処理できていないものがあったのでその変更.

#include	"glut_cg.hxx"
#include	"gonsa_to.hxx"

#define		TIMING_DN	1000

//	int	_tmain	(int argc, _TCHAR* argv[])
int		main	(int argc,   char* argv[])
{
	{
		GonsA	gnsa ;
		{
			tstring	buf ;	buf.resize(1000) ;
			while (std::terr << _T("file ? =") , std::tin.getline(&buf[0],buf.size()))
			{
				tstring	str = buf.c_str() ;
				if 	(str == _T("q"))    {	break ;		}
				else if (str == _T("Q"))    {	break ;		}
				str = ::QuotM_Del_All(str) ;
				if (str.empty())            {	continue ;	}
				if (::File_IsNothing(str))  {	continue ;	}
				tstring	in_file = str ;
				gnsa = ::To_GonsA(in_file.c_str()) ;
				gnsa = ::GonsA_Triangulation(gnsa) ;		//	2023/06/27
				gnsa = ::GonsA_CalcNormal   (gnsa) ;		//	2023/06/27
				if (gnsa.size() > 0)        {	break ;		}
				}
			if (gnsa.size() == 0)           {	return	0 ;		}
			}
		::set_GonsA(gnsa) ;
		::set_Extent(::GonsA_GetExtent(gnsa)) ;
		}
	::glutInitWindowPosition(200,200) ;
	::glutInitWindowSize    (600,400) ;
	::glutInitDisplayMode   (GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH) ;
	::glutInit              (&argc,argv) ;
	::glutCreateWindow      (argv[0]) ;
	::glutReshapeFunc       (cv_resize) ;
	::glutDisplayFunc       (cg_display) ;
	::glutKeyboardFunc      (cv_keyboard) ;
	::glutMouseFunc         (cv_mouse) ;
	::glutMotionFunc        (cv_motion) ;
	::glutTimerFunc         (TIMING_DN,cv_timer,TIMING_DN) ;
	::cv_init               () ;
	{
		::glEnable(GL_LIGHTING) ;
		::glEnable(GL_LIGHT0) ;
		}
	::glutMainLoop          () ;
	return	0 ;
	}

#include	"messbar.cxx"

t_gl_b_3.cpp
t_gl_b_3.exe

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

Linux VS Code インストール

Fedora 環境に VS Code のインストール.
Fedora Linux に Visual Studio Code をインストールする方法
最初の次のコマンドで,時間がかかっている.
sudo dnf upgrade –refresh
それで調べているともっと簡単と思われる情報が…
Visual Studio Code – Fedora Project Wiki
次のコマンドでインストール.
flatpak install https://flathub.org/repo/appstream/com.visualstudio.code.flatpakref
何とか入った.
Fedora に VS Code のインストール
が,どうやって使うのか…


Ubuntu 環境は OS が古く,20.04 への更新から.
さらに flatpak をインストールする必要があった.
sudo apt install flatpak
そして,
flatpak install https://flathub.org/repo/appstream/com.visualstudio.code.flatpakref
Ubuntu 環境に VS Code のインストール
こちらの方は「日本語化」のインストールの案内が自動で出てきた.
Fedora 環境では,手動で追加.
VS Code  日本語化パッケージのインストール
「言語拡張機能の参照」をクリック.すると,左に「C#」などがリストされる.
VC Code に C# のインストール


.NET のインストール.
Linux に .NET をインストールする
dotnet と入力すると,sudo snap install dotnet-sdk と出てきた.
Ubuntu に dotnet-sdk をインストール
これは違った?


次の所にある C# のコードを作成して VS Code で「デバッグなして実行」.
コンソール アプリ
すると,また同じ所に.
Ubuntu に .NET SDK または .NET ランタイムをインストールする
順に入れたが…

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

sudo apt-get update &&   sudo apt-get install -y dotnet-sdk-6.0

よくわからない.


次の所を参考にコマンドで…
Linux での開発用に C# を設定する
次のコマンドを入力すると…
dotnet new console
そして,
dotnet run
dotnet new console と dotnet run
何とか,コンパイル,実行できることは確認できた.


今度は Fedora 環境に.
Fedora に .NET SDK または .NET ランタイムをインストールする
sudo dnf install dotnet-sdk-6.0
dotnet new console と dotnet run
Fedora で dotnet new console と dotnet run


2022/11/25
Windows 環境だと…
dotnet new winforms
dotnet new <テンプレート>


VS Code はエディタとして使用する程度?
チュートリアル: Visual Studio Code を使用して .NET コンソール アプリケーションを作成する
うまく動作しない.ターミナルからでは dotnet コマンドへのパスが通っていない?

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

簡易 Web サーバ

次の様なものをブラウザで表示するために…
http://mish.html.xdomain.jp/Test/WebGL/Sphere.html


「Web Server for Chrome」は以前書いた.
http://test_wp.mish.work/2022/01/chrome-web.html
Win11 環境で同様に実行すると,次の様な表示が…
「Web Server for Chrome」は現在サポートされていません


開発環境には VS 2022 などが入っているので Python を使用した方法
…\Test\Web\WebGL\ に html などをコピー.
コマンドプロンプトで …\Test に移動.
py -m http.server
これで 127.0.0.1:8000 でアクセスできる.
終了は「Ctrl」+「C」.
py -m http.server


ASUSTOR NAS だと,
python -m http.server
python -m http.server
QNAP NAS や Synology NAS でも同様.Raspberry Pi にもあった.


検索すると System.Net.HttpListener.dll と言うのが見つかる.
それを使っていると思われる次の所からコードを拝借.
Windows 標準で Web サーバを起動する
System.Net.HttpListener.dll
勉強を兼ねて,ちょっとやってみるか.


2023/01/17
https://jml.mish.work/index.php/i-tools/web-svr.html
C++/CLI で作成した 簡易 Web サーバ

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

Fedora 34 で GLUT が動作しない?

仮想マシンの Fedora 32 を 34 に更新.
動作を確認していると,GLUT を使用した .out がうまく動作しない.
起動はしているが,ウィンドウが表示されない?
コンパイルなどはできている.
実行するとコンソールにはウィンドウを表示する前の部分は表示される.
いろいろやったがダメで,再起動.
Fedora 34 GLUT
うまく表示する様になった.

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

::GetDiskFreeSpaceEx , ::statvfs

Win9x が多く存在していた頃のコードの MFC を使用しない方法での書き直し.
前のものは次の様になっている.

//	J048221	SDK32:GetDiskFreeSpace と GetDiskFreeSpaceEx について
typedef BOOL (WINAPI *P_GDFSE)(LPCTSTR, PULARGE_INTEGER,PULARGE_INTEGER, PULARGE_INTEGER);
// ..
	fResult = ::GetDiskFreeSpace(pszDrive,&SectorsPerCluster,&BytesPerSector,&FreeClusters,&TotalClusters) ;
	if (fResult) {
		TotalBytes    	= (__int64)TotalClusters * SectorsPerCluster * BytesPerSector ;
		TotalFreeBytes	= (__int64)FreeClusters  * SectorsPerCluster * BytesPerSector ;
		FreeBytesAvailable = TotalFreeBytes ;
		}
// ..
{
	P_GDFSE	pGetDiskFreeSpaceEx = NULL;
	#ifdef UNICODE
		pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress(GetModuleHandle(_T("kernel32.dll")),"GetDiskFreeSpaceExW") ;
	#else
		pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress(GetModuleHandle(_T("kernel32.dll")),"GetDiskFreeSpaceExA") ;
	#endif
	if (pGetDiskFreeSpaceEx) {
		fResult = pGetDiskFreeSpaceEx (pszDrive,
			(PULARGE_INTEGER)&FreeBytesAvailable,
			(PULARGE_INTEGER)&TotalBytes,
			(PULARGE_INTEGER)&TotalFreeBytes);
		}
	}

J048221 SDK32:GetDiskFreeSpace と GetDiskFreeSpaceEx について
https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/231497


Windows 環境では次の様な感じ?

class	DiskFree	{
public:
	DiskFree ()	{	Free = Total = 0 ;	}
public:
	u_64	Free ;
	u_64	Total ;
	} ;

DiskFree	GetDiskFree	(LPCTSTR path)
{
	DiskFree	df ;
	u_64		freeC = 0 ;
	u_64		free  = 0 ;
	u_64		total = 0 ;
	if (::GetDiskFreeSpaceEx(path,(PULARGE_INTEGER)&freeC,(PULARGE_INTEGER)&total,(PULARGE_INTEGER)&free)) {
		df.Free = free ;
		df.Total= total;
		}
	return	df ;
	}

Linux 環境では ::statvfs が使えるみたいで,次の様なコードで取得してデバッガで確認.

#include    <iostream>
#include    <sys/statvfs.h>

int main()
{
	struct statvfs	vfs = { 0 } ;
	::statvfs(".", &vfs) ;
	return 0 ;
	}
vfs     	{...}           	statvfs
  f_bsize 	4096            	unsigned long
  f_frsize	4096            	unsigned long
  f_blocks	1452408524      	__fsblkcnt_t
  f_bfree 	200259802       	__fsblkcnt_t
  f_bavail	199469255       	__fsblkcnt_t
  f_files 	183001088       	__fsfilcnt_t
  f_ffree 	181248356       	__fsfilcnt_t
  f_favail	181248356       	__fsfilcnt_t
  f_fsid  	3941329918106335254	unsigned long
  f_flag  	4096            	unsigned long
  f_namemax	255             	unsigned long
  __f_spare	                 	int [6]
    [0]   	0               	int
    [1]   	0               	int
    [2]   	0               	int
    [3]   	0               	int
    [4]   	0               	int
    [5]   	0               	int

Debian10 ::statvfs

Iwao@AS5202T:/volume1/home/Iwao $ cd gcc_test/Test/t_linux/T_vfs/T_s_vfs/
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/T_vfs/T_s_vfs $ ll
total 12
drwxrwxrwx    2 Iwao     users       4.0K Jul  1 22:01 ./
drwxrwxrwx    4 Iwao     users       4.0K Jul  1 22:00 ../
-rwxrwxrwx    1 Iwao     users        581 Jul  1 21:55 T_s_vfs.cpp*
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/T_vfs/T_s_vfs $ cat T_s_vfs.cpp
#include    <iostream>
#include    <clocale>

#include    <sys/statvfs.h>

#include    "_tdefine.hxx"
#include    "t_tstrng.hxx"

int     _tmain  (int argc,TCHAR* argv[])
{
        _tsetlocale(LC_ALL,_T("")) ;
        {
                struct  statvfs vfs = { 0 } ;
                if (::statvfs(".", &vfs) == 0) {
                        u_64    free = vfs.f_bavail * vfs.f_frsize ;
                        u_64    total= vfs.f_blocks * vfs.f_frsize ;
                        std::tout << ::To_tstring_Ki(free) << _T(" / ") << ::To_tstring_Ki(total) << std::endl ;
                        std::tout << ::To_tstring_cs(free) << _T(" / ") << ::To_tstring_cs(total) << std::endl ;
                        }
                }
        return  0 ;
        }
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/T_vfs/T_s_vfs $ g++ T_s_vfs.cpp -Wall
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/T_vfs/T_s_vfs $ ./a.out
760.90 G /   5.41 T
817,005,420,544 / 5,949,065,314,304
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/T_vfs/T_s_vfs $

AS5202T  ::statvfs
diskfree.hxx

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

NAS lxcdebian10 と VC 2019

ASUSTOR NAS 上の Debian と VC 2019 を使用してのビルドとデバッグ.
VC で次の様なエラーになっている.

lxcdebian10 にツールがありません: gdb rsync zip

lxcdebian10 にツールがありません: gdb rsync zip
次の所にある様に必要なものをインストール.
Linux development with C++ in Visual Studio
gdb rsync zip のインストール
丁度 1 年前にやっていた みたいで,その時より 安定したか?

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

C2664

スタックを使用した次の様なコード.

	stack_s	so ;

エラー情報を指定する様に変更してビルド.

	i_error	ie ;
	stack_s	so(&ie) ;
--------------------Configuration: t_stack - Win32 Debug--------------------
Compiling...
t_stack.cpp
d:\document\vs\vs\1998\t_stack\t_stack\t_stack.cpp(14) : error C2664: '__thiscall stack_s::stack_s(const class stack_s &)' : cannot convert parameter 1 from 'class i_error *' to 'const class stack_s &'
        Reason: cannot convert from 'class i_error *' to 'const class stack_s'
        No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.

T_stack.exe - 1 error(s), 0 warning(s)

C2664 になってしまう.

class	stack_b	{
public:
		stack_b		(i_error* i_err=NULL)	{	ie = &tmp_ie ;	if(i_err != NULL) {	ie = i_err ;	}	}
protected:
	i_error		tmp_ie ;
	i_error*	ie ;
	} ;

class	stack_s	:	public	stack_b	{
public:
//		stack_s		(i_error* i_err=NULL)	:	stack_b	(i_err)		{	;	}
public:
	virtual	bool	push	(c_tstring& s) ;
	virtual	tstring	pop 	(void) ;
	virtual	tstring	last	(void) ;
protected:
	s_tstring	stck_s ;
	} ;

コメントにしている stack_s のコンストラクタを追加すれば OK .
C2664  stack
独習 C++ 7.3 223 ページ

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

OPENFILENAME

コンソール AP では,標準入力を使用していた.

#include	"quotm.hxx"
#include	"existff.hxx"

inline	bool	Test	(void)
{
	while(true)	{
		tstring	str ;
		{
			tstring	buf ;
			buf.resize(1000) ;
			std::terr << _T("file ...=") ;
			std::tin.getline(&buf[0],std::streamsize(buf.size())) ;
			str = buf.c_str() ;
			if   	(str == _T("q"))	{	break ;		}
			else if (str == _T("Q"))	{	break ;		}
			str = ::QuotM_Del_All(str) ;
			if (str.empty())   		{	continue ;	}
			}
		{
			if (::File_IsNothing(str)) 	{	continue ;	}
			std::tout << str << std::endl ;
			}
		}
	return	true ;
	}

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	{
		Test() ;
		}
	return	0 ;
	}

以前作成した CFileDialog を使用したもの.

#include	<afxwin.h>
#include	"F_Dialog.hxx"
#include	"quotm.hxx"

inline	bool	Test	(void)
{
	while(true)	{
		tstring	str ;
		{
			str = ::FD_GetOpenFile(_T("./")) ;
			if (str.empty())   		{	break ;		}
			}
		{
			if (::File_IsNothing(str))	{	continue ;	}
			std::tout << str << std::endl ;
			}
		}
	return	true ;
	}

CWinApp theApp;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) {
		std::terr << _T("error : AfxWinInit") << std::endl ;
		nRetCode = 1;
		}
	else  {
		Test() ;
		}
	return nRetCode;
	}

////////////////////////////////////////////////////////////////////////////////////////

#include	<AfxExt.h>
#include	"BrowseFF.cxx"

これを MFC を使用しない方法での書き換え.


「開く」ダイアログを表示するだけのコード.

{
	OPENFILENAME	ofn =	{	0	} ;
	ofn.lStructSize = sizeof(OPENFILENAME) ;
	if (!::GetOpenFileName(&ofn))	{	return	tstring() ;	}
//	...
	}

OPENFILENAME の指定が複雑なので,使いそうな内容でまとめてみた.

OPENFILENAME
lStructSize sizeof(OPENFILENAME)
hwndOwner NULL の時,モードレスになる.
CFileDialog では DoModal で求めている.
lpstrFile 選択されたファイル名が入る.
OFN_ALLOWMULTISELECT の場合は,下のメモリイメージ.
nMaxFile lpstrFile で確保している領域の文字数

OFN_ALLOWMULTISELECT の場合の結果の lpstrFile .

0x02C00078  44 3a 5c 44 6f 63 75 6d 65 6e 74 5c 56 53 5c 56  D:\Document\VS\V
0x02C00088  53 5c 32 30 30 35 5c 54 5f 4f 70 65 6e 46 5c 54  S\2005\T_OpenF\T
0x02C00098  5f 4f 46 5f 4d 46 43    54 5f 4f 46 5f 4d 46 43  _OF_MFC.T_OF_MFC
0x02C000A8  2e 42 41 4b    54 5f 4f 46 5f 4d 46 43 2e 63 70  .BAK.T_OF_MFC.cp
0x02C000B8  70    54 5f 4f 46 5f 4d 46 43 2e 76 63 70 72 6f  p.T_OF_MFC.vcpro
0x02C000C8  6a    54 5f 4f 46 5f 4d 46 43 2e 76 63 70 72 6f  j.T_OF_MFC.vcpro
0x02C000D8  6a 2e 5a 31 37 30 53 30 2e 49 77 61 6f 2e 75 73  j.Z170S0.Iwao.us
0x02C000E8  65 72       00 00 00 00 00 00 00 00 00 00 00 00  er..............

0x027E6B50  44 00 3a 00 5c 00 44 00 6f 00 63 00 75 00 6d 00 65 00 6e 00 74 00 5c 00 56 00 53 00 5c 00 56 00  D:\Document\VS\V
0x027E6B70  53 00 5c 00 32 00 30 00 30 00 35 00 5c 00 54 00 5f 00 4f 00 70 00 65 00 6e 00 46 00 5c 00 54 00  S\2005\T_OpenF\T
0x027E6B90  5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00 00 00 54 00 5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00  _OF_MFC.T_OF_MFC
0x027E6BB0  2e 00 42 00 41 00 4b 00 00 00 54 00 5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00 2e 00 63 00 70 00  .BAK.T_OF_MFC.cp
0x027E6BD0  70 00 00 00 54 00 5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00 2e 00 76 00 63 00 70 00 72 00 6f 00  p.T_OF_MFC.vcpro
0x027E6BF0  6a 00 00 00 54 00 5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00 2e 00 76 00 63 00 70 00 72 00 6f 00  j.T_OF_MFC.vcpro
0x027E6C10  6a 00 2e 00 5a 00 31 00 37 00 30 00 53 00 30 00 2e 00 49 00 77 00 61 00 6f 00 2e 00 75 00 73 00  j.Z170S0.Iwao.us
0x027E6C30  65 00 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  er..............

lpstrFile	0x02c10078 "D:\Document\VS\VS\2005\T_OpenF\T_OF_MFC\ReadMe.txt"	char *

デバッガで OPENFILENAME_SIZE_VERSION_400 となる様にしたもの.
OPENFILENAME_SIZE_VERSION_400


MFC 9 で bVistaStyle を FALSE とすると
CFileDialog bVistaStyle == FALSE
VC 8 exe と同様の,左側がフォルダツリーではない表示のもの.
デフォルトの TRUE だと
CFileDialog bVistaStyle == TRUE
COM を利用したもの?
Common Item Dialog


今度は MFC を使用しない方法.
::GetOpenFileName を使用する方法で OFN_ALLOWMULTISELECT を指定すると実行されなかった.
見た目のエラーにはならない?が,API を呼んで FALSE で抜けてくる.
::CommDlgExtendedError で調べると FNERR_INVALIDFILENAME だった.
存在しないファイル名などを与えるとうまくないみたい.
まだ何か足りないみたいで Win3.x 頃の表示になってしまった.
GetOpenFileName  Win3.x
選択したファイル名などもスペースで区切られている.
OFN_ALLOWMULTISELECT を指定する時は OFN_EXPLORER も指定する必要があるみたい.
次の所に書かれていた.
OPENFILENAMEW structure (commdlg.h)
OFN_ALLOWMULTISELECT | OFN_EXPLORER の場合 lpstrFile に存在しないファイル名でも問題なさそう.


複数選択可能な「開く」ダイアログのコードは次の様な感じ.

tstring	GetOpenFile	(LPCTSTR default_name=_T("./"))
{
	HWND	hwnd = ::GetConsoleHwnd() ;
	tstring	str_file = default_name ;
	    	str_file.resize(260*100) ;
	OPENFILENAME	ofn =	{	0	} ;
	{
		ofn.lStructSize	= sizeof(OPENFILENAME) ;
		ofn.hwndOwner	= hwnd ;
		ofn.nMaxFile	= DWORD(str_file.size()) ;
		ofn.lpstrFile	= &str_file[0] ;
		ofn.Flags   	= OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_HIDEREADONLY ;
		}
	if (!::GetOpenFileName(&ofn)) {
		DWORD	err = ::CommDlgExtendedError() ;
		std::terr << ::To_tstring(u_32(err),16) << std::endl ;
		return	tstring() ;
		}
	tstring	sel_file ;
	{
		sel_file = ofn.lpstrFile ;
	//	...
		}
	return	sel_file ;
	}

拡張子のフィルタなどは指定していない.また,選択されたファイルを取得するコードもこれから.


選択されたファイルを取得するコード.

tstring	String_Change	(c_tstring& str_,const TCHAR src,const TCHAR dst)
{
	tstring	str = str_ ;
	for (size_t index=0 ; index<str.size() ; index++) {
		TCHAR	ch = str[index] ;
		if (ch == src) {
			str[index] = dst ;
			}
		}
	return	str ;
	}

	tstring	sel_file ;
	{
		sel_file = ofn.lpstrFile ;
		sel_file = str_file ;
		sel_file = ::String_Change(ofn.lpstrFile,_T('\x0'),_T('\n')) ;
		sel_file = ::String_Change(str_file,     _T('\x0'),_T('\n')) ;
		sel_file = ::String_TrimBoth(sel_file) ;
		}

ofn.lpstrFile は ASCIIZ となってしまうので,str_file をそのまま使用する必要がある.
Win3.x 形式の lpstrFile のダンプ.

0x02311F00  0043 003a 005c 0055 0053 0045 0052 0053 005c 0050 0055 0042 004c 0049 0043 005c  C.:.\.U.S.E.R.S.\.P.U.B.L.I.C.\.
0x02311F20  0044 004f 0043 0055 004d 0045 004e 0054 0053 005c 0020 0042 0061 0063 006b 0043  D.O.C.U.M.E.N.T.S.\. .B.a.c.k.C.
0x02311F40  0050 002e 0062 0061 0074 002e 006c 006e 006b 0020 0057 0049 004e 0031 0030 002d  P...b.a.t...l.n.k. .W.I.N.1.0.-.
0x02311F60  007e 0031 002e 004c 004e 004b 0020 005a 0031 0037 0030 0044 004f 007e 0031 002e  ~.1...L.N.K. .Z.1.7.0.D.O.~.1...
0x02311F80  004c 004e 004b 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  L.N.K...........................

区切りがスペースになるため,ファイル名などにスペースが含まれている場合は 8.3 形式 になる.


lpstrFilter を指定.

	tstring	filter ;
		filter	+= _T("Executable Files (*.exe)|*.exe|") ;
		filter	+= _T("All Files (*.*)|*.*|") ;
		filter	+= _T("|") ;
		filter   = ::String_Change(filter,_T('|'),_T('\x0')) ;
	OPENFILENAME	ofn =	{	0	} ;
	{
		ofn.lStructSize	= sizeof(OPENFILENAME) ;
	//	...
		ofn.lpstrFilter	= &filter[0] ;
		}

ここまでのものを WinXP 環境で表示すると
GetOpenFileName WinXP


WFDialog.hxx


[ファイルを開く]ダイアログ
GetOpenFileName
ファイルを開くダイアログの使用方法

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

Ubuntu Linux Station

先日 Linux Station がうまく動作しなくなったように思ったが…
ファームアップデート後,試しに起動するとうまくいった.
先日は,メモリが足りなかったとかだったのか?


GLUT を使える様に インストール
sudo apt install freeglut3 freeglut3-dev
Ubuntu Lunux Station GLUT
ASUSTOR NAS Linux Center Debian 環境の a.out を実行.

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

なんかおかしい? DS116 localtime

2020/12/02 0 時過ぎ,個人的に書いているコードがうまく動作していないことに気づいた.
全てではないが,日時の表示が GMT になってしまっている?
うまく動作しているものもあり,次のものは正しく表示される.
DrawNow アクセス日時を WebGL で表示する
この様になった心当たりはある.
昨日 opkg の update と upgrade ,opkg install gcc などを行ったことが影響している?
tree … -D や cal なども GMT になっている.


どこが影響しているかを調べるために少しコードを書いてみた.

#include	<clocale>
#include	<iostream>
#include	"_tdefine.hxx"
#include	"timefmt.hxx"

int	_tmain	(int argc,TCHAR* argv[])
{
	_tsetlocale(LC_ALL,_T("")) ;
	{
		tstring	now_time = ::Now_Format() ;
		std::tout << _T("::Now_Format()   \t") << now_time << std::endl ;
		}
	{
		tstring	gmt_time = ::Now_FormatGMT() ;
		std::tout << _T("::Now_FormatGMT()\t") << gmt_time << std::endl ;
		}
	return	0 ;
	}

Win10 環境では意図した動作.

Microsoft Windows [Version 10.0.18363.1198]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Iwao>\\TestXP\C_Temp\Test_cpp\t_mtime\t_localt\Release.060\t_localt.exe
::Now_Format()          2020/12/02 10:22:34
::Now_FormatGMT()       2020/12/02 01:22:34

C:\Users\Iwao>  

Win10 で localtime


DS116 では localtime が正しく求まっていない.

Iwao@DS116:~/gcc_test/Test/t_linux/t_mtime/t_localt$ ll
total 44
drwxrwxrwx+ 2 Iwao users  4096 Dec  2 10:19 .
drwxrwxrwx+ 5 Iwao users  4096 Dec  2 10:03 ..
-rwxrwxrwx  1 Iwao users 14188 Dec  2 10:19 a.out
-rwxrwxrwx+ 1 Iwao users   892 Dec  2 10:02 t_localt.BAK
-rwxrwxrwx+ 1 Iwao users   917 Dec  2 10:17 t_localt.cpp
-rwxrwxrwx+ 1 Iwao users  4476 Dec  2 10:02 t_localt.dsp
Iwao@DS116:~/gcc_test/Test/t_linux/t_mtime/t_localt$ ./a.out
::Now_Format()          2020/12/02 01:24:30
::Now_FormatGMT()       2020/12/02 01:24:30
Iwao@DS116:~/gcc_test/Test/t_linux/t_mtime/t_localt$  

DS116 で localtime


上の WebGL で現在日時を表示ている .out は,2017/07/19 にコンパイルしたもの.
他の .out で,古いものは正しく動作し,2020/02 のものはうまくない.


どこかに設定などがあるのか?


2020/12/09
GMT と同じ扱いになり困っていたのは,個人的なコードの i_drawlg.hxx
今日のファイルを求める所で 24*60*60 を加えることで対応.

DS220+


2022/06/15 DS116 entware
entware の更新で正しく動作する様になった.

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

NAS 上で OpenMP ?

今まで Windows 上で動かしていた OpenMP 対応のコードを,NAS 上で…
QNAP NAS 上にソースをコピーしてコンパイルすると

[Iwao@TS253D T_cmb_f]$ g++ T_cmb_f.cpp -Wall -fopenmp
In file included from T_cmb_f.cpp:12:0:
/share/Public/CloudD/GoogleD/Develop/_.SRC/Test/t_g3d_et.hpp:12:10: fatal error: omp.h: No such file or directory
 #include <omp.h>
          ^~~~~~~
compilation terminated.
[Iwao@TS253D T_cmb_f]$ 

もう少し単純なコードで…

#ifdef		_OPENMP
#include	<omp.h>
#endif

#include	<clocale>
#include	<iostream>
#include	"i_define.hxx"

bool	Test	(void)
{
	#ifdef	_OPENMP
		#pragma	omp	parallel for
	#endif
	for (long index=0 ; index<20 ; index++)	{
		#ifdef	_OPENMP
			#pragma	omp	critical	(wait)
		#endif
		std::cout << index << std::endl ;
		}
	return	true ;
	}

int	_tmain	(int argc,TCHAR* argv[])
{
	_tsetlocale(LC_ALL,_T("")) ;
	{
		::Test() ;
		}
	return	0 ;
	}
[Iwao@TS253D T_cmb_f]$ cd ../T_omp/
[Iwao@TS253D T_omp]$ g++ T_omp.cpp -Wall -fopenmp
T_omp.cpp:10:10: fatal error: omp.h: No such file or directory
 #include <omp.h>
          ^~~~~~~
compilation terminated.
[Iwao@TS253D T_omp]$

NAS OpenMP コンパイルで "fatal error: omp.h: No such file or directory"


Raspberry Pi で同様に行うと問題ない.
Raspberry Pi 上で OpenMP コンパイル


これとは直接関係ないが,
普通にコンパイルした T_cmb_f を QNAP NAS で実行すると,CPU などの温度が正しく表示されない状態に陥った.



2021/05/24
Ubuntu Linux Station ではうまく動作する.
Linux Station OpenMP
Linux Center でも動作する.
Linux Center OpenMP

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

フォルダの更新日時の変更

今までファイルの更新日時の変更は使っていた.
https://www.vector.co.jp/soft/winnt/util/se500182.html
が,このツールでフォルダの更新日時を変更しようとするとできない.
コードは CFile::SetStatus を使用している.

	CFileStatus	fs ;
	CFile::GetStatus(file,fs) ;
	fs.m_mtime = newTime ;
	CFile::SetStatus(file,fs) ;

CFile::SetStatus の中(…\atlmfc\src\mfc\filest.cpp)を見ると ::SetFileTime を使用している.
また Linux などでも使える utime(…\crt\src\utime.c)も ::SetFileTime を使っている.
VC 6 で作成したものをデバッガで追いかけると ::CreateFile で 0xffffffff が返ってきている.


ASUSTOR NAS で試すと,特に問題なく変更できる.

Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/t_mtime/t_utime $ cat t_utime.cpp
#include        <clocale>

#include        "i_trace.hxx"
#include        "filetime.hxx"
#include        "itls_tmp.hxx"
#include        "c_which.hxx"

int     _tmain  (int argc,TCHAR* argv[])
{
        _tsetlocale(LC_ALL,_T("")) ;
        {
                tstring temp_path = ::Get_i_Tools_tmp_date() ;
                tstring fold_path = ::Path_AddLastSP(temp_path) + ::Now_Format(_T("%H%M%S")) ;
                tstring file_path = ::Path_AddLastSP(temp_path) + ::Now_Format(_T("%H%M%S")) + _T(".tmp") ;
                {
                        ::Folder_Create   (fold_path) ;
                        ::File_CreateEmpty(file_path) ;
                        }
                {
                        time_t  f_time = ::File_GetMTime(file_path.c_str()) ;
                                f_time-= 3600*24*7 ;
                        ::File_SetMTime(file_path.c_str(),f_time) ;
                        ::File_SetMTime(fold_path.c_str(),f_time) ;
                        }
                {
                        tstring cmd     = tstring(cmd_ls_la) + _T(" ") + ::QuotM_Add_Auto(temp_path) ;
                        _tsystem(cmd.c_str()) ;
                        }
                }
        return  0 ;
        }
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/t_mtime/t_utime $ g++ t_utime.cpp -Wall
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/t_mtime/t_utime $ ll
total 136
drwxrwxrwx    2 Iwao     users       4.0K Nov  7 16:24 ./
drwxrwxrwx    3 Iwao     users       4.0K Nov  7 15:32 ../
-rwxr-xr-x    1 Iwao     users     122.7K Nov  7 16:24 a.out*
-rwxrwxrwx    1 Iwao     users        838 Nov  7 16:22 t_utime.cpp*
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/t_mtime/t_utime $ ./a.out
total 0
drwxr-xr-x    3 Iwao     users           80 Nov  7 16:24 .
drwxr-xr-x    3 Iwao     users           60 Nov  7 16:24 ..
drwxr-xr-x    2 Iwao     users           40 Oct 31 16:24 162451
-rw-------    1 Iwao     users            0 Oct 31 16:24 162451.tmp
Iwao@AS5202T:/volume1/home/Iwao/gcc_test/Test/t_linux/t_mtime/t_utime $                                  

ASUSTOR NAS AS5202T 上で utime
今日はここまで.


2024/01/04
フォルダの更新日時の設定

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

Python venv

次の所を参考にして…
VS CodeとFlaskによるWebアプリ開発「最初の一歩」
https://kazuhira-r.hatenablog.com/entry/2019/01/09/231800


cd %TMP% で移動し temp\test\ 以下に作成.
py -m venv temp\test
Win10 環境で py -m venv ...
Linux 環境では,~/Documents/tmp/test/
cd ~/Documents/tmp
python3 -m venv test
Ubuntu 環境で python3 -m venv ...


Win10   .\test\Scripts\activate
Ubuntu  source ./test/bin/activate

Flask の起動は,環境変数 FLASK_APP を設定して flask run らしい.
サンプルにある内容 を python3 sample.py との違いは?


2020/08/24
VS 2017 での仮想環境の作成は「ソリューション エクスプローラー」-「Python 環境」の「右クリック」にある.
VS 2017 Python 仮想環境を追加

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

Python tkinter インストール

sudo apt install python3-tk
Debian 環境に tkinter インストール
Ubuntu 環境に tkinter インストール


Windows から Raspberry Pi 環境に接続できる様に samba を追加しようと…
検索して次の所を参考に設定.
https://qiita.com/fstyle/items/1670d260f58f77a43144
https://www.raspberrypirulo.net/entry/samba
この中で書かれている nano というエディタ.
CUI で使えるみたいで NAS などの幾つかの環境にインストール.
sudo opkg install nano


他に CUI のファイルマネージャ.
sudo opkg install mc
操作性など異なるが,エコロジーⅡを思い出す.
https://unilab.gbb60166.jp/T98Next/T98Next2.htm

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