Разбил программу на несколько исходных файлов с одним заголовочным файлом - не хочет компилироваться:
| Код | [fox@localhost snake]$ g++ *.cpp snake.h `sdl-config --cflags --libs` /home/fox/tmp/cch5qfyz.o(.bss+0x0): multiple definition of `back' /home/fox/tmp/cc53elHh.o(.bss+0x0): first defined here /home/fox/tmp/cch5qfyz.o(.bss+0x4): multiple definition of `image' /home/fox/tmp/cc53elHh.o(.bss+0x4): first defined here /home/fox/tmp/cch5qfyz.o(.bss+0x8): multiple definition of `screen' /home/fox/tmp/cc53elHh.o(.bss+0x8): first defined here /home/fox/tmp/cch5qfyz.o(.bss+0xc): multiple definition of `xpos' /home/fox/tmp/cc53elHh.o(.bss+0xc): first defined here /home/fox/tmp/cch5qfyz.o(.bss+0x10): multiple definition of `ypos' /home/fox/tmp/cc53elHh.o(.bss+0x10): first defined here /home/fox/tmp/ccHVDm12.o(.bss+0x0): multiple definition of `back' /home/fox/tmp/cc53elHh.o(.bss+0x0): first defined here /home/fox/tmp/ccHVDm12.o(.bss+0x4): multiple definition of `image' /home/fox/tmp/cc53elHh.o(.bss+0x4): first defined here /home/fox/tmp/ccHVDm12.o(.bss+0x8): multiple definition of `screen' /home/fox/tmp/cc53elHh.o(.bss+0x8): first defined here /home/fox/tmp/ccHVDm12.o(.bss+0xc): multiple definition of `xpos' /home/fox/tmp/cc53elHh.o(.bss+0xc): first defined here /home/fox/tmp/ccHVDm12.o(.bss+0x10): multiple definition of `ypos' /home/fox/tmp/cc53elHh.o(.bss+0x10): first defined here collect2: ld returned 1 exit status [fox@localhost snake]$
|
snake.h:
| Код | #ifndef SNAKE_HEADER #define SNAKE_HEADER #include <stdio.h> #include <stdlib.h> #include <SDL/SDL.h>
SDL_Surface *back=SDL_LoadBMP("/docs/programming/Sdl/progs/less2/bg.bmp"); SDL_Surface *image=SDL_LoadBMP("/docs/programming/Sdl/progs/less2/image.bmp"); SDL_Surface *screen=SDL_SetVideoMode(640,480,24,SDL_HWSURFACE|SDL_DOUBLEBUF);
int xpos=0, ypos=0;
void DrawIMG(SDL_Surface *img, int x, int y); void DrawIMG(SDL_Surface *img, int x, int y, int w, int h, int sx, int sy); void DrawBG(void); void DrawScene(void);
void initsystem(); void driver();
#endif //SNAKE_HEAER
|
Вся программы в прикреплённом архиве |