C:/MinGW/lib/libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `WinMain@16'
来源:互联网 发布:域名是做什么的 编辑:程序博客网 时间:2024/05/21 18:36
需要加 -lmingw32
例如使用minGW32 :执行g++命令:g++ -o mysql.exe main.cpp -lmingw32 -lSDLmain -lSDL
main.cpp
#include <stdio.h>#include "SDL/SDL.h"#define WIDTH 640#define HEIGHT 480#define BPP 4#define DEPTH 32void setpixel(SDL_Surface *screen, int x, int y, Uint8 r, Uint8 g, Uint8 b){ Uint32 *pixmem32; Uint32 colour; colour = SDL_MapRGB( screen->format, r, g, b ); pixmem32 = (Uint32*) screen->pixels + y + x; *pixmem32 = colour;}void DrawScreen(SDL_Surface* screen, int h){ int x, y, ytimesw; if(SDL_MUSTLOCK(screen)) { if(SDL_LockSurface(screen) < 0) return; } for(y = 0; y < screen->h; y++ ) { ytimesw = y*screen->pitch/BPP; for( x = 0; x < screen->w; x++ ) { setpixel(screen, x, ytimesw, (x*x)/256+3*y+h, (y*y)/256+x+h, h); } } if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); SDL_Flip(screen);}int main(int argc, char* argv[]){printf("hello world !"); SDL_Surface *screen; SDL_Event event; int keypress = 0; int h=0; if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1; if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_HWSURFACE))) { SDL_Quit(); return 1; } while(!keypress) { DrawScreen(screen,h++); while(SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: keypress = 1; break; case SDL_KEYDOWN: keypress = 1; break; } } } SDL_Quit(); return 0;}
参数 -l (小写的L)使库文件得以与源文件一起编译和连接。(简单的可以认为-labc即连接了名称符合libabc.*的所有库文件)
最后说明的两个参数是:-mconsole 和 -mwindows
他们的效果是使可执行程序是带命令行控制窗口的或者是纯Windows窗口的,缺省情况下应该是带命令行控制窗口的。
运行mysdl.exe可以看到文件的执行情况。
0 0
- C:/MinGW/lib/libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `WinMain@16'
- crtbegin_dynamic.o: in function _start:crtbrand.c(.text+0x78): error: undefined reference to 'main
- 解决 init.c:(.text+0x34): undefined reference to `main'
- _start:crtbrand.c(.text+0x78): error: undefined reference to 'main'
- 在CentOS中编译c源文件,遇到(.text+0x20): undefined reference to `main'
- undefined reference to main
- 库依赖错误导致main.c:(.text+0x7): undefined reference问题
- gcc 共享库的时候显示.../crt1.o: In function `_start': (.text+0x18): undefined reference to `main'的错误
- gcc/g++ 出现.../crt1.o: In function `_start': (.text+0x18): undefined reference to `main'的错误
- MinGW下undefined reference to `WinMain@16'问题
- Eclipse CDT+Mingw: undefined reference to `WinMain@16'
- [ANDROID NDK ERROR]crtbegin_dynamic.o: undefined reference to 'main'
- g++ undefined reference to `main'
- Undefined reference to 'WinMain@16
- undefined reference to 'WinMain@16'
- limit.c:(.text+0xa5): undefined reference to `sin'
- busybox mount.c:(.text+0x42c): undefined reference to `del_loop'
- hello.c:(.text+0x45): undefined reference to `XDisplayName'
- leetcode Longest Palindromic Substring 005
- Jenkins进阶系列之——18Jenkins语言本地化
- 【tyvj1039】忠诚2
- 为什么深度神经网络难以训练Why are deep neural networks hard to train?
- 沙盒(SandBox)的文件目录获取
- C:/MinGW/lib/libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `WinMain@16'
- 利用三维旋转矩阵在空间中旋转平面
- Java基础之八:数组
- 深度学习Deep learning
- 浅谈Java中的Set、List、Map的区别
- Jenkins进阶系列之——06FTP publisher plugin插件下载(支持绝对路径)
- PB中的DataStore的应用示例
- 人工智能有简单的算法吗?Appendix: Is there a simple algorithm for intelligence?
- mac jdk 路径