-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeneratedQRCodeUsingCLanguage.txt
More file actions
76 lines (62 loc) · 2.1 KB
/
generatedQRCodeUsingCLanguage.txt
File metadata and controls
76 lines (62 loc) · 2.1 KB
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
- Primeiro precisamos instalar a biblioteca:
$ sudo apt-get install libqrencode-dev
- Código simples que gera QRCode apartir de uma String e imprime a matriz no console:
#include <stdio.h>
#include <stdlib.h>
#include <qrencode.h>
int main()
{
// Define a mensagem a ser codificada no QR code
char* message = "Hello, World!";
// Cria um objeto QRcode a partir da mensagem
QRcode* qrcode = QRcode_encodeString(message, 0, QR_ECLEVEL_M, QR_MODE_8, 1);
// Imprime a matriz de pontos do QR code
int i, j;
for (i = 0; i < qrcode->width; i++) {
for (j = 0; j < qrcode->width; j++) {
printf("%c ", qrcode->data[i*qrcode->width+j]?'#':' ');
}
printf("\n");
}
// Libera a memória alocada pelo QRcode
QRcode_free(qrcode);
return 0;
}
- Para compilar na mão: Devemos informar ao compilador para incluir a biblioteca
utilizada na hora de compilar o hello.c e gerar o executável com o seguinte cmd:
- Primeiro ir no path:
~/Documentos/github/QRCodeReader_SummarizingInvoiceNotes/generatedQRCodeWithLibqrencode$
- Depois compilar:
$ gcc -o main hello.c -lqrencode
- Para compilar no Visual Studio Code:
- Devemos editar o task.json do ./vscode/task.json com o parâmetro: "-lqrencode"
em args, sendo assim o arquivo task.json final deve ser algo como:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc-12 build active file",
"command": "/usr/bin/gcc-12",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-lqrencode"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}