GNUmakefile
Makefile (notes and examples)This document explains how to compile C programs with gcc and how to use Makefiles to automate builds. It includes step-by-step commands, split compilation, simple Makefiles, and improved templates with variables and pattern rules.
1. How to compile a simple program
Create main.c:
11. Create `main.c`:
Write this example code into main.c:
123gcc -o hello main.o defs.ogcc -c main.c -o main.o
Makefile (notes and examples) This document explains how to compile C prog ...
Linux链接静态库与动态库并且打包程序
[toc]
链接静态库1.自写链接动态库
1gcc -o httpc httpc.c -lssl -lcrypto
2.第三方链接动态库1.自写链接静态库
1gcc -o LinClient LinClient.c -static -lssl -lcrypto
2.第三方打包程序1.打包一个链接OpenSSl的程序
安装 OpenSSL12sudo apt updatesudo apt install openssl libssl-dev
编写代码
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 ...
9.C语言使用glfw3与opengl在vs2022中开发窗口程序
[toc]
C语言使用glfw3与opengl在vs2022中开发窗口程序1.准备开发环境
使用vkpkg安装glfw3.
使用vkpkg安装glad
2.使用glfw创建一个窗口程序12345678910111213141516171819202122232425262728293031#include <GLFW/glfw3.h> #include <stdio.h>int main(){ glfwInit(); 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);#endif GLFWwindow* windo ...
8.C++使用OpenGl画点线面
[toc]
C++使用OpenGl画点线面1.点1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071#include <glut.h>#include <windows.h>#define WINDOW_NAME "Drawing Points"// Vertex data for 5 pointsGLfloat points[][2] = { {100.0f, 100.0f}, {200.0f, 100.0f}, {300.0f, 100.0f}, {400.0f, 100.0f}, {500.0f, 100.0f}};// Function to render the scen ...
7.C语言在windows平台使用opengl图形库画窗口图形
[toc]
在c语言程序中使用openGL配置环境
下载glut库
将头文件添加项目里,将静态库与动态库放置项目文件夹里
编译版本选择x86,库文件只支持x86不支持x64
使用openGL画一个茶壶OpenGL(十六) 鼠标、键盘交互响应事件
OpenGL(十六) 鼠标、键盘交互响应事件
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 ...
6.C++使用Direct3D9画点线面
[toc]
C++使用Direct3D画点线面1.点1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931 ...
5.C++使用Direct2D画点线面
[toc]
#C++使用Direct2D画点线面1.Direct2D绘制点123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129#include <windows.h>#include <d2d1.h>#pragma comment(lib, "d2d1.lib")// 全局变量ID2D1Factory* pFactory = NULL;ID2D1HwndRenderTarget* pRenderTarget = NULL;void Creat ...
4.在windows窗口程序中画立体图形
[toc]
在windows窗口程序中画立体图形1.在windows窗口程序中画正方体123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116#include <windows.h>// 绘制正方体的函数void DrawCube(HDC hdc) { // 设置正方体的参数 int size = 100; // 正方体的边长 int offsetX = 150; // 正方体的X坐标 int offsetY = 100; // 正方体的Y坐标 // 计算正方体的顶点 POINT front[4] = ...
3.在windows窗口程序中让图形通过鼠标控制移动
[toc]
鼠标控制图形的移动1.让图形随着鼠标位置移动123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117#include <windows.h>// 定义全局变量来存储矩形的坐标和大小int rectX = 50; // 矩形左上角的X坐标int rectY = 50; // 矩形左上角的Y坐标int rectWidth = 50; // 矩形的宽度int rectHeight = 30; // 矩形的高度// 定义标志来跟踪矩形是否被选中BOOL isRectSelected = FALSE;POINT offset; // 用于存储鼠标 ...
2.在windows窗口程序中让图形通过键盘控制移动
[toc]
在windows窗口程序中让图形通过键盘控制移动1.通过WSAD控制像素点上下左右移动12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879#include <windows.h>// 定义全局变量来存储红色像素点的坐标int posX = 50; // 初始X坐标int posY = 50; // 初始Y坐标// 窗口过程函数LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &p ...
