반응형

2021/02/08 - [Linux] - Linux CMake를 이용한 컴파일(빌드) 자동화

 

리눅스에서 소스 코드를 컴파일(빌드)할때 유용한 make의 간단한 사용법을 알아 보자.

 

첫 번째 간단한 소스 파일을 만든다. (a.cpp)

 

두 번째 간단한 소스 파일을 만든다. (b.cpp)

 

Makefile을 만든다.

 

더보기

target … : prerequisites …
             recipe
             …
             …

A target is usually the name of a file that is generated by a program; examples of targets are executable or object files. A target can also be the name of an action to carry out, such as ‘clean’ (see Phony Targets).
A prerequisite is a file that is used as input to create the target. A target often depends on several files.
A recipe is an action that make carries out. A recipe may have more than one command, either on the same line or each on its own line. Please note: you need to put a tab character at the beginning of every recipe line! This is an obscurity that catches the unwary. If you prefer to prefix your recipes with a character other than tab, you can set the .RECIPEPREFIX variable to an alternate character.

 

3개의 파일이 생성 되었다. 'make runme'를 실행하면 모든 소스 코드가 컴파일 되고 빌드되어 실행파일(runme)이 생성 된다.

 

 

'make clean'을 실행하면 소스 코드 및 Makefile을 제외한 모든 파일이 정리된다.

 

이번엔 Makefile의 'runme: ...' 부분을 제일 위로 옮긴다.

 

'make runme'가 아닌 'make' 명령만으로도 빌드가 완료 된다.

 

Makefile을 매크로와 자동변수를 사용하도록 바꿔보자.

 

make와 make clean 명령이 동일하게 실행된다.

 

반응형
Posted by J-sean
:
반응형

The SendInput function inserts the events in the INPUT structures serially into the keyboard or mouse input stream.

마우스 입력을 보낸다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <Windows.h>
#include <iostream>
 
using namespace std;
 
void PrintMenu()
{
    cout << "--- Mouse sender ---" << endl << endl;
    cout << "0: End" << endl;
    cout << "1: Get cursor position" << endl;
    cout << "2: Send left button click" << endl;
    cout << "3: Send right button click" << endl;
    cout << "4: Send cursor move" << endl;
    cout << "Choose: ";
}
 
void GetCursorPosition()
{
    Sleep(2000);    // Wait for 2 seconds before get the cursor position.
 
    POINT cursorPos;
    GetCursorPos(&cursorPos);
 
    cout << "Current cursor position : (x: " << cursorPos.x << ", y: " << cursorPos.y << ")" << endl;
}
 
void SendLeftClick()
{
    Sleep(5000);
 
    INPUT input;
    ZeroMemory(&input, sizeof(INPUT));
    input.type = INPUT_MOUSE;
    input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
    SendInput(1&input, sizeof(INPUT));
 
    input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
    SendInput(1&input, sizeof(INPUT));
}
 
void SendRightClick()
{
    Sleep(5000);
 
    INPUT input;
    ZeroMemory(&input, sizeof(INPUT));
    input.type = INPUT_MOUSE;
    input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
    SendInput(1&input, sizeof(INPUT));
 
    input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
    SendInput(1&input, sizeof(INPUT));
}
 
void SendMove()
{
    int x, y;
    int screenWidth = GetSystemMetrics(SM_CXSCREEN);
    int screenHeight = GetSystemMetrics(SM_CYSCREEN);
 
    cout << "Screen size: (" << screenWidth << ", " << screenHeight << ")" << endl;
    cout << "[x: 0~" << screenWidth - 1 << ", y: 0~" << screenHeight - 1 << "]" << endl;
    cout << "x: ";
    cin >> x;
    cout << "y: ";
    cin >> y;
 
    INPUT input;
    ZeroMemory(&input, sizeof(INPUT));
    input.type = INPUT_MOUSE;
    input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
    // If MOUSEEVENTF_ABSOLUTE value is specified, dx and dy contain normalized absolute coordinates
    // between 0 and 65,535. The event procedure maps these coordinates onto the display surface.
    // Coordinate (0,0) maps onto the upper-left corner of the display surface; coordinate (65535,65535)
    // maps onto the lower-right corner. In a multimonitor system, the coordinates map to the primary monitor.
    //
    // If the MOUSEEVENTF_ABSOLUTE value is not specified, dxand dy specify movement relative to the previous
    // mouse event(the last reported position).Positive values mean the mouse moved right(or down); negative
    // values mean the mouse moved left(or up).
    float dx = x * (65535.0f / (screenWidth - 1));
    float dy = y * (65535.0f / (screenHeight - 1));
    input.mi.dx = LONG(dx);
    input.mi.dy = LONG(dy);
    SendInput(1&input, sizeof(INPUT));
}
 
int main()
{
    int choice = 1;
 
    while (choice)
    {
        PrintMenu();
        cin >> choice;
 
        switch (choice)
        {
        case 1:
            GetCursorPosition();
 
            break;
        case 2:
            SendLeftClick();
 
            break;
        case 3:
            SendRightClick();
 
            break;
        case 4:
            SendMove();
 
            break;
        default:
 
            return 0;
        }
    }
 
    return 0;
}



Run the program and choose the event you want to send.


반응형
Posted by J-sean
: