ホーム » gcc (ページ 3)

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

2024年4月
 123456
78910111213
14151617181920
21222324252627
282930  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,435 アクセス



Windows , Linux 共通の c++ コード

3 年位前から,少しずつ Windows や Linux に依存しない c++ のコードを書く様にしている.
ソースファイルの文字コードと改行コードは 7 ビットの範囲で crlf にしている.
.sh などは lf でないとうまくない.
html などの場合は UTF-8 .
扱うファイル名も 7 ビットの範囲に限定している.
これで UI を伴わない範囲ではほぼうまく機能している.
次のページからのリンク先で WebGL を使用したサーバのコードはソースレベルで互換性あり.
https://itl.mydns.jp/i_Tools/

他に Windows 専用のコードとの区別のため,ファイル名を小文字に.
これは Linux では大文字,小文字が区別されるため.


今回既存の AP ドキュメントを扱うことに.
Windows でいう「シフト JIS」と「UNICODE」のテキストファイル.
他に UTF-8 のファイルもあるが対応する必要性は未定.
UTF-8 ファイルは Windows のコードでは書いているが,テスト用に存在するのみ.


今までの Windows のコード(tstrmbwc.hxx)では _T や _UNICODE の有無でうまく機能している.
読み込んだ時に _UNICODE の有無でそれぞれの文字コードで保持すればほぼ OK .
「ほぼ」というのは「㎥」の様にシフト JIS にない文字は失われてしまうため.
他にもサロゲートペアにはうまく対応できていない.


Linux でも同様に考えると,読み込んだ時に UTF-8 にすれば良さそう.
wchar_t もあるみたいだが今の時点では考慮しないことにする.
と,思ってテスト用のコードを書いてみたがうまく動作しない.
恐らく変換関連の考え方が理解できていないため.


2020/02 「文字コードを変更してコピー」するツール
https://i–tools.blogspot.com/2020/02/copycc202001.html
「文字コードを変換してコピー」するツール

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

Win10 に IIS と PHP – 3

どこかに設定があるのかもしれないが,
PHP でのエラーなどのログファイル.
場所は c:\Windows\Temp\ .
Win10 IIS PHP のログファイル
今回テストした PHP のコード

<?php
	$tempfile =             $_FILES['fname']['tmp_name'];
	$filename = './data/' . $_FILES['fname']['name'] ;
	$up_status = false ;
	if (is_uploaded_file($tempfile)) {
		$up_status = move_uploaded_file($tempfile , $filename) ;
		}
	$link	= "" ;
	if ($up_status) {
		$p_info = pathinfo($filename) ;
		$pi_ext = $p_info['extension'] ;
		$bmp_name = $filename . ".bmp" ;
		$to_bmp = FALSE ;
		if  	($pi_ext == "png")  {	$img = imagecreatefrompng ($filename) ;   $to_bmp = imagebmp($img,$bmp_name) ;	}
		else if	($pi_ext == "jpg")  {	$img = imagecreatefromjpeg($filename) ;   $to_bmp = imagebmp($img,$bmp_name) ;	}
		else if ($pi_ext == "bmp")  {	$bmp_name = $filename ;                   $to_bmp = TRUE ;                 	}
		if ($to_bmp) {
			$cmd_to	= ("rsz_bmp.exe") . " " . $bmp_name ;
			exec	($cmd_to,$out,$ret) ;
			}
		if ($ret == 0) {
			$rsz_file = $out[count($out)-1] ;
			$bak_file = $filename . ".bak." . $pi_ext ;
			rename($filename,$bak_file) ;
			$rsz_name = pathinfo($rsz_file)['basename'] ;
			$file_rsz = $p_info['dirname'] . "/" . $rsz_name ;
			rename($rsz_file,$file_rsz) ;
			if    	($pi_ext == "png")  {	$img_bmp = imagecreatefrombmp($file_rsz) ;   imagepng ($img_bmp,$filename) ;	}
			else if	($pi_ext == "jpg")  {	$img_bmp = imagecreatefrombmp($file_rsz) ;   imagejpeg($img_bmp,$filename) ;	}
			else if ($pi_ext == "bmp")  {	copy($file_rsz,$filename) ;                                             	}
			if (!file_exists($filename)) {
				$filename = $file_rsz ;
				}
			}
		if (file_exists($filename)) {
			$link .= "<hr/>" ;
			$link .= "<a href='" ;
			$link .= $filename ;
			$link .= "'>" ;
			$link .= $filename ;
			$link .= "</a>" ;
			$link .= "<br/>" ;
			$link .= "<img src='" ;
			$link .= $filename ;
			$link .= "'>" ;
			}
		}
	?>

rsz_bmp.exe で画像ファイルを 2^n にリサイズし,その結果のファイル名を標準出力に出力する.
画像を出力する imagebmp などはあまり速くない.
同様の PHP を Synology NAS 上で.
https://itl.mydns.jp/…/tex_pow2.php
PHP のコードが悪いのか? Synology NAS では DIB から元の画像に戻すのがうまくいかない.

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

VS 2019 Raspberry Pi への接続で…

VS 2019 の「オプション」-「クロスプラットフォーム」-…-「リモートヘッダー…」の「更新」を選択すると,
エラーが発生しました。Could not connect to the remote system or the connection was lost。詳細については、C:\Users\Iwao\AppData\Local\Temp\vslinux_header_update_log.txt を参照してください。トラブルシューティングについては、https://aka.ms/AA23jat をご覧ください。
「InteliSense 用のヘッダーのダウンロードおよび更新」でエラー
SSH コマンドで接続しようとするとやはり接続できない.IP では可能.

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

C:\Users\Iwao>ssh -l pi raspberrypi
ssh: Could not resolve hostname raspberrypi: \202\273\202\314\202\346\202\244\202\310\203z\203X\203g\202\315\225s\226\276\202\305\202\267\201B

C:\Users\Iwao>ssh -l pi 192.168.1.36
pi@192.168.1.36's password:
Linux raspberrypi 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Nov 12 17:04:32 2019

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

pi@raspberrypi:~ $

ちょっとわからないので,IP での接続を追加して対応.
IP で「リモートシステムへの接続」を追加

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

Linux から NAS 上のアクセス

Linux から NAS 上のファイルを読み込むコード


Windows からであれば次の様な指定が可能.
tstring test_imo = _T(“//DS116/web/i_Tools/Doc/blog/3D_Data/Test_cube_line.imo”) ;
使用する関数や API によっては “\\” でないとうまくない場合もある.
tstring test_imo = _T(“\\\\DS116\\web\\i_Tools\\Doc\\blog\\3D_Data\\Test_cube_line.imo”) ;


Linux では mount すれば次の様な指定が可能なことは以前に調べている.
tstring test_imo = _T(“/mnt/ds116/web/i_Tools/Doc/blog/3D_Data/Test_cube_line.imo”) ;
今回は異なる方法で何か方法はないかと調べてみた.
結果としては「ファイルマネージャ」などでアクセスできる状態にする必要があるのであまり mount と変わらない.


調べたのは次の様な手順.
「端末」を開いて ls と入力.
そこに「ファイルマネージャ」からディレクトリをドロップ.
「端末」で「Enter」するとアクセスできることを確認.
Linux から NAS 上のディレクトリの ls
tstring test_imo = _T(“/run/user/1000/gvfs/smb-share:server=ds116.local,share=web/i_Tools/Doc/blog/3D_Data/Test_cube_line.imo“) ;

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

VC Linux でのデバッグ

単純な「Linux ターミナル」の「コンソール AP」であれば,Windows コンソール AP と同様にデバッグできる.
出力は VS の「Linux コンソールウィンドウ」.
VC Linux コンソール AP のデバッグ


GLUT を使用したデバッグはこの方法ではできない?
::glutInit(&argc, argv); で抜けてしまう.
Linux 上で .out を起動しておいて VS の「デバッグ」-「プロセスにアタッチ」.
「接続の種類」を「SSH」にして「接続先」を Linux 環境に.
VC Linux デバッグ対象の .out にアタッチ
「使用可能なプロセス」が更新されるのでデバッグ対象の .out を選択して「アタッチ」でデバッグできる.

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

VC Linux で GLUT

GLUT を使用したコード
ビルドするとリンクでのエラーとなってしまう.

1>------ ビルド開始: プロジェクト: T_GL2, 構成: Debug x64 ------
1>ソースを検証します
1>リモートでソースを 'fedora' にコピーします
1>アーキテクチャを検証します
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\Linux.targets(184,5): warning : 配置で使用されるリモート システムに互換性のないプラットフォーム アーキテクチャ ('x64'、'ARM') があります。
1>アーキテクチャを検証します
1>リモート ビルドを開始しています
1>ソースをコンパイルします:
1>オブジェクトをリンクしています
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/obj/x64/Debug/main.o: in function `idle()':
1>D:\Document\VS\VS\2019\T_Linux\T_GL2\main.cpp(51): error : undefined reference to `glutPostRedisplay'
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/obj/x64/Debug/main.o: in function `display()':
1>D:\Document\VS\VS\2019\T_Linux\T_GL2\main.cpp(56): error : undefined reference to `glClear'
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/main.cpp:63: undefined reference to `glMatrixMode'
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/main.cpp:64: undefined reference to `glLoadIdentity'
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/main.cpp:65: undefined reference to `gluLookAt'
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/main.cpp:67: undefined reference to `glColor3d'
...
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/main.cpp:165: undefined reference to `glutMainLoop'
1>collect2 : error : エラー: ld はステータス 1 で終了しました
1>プロジェクト "T_GL2.vcxproj" のビルドが終了しました -- 失敗。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========

コマンドでの -l オプションにあたる指定が足りないため.
「リンカー」-「コマンドライン」-「追加のオプション」に以下を追加.
-lglut -lGL -lGLU
-l オプション
GLUT を使用した .out

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

VC Linux の include 設定

VC Linux プロジェクトの include 設定
次のようなコードをビルドするのに include の設定がわからなかった.

#include	<cstdio>
#include	"gettickc.hxx"

int main()
{
	printf("VC 2019 hello !\n");
	for (long index = 0; index < 100; index++) {
		::Sleep_ms(100);
		printf("hello \t");
		fflush(stdout);
		if (index%5 == 4)	{
			printf("\n");
			}
		}
	printf("VC 2019 hello !\n");
	return 0;
	}

VC Linux プロジェクトの 「インクルードディレクトリ」設定


MFC のプロジェクトなどであれば,次の所で指定している.
C:\Users\Iwao\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.x64.user.props
共通のインクルードディレクトリは,次の様なもの.
\\DevS\Documents\Develop\_.SRC\__CPR_;\\DevS\Documents\Develop\_.SRC\__Iwao;…


ソース内で次の様に指定してもエラーに.
#include “\\DevS\Documents\Develop\_.SRC\__CPR_\i_define.hxx”

1>main.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\Linux.targets(412,5): error : g++ がコード 1 で終了しました。詳細については、出力ウィンドウでビルド出力をご確認ください (注: 出力ウィンドウで詳細を確認するには、ツール オプションでビルド出力の詳細度を変更する必要があります)。
1>プロジェクト "ConsoleApplication2.vcxproj" のビルドが終了しました -- 失敗。

他に #include “//devs/documents/develop/_.src/__cpr_/i_define.hxx” としてみたが変わらず.


Raspberry Pi でビルドするともう少しわかりやすいエラーの表示になった.

1>main.cpp
1>D:\Document\VS\VS\2019\T_Linux\ConsoleApplication2\main.cpp(18,10): error : \\DevS\Documents\Develop\_.SRC\__CPR_\i_define.hxx: そのようなファイルやディレクトリはありません
1>D:\Document\VS\VS\2019\T_Linux\ConsoleApplication2\main.cpp(18,10): error :  #include "\\DevS\Documents\Develop\_.SRC\__CPR_\i_define.hxx"
1>D:\Document\VS\VS\2019\T_Linux\ConsoleApplication2\main.cpp(18,10): error :           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1>D:\Document\VS\VS\2019\T_Linux\ConsoleApplication2\main.cpp(18,10): error : compilation terminated.
1>プロジェクト "ConsoleApplication2.vcxproj" のビルドが終了しました -- 失敗。

いろいろやって,次の様に指定することでうまくいった.
#include “/mnt/_.src/__cpr_/i_define.hxx”
プロジェクトの設定で次のものを指定することでビルドできることを確認.
/mnt/_.src/__CPR_;/mnt/_.src/__Iwao;/mnt/_.src/__Mlt_;/mnt/_.src/_gcc;/mnt/_.src/Test


/mnt/_.src はマウントしている.
Linux から Windows 環境への接続
g++ インクルードパスの設定

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

Fedora への ssh 接続

Fedora での SSH 接続の有効化
Fedora では「設定」-「共有」-「リモートログイン」がそれにあたる.
VS でのリモートの設定 は「ツール」-「オプション」で開いた「クロスプラットフォーム」にある.
リモート環境の追加
プロジェクトの設定も必要で「構成プロパティ」-「全般」の「リモートビルドマシン」.
リモートビルドマシンの設定
これが合っていないとビルドエラーになる.

1>------ ビルド開始: プロジェクト: ConsoleApplication1, 構成: Release x64 ------
1>Validating sources
1>Copying sources remotely to '192.168.1.34'
1>Validating architecture
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Application Type\Linux\1.0\Linux.targets(151,5): error : Current project architecture 'x64' is incompatible with the remote system architecture 'ARM' ('ARM'). Please switch the project architecture to 'ARM' in Configuration Manager.
1>プロジェクト "ConsoleApplication1.vcxproj" のビルドが終了しました -- 失敗。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========

Ubuntu では ssh サーバが入っていないみたいで次のコマンドでインストール.
$ sudo apt install openssh-server
何故か password を受け付けない?
Win10 19h1 のコマンドプロンプトで次の様にしても接続できない.

C:\Users\Iwao\AppData\Local\Temp>ssh -l Iwao -p 22 192.168.1.39
Iwao@192.168.1.39's password:
Permission denied, please try again.
Iwao@192.168.1.39's password:

何か他の設定が足りないのか?


設定関連のドキュメントは次の所にあった.
Linux ワークロードのダウンロード、インストール、セットアップ

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

VC 2017 Linux プロジェクト

VC 2017 を弄っていたら,Linux のプロジェクトの作成が可能になっていたので試してみた.
どのタイミングだったか忘れたが,SSH 接続が必要になる.


今まで設定してある Raspberry Pi に接続してみた.
Raspberry Pi  SSH 設定
Raspberry Pi 側の設定は「Raspberry Pi の設定」-「インターフェイス」にある.


ビルド時に使用する include は以下にコピーされている.これは Raspberry Pi の /user/include と同じ内容?
C:\Users\Iwao\AppData\Local\Microsoft\Linux\HeaderCache\1.0\-1277036696\usr\include
Raspberry Pi の /user/include のコピー
ビルドして出来上がった .out は /home/pi/projects/…/bin/ARM/Release にある.
Raspberry Pi /home/pi/projects/

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

g++ インクルードパスの設定

先日,Windows 環境に mount することで C++ の共通のコードを参照できる様になった.
今度は,これらを使用してコンパイルできるようにするための設定.
g++ file.cpp -I/mnt/_.src/__CPR_ などと指定すれば可能だが,これらのパスを 環境変数 に登録.

[Iwao@fedora first]$ g++ T_P_ini.cpp -I/mnt/_.src/__CPR_ -I/mnt/_.src/__Iwao -I/mnt/_.src/__Mlt_ -I/mnt/_.src/_gcc -Wall
In file included from /mnt/_.src/__Iwao/delff_e.hxx:14,
                 from /mnt/_.src/__CPR_/filefnc.hxx:13,
                 from /mnt/_.src/__CPR_/i_Trace.hxx:16,
                 from T_P_ini.cpp:5:
/mnt/_.src/__Iwao/enumfile.hxx:33:56: 備考: #pragma message: EnumFile.hxx MessageBar  No Support
   33 | #pragma  message ("EnumFile.hxx MessageBar  No Support")
      |                                                        ^
[Iwao@fedora first]$ ./a.out 
Iwao
Iwao
[Iwao@fedora first]$ 

g++ main.cpp -I(include path)

[Iwao@fedora first]$ export CPATH=/mnt/_.src/__CPR_:/mnt/_.src/__Iwao:/mnt/_.src/__Mlt_:/mnt/_.src/_gcc
[Iwao@fedora first]$ g++ T_P_ini.cpp -Wall
In file included from /mnt/_.src/__Iwao/delff_e.hxx:14,
                 from /mnt/_.src/__CPR_/filefnc.hxx:13,
                 from /mnt/_.src/__CPR_/i_Trace.hxx:16,
                 from T_P_ini.cpp:5:
/mnt/_.src/__Iwao/enumfile.hxx:33:56: 備考: #pragma message: EnumFile.hxx MessageBar  No Support
   33 | #pragma  message ("EnumFile.hxx MessageBar  No Support")
      |                                                        ^
[Iwao@fedora first]$ 

export CPATH による環境変数の指定


export の部分を sh ファイルに

[Iwao@fedora first]$ cat set_z_inc.sh 
#!/bin/bash
export	CPATH=/mnt/_.src/__CPR_
export	CPATH=$CPATH:/mnt/_.src/__Iwao
export	CPATH=$CPATH:/mnt/_.src/__Mlt_
export	CPATH=$CPATH:/mnt/_.src/_gcc
export	CPATH=$CPATH:/mnt/_.src/Test

[Iwao@fedora first]$ source ./set_z_inc.sh 
: コマンドが見つかりませんでした...
[Iwao@fedora first]$ 

登録内容を見てみると何かおかしい.

[Iwao@fedora first]$ export
declare -x BASH_ENV="/usr/share/Modules/init/bash"
declare -x COLORTERM="truecolor"
"/mnt/_.src/Testt_/mnt/_.src/__CPR_
declare -x DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
...

原因は改行コード.CRLF になっていたので LF に.
スクリプトファイルの改行コードを LF に


本当はもっと良い方法があるとは思うが,まだそこまで理解できていない.
Fedora での source ....sh と g++
Ubuntu での source ....sh と g++
Raspberry Pi での source ....sh と g++
ここまでで何とか思ったことまでは可能.


5 年前に GLUT を調べた 時のコードを,最近のコードで動作するように少し編集.
Windows での GLUT を使用したもの 2014/08 \\DevS\...\VC_Test\GL_Pick
2014/08 の GLUT を使用したコードのビルドと実行


こちらは当時のコードそのまま.Pick07.cpp
5 年前のコードをそのままビルド Pick07

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

GLUT インストール

ちょっと時間が空いたので,Linux 環境で GLUT を使える様にしてみた.
以前からお世話になっている次の所に詳しく書かれている.
GLUTによる「手抜き」OpenGL入門


Ubuntu , Debian ,Raspberry Pi では
  $ sudo apt install freeglut3 freeglut3-dev
Fedora では
  $ sudo yum install freeglut
  $ sudo yum install freeglut-devel


コンパイルは
  $ cc hello_gl.c -lglut -lGLU -lGL
GLUT を使用したサンプルのコンパイルと実行
https://jml.mish.work/index.php/cpp/install-glut.html


2019/08/17 本屋に寄ったらあったので購入.


opengl.jp
The OpenGL Utility Toolkit (GLUT) Programming Interface API Version 3 日本語翻訳版


2021/05 Win10 に GLUT インストール


https://itl.mish.work/Iwao/Doc/algo/to_thick/glut.htm

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

NAS でのコンパイルエラー

Iwao@DS116:~/gcc_test/Test/gons_to$ g++ gons_to.cpp
In file included from /volume1/public/C_Sync/GoogleD/Develop/_.SRC/__Iwao/gonsa_to.hxx:24:0,
                 from /volume1/public/C_Sync/GoogleD/Develop/_.SRC/Test/gons_to.hpp:11,
                 from gons_to.cpp:13:
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__Iwao/ga_dae.hxx: In function 'Xml_E GonsA_ToDAE(const GonsA&, c_v_tstring&)':
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__Iwao/ga_dae.hxx:180:95: error: invalid initialization of non-const reference of type 'Vd3& {aka Vector3<double>&}' from an rvalue of type 'Vd3 {aka Vector3<double>}'
      Xml_E nodeR = dae_out::node_lookat(ID_visual_scene_n_c_R,ID_camera_R_STD,stdR.GetEyePoint(),target) ;
                                                                               ~~~~~~~~~~~~~~~~^~
In file included from /volume1/public/C_Sync/GoogleD/Develop/_.SRC/__Iwao/ga_dae.hxx:12:0,
                 from /volume1/public/C_Sync/GoogleD/Develop/_.SRC/__Iwao/gonsa_to.hxx:24,
                 from /volume1/public/C_Sync/GoogleD/Develop/_.SRC/Test/gons_to.hpp:11,
                 from gons_to.cpp:13:
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__Iwao/fe_dae.hxx:596:15: note:   initializing argument 3 of 'static Xml_E dae_out::node_lookat(LPCTSTR, LPCTSTR, Vd3&, Vd3&)'
  static Xml_E node_lookat (
               ^~~~~~~~~~~
In file included from /volume1/public/C_Sync/GoogleD/Develop/_.SRC/__Iwao/gonsa_to.hxx:24:0,
                 from /volume1/public/C_Sync/GoogleD/Develop/_.SRC/Test/gons_to.hpp:11,
                 from gons_to.cpp:13:
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__Iwao/ga_dae.hxx:181:95: error: invalid initialization of non-const reference of type 'Vd3& {aka Vector3<double>&}' from an rvalue of type 'Vd3 {aka Vector3<double>}'
      Xml_E nodeL = dae_out::node_lookat(ID_visual_scene_n_c_L,ID_camera_L_STD,stdL.GetEyePoint(),target) ;
                                                                               ~~~~~~~~~~~~~~~~^~
In file included from /volume1/public/C_Sync/GoogleD/Develop/_.SRC/__Iwao/ga_dae.hxx:12:0,
                 from /volume1/public/C_Sync/GoogleD/Develop/_.SRC/__Iwao/gonsa_to.hxx:24,
                 from /volume1/public/C_Sync/GoogleD/Develop/_.SRC/Test/gons_to.hpp:11,
                 from gons_to.cpp:13:
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__Iwao/fe_dae.hxx:596:15: note:   initializing argument 3 of 'static Xml_E dae_out::node_lookat(LPCTSTR, LPCTSTR, Vd3&, Vd3&)'
  static Xml_E node_lookat (
               ^~~~~~~~~~~
Iwao@DS116:~/gcc_test/Test/gons_to$ g++ gons_to.cpp
Iwao@DS116:~/gcc_test/Test/gons_to$ ./a.out

invalid initialization of non-const reference of type
node_lookat の 3 つ目の Vd3& を const とすることで対応.
invalid initialization of non-const reference of type” で検索するとわかりやすく書いてあった.

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

xml の読込み – 3

2019/01 に書いた xml の読込み で,属性が次の様になっている場合うまく処理できないバグがあった.
attr=’”a” “b”‘
他にも !DOCTYPE があるとうまく処理できていなかった.
また,そのデータの出力(Save_xml)も attr=””a” “b”” となってうまくなかった.
xml 読込みバグ データ
parsexml.hxx
xml_out.hxx


https://jml.mish.work/index.php/cpp/xml.html

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

クラスの配列のダンプ

先日の「クラスの配列」をダンプする template を利用するためのサンプル.

// *******************************************************************************
// Name   : tpl_tstr.cpp
//        : test template To_string vector
// Author : I. Nakagawa
// Create : 2019/06/13
// *******************************************************************************

#include <iostream>
#include "i_vector.hxx"
#include "tstring.hxx"
#include "i_define.hxx"
#include "_tdefine.hxx"

// *******************************************************************************
// To tstring
// Create : 2019/06/10
// *******************************************************************************
template <class T> tstring To_tstring(const std::vector<T>& vt)
{
    tstring str ;
    for (size_t index=0 ; index<vt.size() ; index++) {
        T       e1 = vt[index] ;
        tstring s1 = e1.To_tstring() ;
        str += s1 + _T("\r\n") ;
        }
    return str ;
    }

// *******************************************************************************
// sample class
// Create : 2019/06/13
// *******************************************************************************
class Str_2 {
public:
    Str_2 (const tstring& s1=tstring(),const tstring& s2=tstring()) { Str1 = s1 ; Str2 = s2 ; }
public:
    virtual tstring To_tstring (void) const { return Str1 + _T("\t") + Str2 ; }
protected:
    tstring Str1 ;
    tstring Str2 ;
    } ;

typedef std::vector<Str_2> v_Str_2 ;

// *******************************************************************************
// main
// Create : 2019/06/13
// *******************************************************************************
int _tmain (int argc,TCHAR* argv[])
{
    _tsetlocale(LC_ALL,_T("")) ;
    {
        v_Str_2 v_s2 ;
        {
            Str_2 sd_1(_T("asdf"),_T("qwer")) ;
            Str_2 sd_2(_T("zxcv"),_T("ASDF")) ;
            Str_2 sd_3(_T("QWER"),_T("ZXCV")) ;
            Str_2 sd_4(_T("1234")) ;
            Str_2 sd_5 ;
            v_s2.push_back(sd_1) ;
            v_s2.push_back(sd_2) ;
            v_s2.push_back(sd_3) ;
            v_s2.push_back(sd_4) ;
            v_s2.push_back(sd_5) ;
            v_s2.push_back(sd_4) ;
            v_s2.push_back(sd_3) ;
            v_s2.push_back(sd_2) ;
            v_s2.push_back(sd_1) ;
            }
        std::tout << ::To_tstring<Str_2>(v_s2) ;
        }
    return 0 ;
    }

DS116 での動作テスト.
DS116 上でのクラスの配列のダンプ

C:\WINDOWS\system32>cd C:\Users\Iwao\AppData\Local\Temp

C:\Users\Iwao\AppData\Local\Temp>ssh -l Iwao -p 22 192.168.xx.xx
Iwao@192.168.xx.xx's password:
Iwao@DS116:~$ source ./set_ds_inc.sh
Iwao@DS116:~$ cd gcc_test/Test/tpl_tstr/
Iwao@DS116:~/gcc_test/Test/tpl_tstr$ ll
total 20
drwxrwxrwx+  3 Iwao users  4096 Jun 13 10:42 .
drwxrwxrwx+ 15 Iwao users  4096 Jun 13 10:32 ..
drwxrwxrwx+  2 Iwao users  4096 Jun 13 10:42 bak
-rwxrwxrwx+  1 Iwao users  2166 Jun 13 10:35 tpl_tstr.cpp
Iwao@DS116:~/gcc_test/Test/tpl_tstr$ g++ tpl_tstr.cpp
Iwao@DS116:~/gcc_test/Test/tpl_tstr$ ll
total 44
drwxrwxrwx+  3 Iwao users  4096 Jun 13 10:43 .
drwxrwxrwx+ 15 Iwao users  4096 Jun 13 10:32 ..
-rwxrwxrwx   1 Iwao users 23540 Jun 13 10:43 a.out
drwxrwxrwx+  2 Iwao users  4096 Jun 13 10:42 bak
-rwxrwxrwx+  1 Iwao users  2166 Jun 13 10:35 tpl_tstr.cpp
Iwao@DS116:~/gcc_test/Test/tpl_tstr$ ./a.out
asdf qwer
zxcv ASDF
QWER ZXCV
1234

1234
QWER ZXCV
zxcv ASDF
asdf qwer
Iwao@DS116:~/gcc_test/Test/tpl_tstr$ 
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

WordPress でエラーが表示される

自分のブログを見ているとエラーが…
Warning: mysqli_query(): (HY000/14): Can’t change size of file (Errcode: 28 “No space left on device”) in /…/wp-db.php on line 1924 Warning: mysqli_query(): (HY000/1021): Disk full (/tmp/#sql_27c2_0.MAI); waiting for someone to free some space… (errno: 28 “No space left on device”) in /…/wp-db.php on line 1924
wordpress disk full /tmp
原因は,画像変換で /tmp 以下を使用していて,70 MB 位のファイルが幾つも存在する様になってしまっていた.

Iwao@DS116:~/gcc_test/Test/t_linux/call_im$ ./a.out ~/gcc_test/Test/gons_to/data/dib/IMG_20180624_185921.vr.jpg
Iwao@DS116:~/gcc_test/Test/t_linux/call_im$ ./a.out ~/gcc_test/Test/gons_to/data/dib/IMG_20180624_185921.vr.jpg
Iwao@DS116:~/gcc_test/Test/t_linux/call_im$ ./a.out ~/gcc_test/Test/gons_to/data/dib/IMG_20180624_185921.vr.jpg
convert: ImproperImageHeader `/tmp/Iwao/i_Tools.tmp/20190201/20190201/IMG_20180624_185921.vr.jpg.004.bmp' @ error/bmp.c/ReadBMPImage/590.
convert: NoImagesDefined `/tmp/Iwao/i_Tools.tmp/20190201/20190201/IMG_20180624_185921.vr.001.jpg' @ error/convert.c/ConvertImageCommand/3258.
Iwao@DS116:~/gcc_test/Test/t_linux/call_im$ df
Filesystem      1K-blocks      Used  Available Use% Mounted on
/dev/sda1         2385592    946808    1320000  42% /
none               513436         0     513436   0% /dev
/tmp               515324    515320          4 100% /tmp
/run               515324      3312     512012   1% /run
/dev/shm           515324         4     515320   1% /dev/shm
none                    4         0          4   0% /sys/fs/cgroup
/dev/sda3      2879506904 518855752 2360532368  19% /volume1
Iwao@DS116:~/gcc_test/Test/t_linux/call_im$

rm -r /tmp/Iwao/i_Tools.tmp/20190201/* とすることで一先ず対応.
他に,/tmp なので再起動すれば消去される.
デバッグ用にファイルを残していることもあるが,コードとしてどの様に対応するか検討が必要.

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

Linux で 32 ビット色の BMP に変換

3D データの相互変換を書き直していて,32 ビット DIB が必要になってきた.
Windows 環境では,自前の Image クラスがあるのでそれを利用している.
Linux 環境は,先日見つけた convert コマンドが使えそうと思って調べるとなかなか情報が少ない.
次の -depth 32 で行けそうと思うが,24 ビットのまま.
convert dib_24.png -depth 32 dib_32.bmp
それで検索して見つけたのが,Convert to 32-bit depth BMP
次の様に存在しないアルファの情報を指定(-alpha set)する必要があるみたい.
convert dib_24.png -depth 32 -alpha set dib_32.bmp

ImageMagick

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

xml の読込み – 2

昨日の xml 読込み で,データが大きい場合に比例ではなく極端に遅くなる?
それで,次の様なコードで計測してみた.

bool Test (c_tstring& str)
{
    for (size_t index=0 ; index<str.size() ; index++) {
        ElapseTime et ;
        tstring s_str = ::Parse_xml_quot(str,_T('|'), &index) ;
        std::cerr << ::To_tstring_Ki(long(s_str.size())) << _T("\t") << et.GetElapse() << std::endl ;
        }
    return true ;
    }

bool Test (void)
{
    tstring outPath = ::Get_i_Tools_tmp_date() ;
    tstring now_hms = ::Now_Format(_T("%H%M%S")) ;
    tstring out_txt = ::Path_AddLastSP(outPath) + now_hms + _T(".txt") ;
    tstring outrtxt = ::Path_AddLastSP(outPath) + now_hms + _T("_.txt") ;
    tstring str ;
    {
        v_tstring strAry ;
        {
            tstring str_1000 ;
            {
                tstring str_10 = _T("0123456789") ;
                for (long indexS=0 ; indexS<100 ; indexS++) {
                    str_1000 += str_10 ;
                    }
                }
            for (long index=0 ; index<2000 ; index++) {
                strAry.push_back(str_1000) ;
                }
            }
        str = ::String_Join_Line(strAry) ;
        }
    str[0] = _T('|') ;
    str += _T('|') ;
    size_t len = str.length() ;
    while (len > 100) {
        len = len/2 ;
        str[len-0] = _T('|') ;
        str[len-1] = _T('|') ;
        }
    {
        tstring tmp = str ;
        v_tstring tmpAry = ::String_Split(tmp.c_str(),false) ;
        tmpAry = ::SkipEmpty(tmpAry) ;
        str = ::String_Join_Line(tmpAry) ;
        }
    {
        ::SaveUTF8(out_txt.c_str(),str) ;
        ::Test(str) ;
        }
    {
        tstring rev = str ;
        {
            std::reverse(rev.begin(),rev.end()) ;
            v_tstring revAry = ::String_Split(rev.c_str(),false) ;
            revAry = ::SkipEmpty(revAry) ;
            rev = ::String_Join_Line(revAry) ;
            }
        ::SaveUTF8(outrtxt.c_str(),rev) ;
        ::Test(rev) ;
        }
    return true ;
    }

DS116 では,比例と思われる.

login as: Iwao
Iwao@DS116's password:
Iwao@DS116:~$ source ./set_ds_inc.sh
Iwao@DS116:~$ cd gcc_test/Test/T_P_xm_q/
Iwao@DS116:~/gcc_test/Test/T_P_xm_q$ g++ T_P_xm_q.cpp
Iwao@DS116:~/gcc_test/Test/T_P_xm_q$ ll
total 204
drwxrwxrwx+  2 Iwao users   4096 Jan  8 14:10 .
drwxrwxrwx+ 10 Iwao users   4096 Jan  8 14:09 ..
-rwxrwxrwx   1 Iwao users 183528 Jan  8 14:10 a.out
-rwxrwxrwx+  1 Iwao users   3009 Jan  8 13:59 T_P_xm_q.cpp
Iwao@DS116:~/gcc_test/Test/T_P_xm_q$ ./a.out
     61         0.000384092
     61         6.10352e-05
    122         5.31673e-05
    245         5.19753e-05
    489         6.29425e-05
    979         8.70228e-05
  1.91 K        0.000140905
  3.82 K        0.000212908
  7.64 K        0.000381947
 15.29 K        0.000729799
 30.58 K        0.00145721
 61.16 K        0.0028069
122.32 K        0.00562811
244.63 K        0.011224
489.26 K        0.0223849
978.52 K        0.0462639
      0         5.38826e-05
      0         3.91006e-05
978.52 K        0.045109
489.26 K        0.022413
244.63 K        0.0112309
122.32 K        0.00556397
 61.16 K        0.00286198
 30.58 K        0.00143504
 15.29 K        0.000734806
  7.64 K        0.000383139
  3.82 K        0.000211
  1.91 K        0.000123024
    979         8.51154e-05
    489         6.19888e-05
    245         5.00679e-05
    122         4.3869e-05
     61         4.00543e-05
     61         3.91006e-05
      0         3.31402e-05
      0         3.31402e-05
Iwao@DS116:~/gcc_test/Test/T_P_xm_q$

VC 6 は比例でなく,もっとかかっている.VC 14 では問題ない.VC 8 以降?は大丈夫だと思う.

C:\Users\Iwao>C:\Users\Iwao\AppData\Local\Temp\MICS.tmp\Temp\Test.exe\T_P_xm_q.exe
     61         0
     61         0
    122         0
    245         0
    489         0
    979         0
  1.91 K        0
  3.82 K        0
  7.64 K        0
 15.29 K        0
 30.58 K        0.016
 61.16 K        0.016
122.32 K        0.109
244.63 K        0.531
489.26 K        2.433
978.52 K        14.68
      0         0
      0         0
978.52 K        14.664
489.26 K        1.342
244.63 K        0.374
122.32 K        0.125
 61.16 K        0.016
 30.58 K        0.015
 15.29 K        0
  7.64 K        0
  3.82 K        0
  1.91 K        0
    979         0
    489         0
    245         0
    122         0
     61         0
     61         0
      0         0
      0         0

C:\Users\Iwao>

parse_xml_quot をグラフ化
修正のコードは,

tstring Parse_xml_quot (c_tstring& str,const TCHAR qm,size_t* index)
{
    tstring q_str ;
    if (*index < str.length()) {
        TCHAR c = str[*index] ;
        if (c == qm) {
            /*
            q_str += c ;
            for (size_t indexQ=*index+1 ; indexQ<str.size() ; indexQ++) {
                TCHAR cq = str[indexQ] ;
                q_str += cq ;
                if (cq == qm) {
                    *index = indexQ ;
                    break ;
                    }
                }
            */
            size_t pos = ::String__Find(str,qm,*index+1) ;
            if (pos == tstring::npos) {
                q_str = str.substr(*index) ;
                *index = str.length() ;
                }
            else {
                size_t q_len = pos+1 - *index ;
                q_str = str.substr(*index,q_len) ;
                *index = pos ;
                }
            }
        }
    return q_str ;
    }

parsexml.hxx


2019/06/06
2019/01 のコードは属性の値のネスト(attr='”a” “b”‘)に対応できてないバグあり.


https://jml.mish.work/index.php/cpp/xml.html

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

xml の読込み

幾つかの xml データを読んでみると,データにより msxml.dll を使用したときに比べて明らかに遅い.

bool Test (LPCTSTR pathName)
{
    tstring outPath = ::Get_i_Tools_tmp_date() ;
    tstring now_hms = ::Now_Format(_T("_%M%S")) ;
    tstring out_xml = ::Path_AddLastSP(outPath) + ::Path_GetName(pathName) + now_hms + _T(".o.xml") ;
    tstring new_xml = ::Path_AddLastSP(outPath) + ::Path_GetName(pathName) + now_hms + _T(".n.xml") ;
    {
        ElapseTime eto ;
        Xml_E xml = ::Xml_Import(pathName) ;
        std::cerr << eto.GetElapse() << std::endl ;
        Xml_Out::Export(xml,out_xml.c_str()) ;
        }
    {
        ElapseTime etn ;
        Xml_E xml = ::Load_xml_2018_12(pathName) ;
        std::cerr << etn.GetElapse() << std::endl ;
        Xml_Out::Export(xml,new_xml.c_str()) ;
        }
    return true ;
    }

データは次の様な x3d で,5 倍くらいかかる.

Parse_xml で時間がかかる x3d
Parse_xml で時間がかかる x3d

x3d の場合は,属性の値が長い.
そのため次のコード部分( q_str+=cq )がうまくない.

tstring Parse_xml_quot (c_tstring& str,const TCHAR qm,size_t* index)
{
    tstring q_str ;
    if (*index < str.length()) {
        TCHAR c = str[*index] ;
        if (c == qm) {
            q_str += c ;
            for (size_t indexQ=*index+1 ; indexQ<str.size() ; indexQ++) {
                TCHAR cq = str[indexQ] ;
                q_str += cq ;
                if (cq == qm) {
                    *index = indexQ ;
                    break ;
                    }
                }
            }
        }
    return q_str ;
    }

https://jml.mish.work/index.php/cpp/xml.html

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

ジブン専用パソコンキット2 追加

KoKaジブン専用パソコンキット2 が届いた.

KoKaジブン専用パソコンキット2
KoKaジブン専用パソコンキット2

箱は 2つ.
ジブン専用パソコンキット2 本体
ジブン専用パソコンキット2 本体

今日は組み立てまで.
パイケース組立マニュアル」の手順通りやれば難しくはないが,カバーを外すのが少しわかり難い?
赤い所に突起がある.
パイケース組立 3
パイケース組立 3

小さい方のヒートシンクは,大人は指が大きいので取り付けが難しい.


2018/12/25
はじめようジブン専用パソコン」連載のバックナンバーから,組み立てと設定.
組み立てて OS 起動直後はシステム日付が正しくない.
ネットワークの設定を行うと自動的に設定される?


2018/12/26
そのままでは使い勝手が悪いので,リモート接続を可能にするための設定.
Windowsパソコンからraspberrypi3にリモートデスクトップで接続する」を参考にさせてもらい設定.
実際に入力したのは,
$ sudo apt-get update
$ sudo apt-get install xrdp
「日本語キーボードの配列を追加」はやっていない.
他に「Raspberry Pi の設定」で「SSH」を「有効」に.

リモート接続と SSH 接続
リモート接続と SSH 接続


DS116 とは違い,zip と unzip があることは確認.7z はない.
以前調べて知ってはいたが gcc はちゃんと入っている.


2018/12/28
今日起動すると,
SSH is enabled and the default password for the ‘pi’ user has not been changed .
This is a seurity risk – please login as the ‘pi’ user and run Raspberry Pi Configuration to set a new passowrd .

pi SSH warning
pi SSH warning

自分でしか使わないので,そのままに.


WebGL で作成したページを表示すると,あまり綺麗に表示できない.

WebGL のページの表示
WebGL のページの表示


あると便利かも?

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

include ファイルの大文字

Windows 上で動作しているコンソール AP の Synology NAS 上での動作テスト.
NAS 上でコンパイルすると include ファイルがないエラー.
今まで include する時,大文字と小文字を正しく指定できていた.
が,今回タイプミスで小文字となってしまっていたためのエラー.


g++ 時に大文字,小文字を無視する方法がないか調べたがわからず.
いろいろ考えたが,Linux 環境などでも互換性が取れるコードは小文字のファイル名とすれば都合が良さそう.
MFC や Windows.h を使用している時は,今まで通り大文字が混在するファイル名とする.

インクルードしているファイル

関連するファイルを全て編集するのは時間がかかるし間違いも増えそう.
そこで,新規のファイルと変更するファイルなどから徐々に修正することにする.
新規や変更時,include する所で lowname.hxx などとする.
LowName.hxx となっているファイルは,gcc でのみインクルードするディレクトリにコピー.
元のファイルは lowname.hxx にリネーム.
gcc にコピーした LowName.hxx は #include “lowname.hxx” の様に間接的にインクルードする様に変更する.
これでうまく機能することは確認した.
が,robocopy や Dropbox を使用している関係で lowname.hxx にならないことがある.


2019/04/16 追記
robocopy で lowname.hxx にならないことに関しては,一度コピー先を削除(実際は移動)して対応.

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