2026年7月22日 星期三

Linux Man(Manual) Page - (線上手冊)

 章節分類(Sections):

1. 可執行的程式或是 shell 指令

2. 系統呼叫(system calls,Linux 核心所提供的函數)

3. 一般函式庫函數

4. 特殊檔案(通常位於 /dev)

5. 檔案格式與協定,如 /etc/passwd

6. 遊戲

7. 雜項(巨集等,如 man(7)、groff(7))

8. 系統管理者指令(通常是管理者 root 專用的)

9. Kernel routines(非標準)


線上查詢:

    https://man7.org/linux/man-pages/index.html

Program部份:

    gcc : https://man7.org/linux/man-pages/man1/gcc.1.html

    g++: https://man7.org/linux/man-pages/man1/g++.1.html


參考網址:

    第六章、Linux 檔案與目錄管理 - 鳥哥 - 基礎學習篇 - CentOS 7.x

    善用 man 指令查詢 Linux 線上手冊(Man Page)


Visual Studio Code(VS Code) tutorial


1. install VS code

    Download the corresponding version

    https://code.visualstudio.com/download?_exp_download=fb315fc982

    sudo apt install ./<file>.deb

Ref:

    https://code.visualstudio.com/docs/setup/linux

    https://code.visualstudio.com/docs/setup/windows


2. install extension for C/C++ or other

    Start app

    Enter extensions and install: C/C++, C/C++ Extension Pack, C/C++ DevTools

Ref:

    https://code.visualstudio.com/docs/languages/cpp


3. first program(Hello World) and do debug

    Please check the under link.

    .vscode -- some setting file

        tasks.json (compiler build settings)

        launch.json (debugger settings)

        c_cpp_properties.json (compiler path and IntelliSense settings)

    Debug: 

        a. Open main.cpp in VS code.

        b. Add a breakpoint in source code

        c. Press the play button(in the right-up location),  select Debug C/C++ File in the drop-down

Ref:

    https://code.visualstudio.com/docs/cpp/config-linux


4. Debugging with Multiple Files

    Previous step will generate tasks.json. Modify task.json.

    Replease

    "${file}",

    to

    "file1.cpp",

    "file2.cpp",

Ref:

    http://antares.cs.kent.edu/~csi/blog/vscodemultiple.html



2026年7月21日 星期二

Install ImageMagick 7 in Ubuntu 22.04

Use source code

1.  Download the newest source code from official website: Source code(zip) or Source code(tar.gz)

https://github.com/ImageMagick/ImageMagick/releases

2. Decompress source codes and enter the folder

cd ImageMagick-7.1.2-27

3. Set build environment

./configure

4. build code

make

5. install ImageMagick

sudo make install

6. update dynamic shared library

sudo ldconfig /usr/local/lib



Ref:

https://imagemagick.org/install-source/#gsc.tab=0

https://www.ufans.top/index.php/archives/370/

2026年7月9日 星期四

Glad and GLFW in Ubuntu

 1. Check previous article to install GLFW


2. Download Glad(https://glad.dav1d.de)

C/C++, OpenGL, gl(Version 3.3) --> Generate --> Download Zip file


3. File tree

├── glad.c

├── include/

│   ├── KHR/

│   │   └── khrplatform.h

│   └── glad/

│       └── glad.h

└── Hello_Window.cpp


4. Hello_World.cpp(A Sample code)

------------------------------------------------------------------------

#include <glad/glad.h>

#include <GLFW/glfw3.h>

#include <iostream>


void framebuffer_size_callback(GLFWwindow* window, int width, int height) {

    glViewport(0, 0, width, height);

}


// Process escape key to close the window

void processInput(GLFWwindow *window) {

    if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {

        glfwSetWindowShouldClose(window, true);

    }

}


int main() {

    // 1. Initialize GLFW

    if (!glfwInit()) {

        std::cerr << "Failed to initialize GLFW" << std::endl;

        return -1;

    }


    // 2. Configure GLFW (Targeting OpenGL 3.3 Core Profile)

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);

    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);

    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

#ifdef __APPLE__

    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required for macOS

#endif


    // 3. Create the window object

    GLFWwindow* window = glfwCreateWindow(800, 600, "OpenGL Hello World", NULL, NULL);

    if (window == NULL) {

        std::cerr << "Failed to create GLFW window" << std::endl;

        glfwTerminate();

        return -1;

    }

    glfwMakeContextCurrent(window);

    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);


    // 4. Initialize GLAD before calling any OpenGL functions

    if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {

        std::cerr << "Failed to initialize GLAD" << std::endl;

        return -1;

    }


    // 5. The Render Loop

    while (!glfwWindowShouldClose(window)) {

        // Input handling

        processInput(window);


        // Rendering commands (Clear screen with a dark greenish-blue color)

        glClearColor(0.2f, 0.3f, 0.3f, 1.0f);

        glClear(GL_COLOR_BUFFER_BIT);


        // Swap buffers and poll window events

        glfwSwapBuffers(window);

        glfwPollEvents();

    }


    // 6. Clean up resources

    glfwTerminate();

    return 0;

}

------------------------------------------------------------------------


5. Build code

g++ Hello_World.cpp glad.c -I./include -lglfw -lGL -ldl -o Hello_Window



Hello GLFW in Ubuntu

 

1. install GLFW Library

sudo apt update

sudo apt install libglfw3 libglfw3-dev


2. Create a "Hello world.cpp" file and copy the under codes

-------------------------------------------------------------

#include <GLFW/glfw3.h>

#include <iostream>


int main() {

    // Initialize the library

    if (!glfwInit()) return -1;


    // Create a windowed mode window and its OpenGL context

    GLFWwindow* window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);

    if (!window) {

        glfwTerminate();

        return -1;

    }


    // Make the window's context current

    glfwMakeContextCurrent(window);


    // Loop until the user closes the window

    while (!glfwWindowShouldClose(window)) {

        // Render here

        glClear(GL_COLOR_BUFFER_BIT);


        // Swap front and back buffers

        glfwSwapBuffers(window);


        // Poll for and process events

        glfwPollEvents();

    }


    glfwTerminate();

    return 0;

}

-------------------------------------------------------------


3. Build code

g++ "Hello world.cpp" -o "Hello world" -lglfw -lGL


4. Run

./Hello\ world


5. Search GLFW version

apt show libglfw3-dev


2026年7月7日 星期二

FrameBuffer in Linux

如無效, 請在文字模式下(tty3),測試。 Ctrl+Alt+F3


1. 檢查:ls -l /dev/fb0

     crw-rw---- 1 root video 29, 0 Jul  7 15:53 /dev/fb0

2. 輸出擷取畫面:cat /dev/fb0 > screensnap

3. 檢查:ls -l sreensnap

4. 清理螢幕:clear

5. 寫入FrameBuffer:cat sreensnap > /dev/fb0

6. 恢復原狀:clear


參考網址:

Linux - FrameBuffer