sdl

Strange segfault from SDL_FreeSurface

社会主义新天地 提交于 2019-12-02 04:18:59
I have the following simple SDL code: #include <SDL.h> #include <stdbool.h> #include <stdio.h> // helpers bool init(SDL_Window **win, SDL_Surface **surf) { int const width = 800; int const height = 600; if (SDL_Init(SDL_INIT_VIDEO) != 0) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); return false; } *win = SDL_CreateWindow("Picture test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, 0); if (*win == NULL) { fprintf(stderr, "Unable to create window: %s\n", SDL_GetError()); return false; } *surf = SDL_GetWindowSurface(*win); return true; } bool load_media(SDL

C++: How to add external libraries

时光毁灭记忆、已成空白 提交于 2019-12-02 03:20:32
问题 I'm trying to add SVL to my project. Without it I'm getting hundreds of errors (undefined reference...). After adding -lSVL all errors are gone, but gcc says: "cannot find -lSVL". Everything else (SDL, SDL_TTF, SDL_Mixer...) works fine. 回答1: You should inform gcc of the path where libsvl.a is installed, for example: gcc -lsvl -L/my/path/ Also, pay attention to the case if you work under Linux ("SVL" is different from "svl"). 回答2: There are two parts to adding an external library; you need to

Receiving undefined references to various Windows libraries when compiling with SDL 2 and -static?

我的梦境 提交于 2019-12-02 03:20:25
问题 I'm working on a modification of the Wolfenstein 3D engine in SDL2 (using Wolf4SDL as a base) and I've run into a problem - when using -static in the linker options, I get a large variety of undefined references to various things. Here's my build log to show what I mean: -------------- Build: Debug in Lazarus (compiler: GNU GCC Compiler)--------------- i686-w64-mingw32-g++.exe -LC:\SDL2\lib -o Lazarus.exe .objs\alu_cache.o .objs\alu_dbg_mem.o .objs\alu_gfx.o .objs\alu_hud.o .objs\alu_in.o

SDL2 won't link properly

扶醉桌前 提交于 2019-12-02 02:37:33
问题 I'm using Code::Blocks, that's my code: #include "SDL2/SDL.h" int main(int argc, char* args[]) { SDL_Init( SDL_INIT_EVERYTHING ); SDL_Quit(); return 0; } I'm building like: mingw32-g++.exe -o C:\..\main.exe C:\..\main.o -lmingw32 -lSDL2main -lSDL2 And getting that: undefined reference to "SDL_Init" undefined reference to "SDL_Quit" I'm pretty sure the linker finds the libs cause if I change them to something random it complains "can't find whatever". 回答1: A bit late, but I just stumbled over

Undefined reference to 'SDL_main' while using Dev C++

为君一笑 提交于 2019-12-02 01:32:51
i am currently having problem compiling my project in dev c++ which uses SDL libraries, what i did was first download the file SDL2-devel-2.0.3-mingw.tar.gz (MinGW 32/64-bit) from this site , then in Tools -> Compiler Options and then in ' Directories ' section i included the x86_64-w64-mingw32/lib in ' libraries ' tab and x86_64-w64-mingw32/include in ' C++ includes ' tab after i extracted the downloaded folder in C drive. Finally, in project options i added these linkers -lmingw32 -lSDL2main -lSDL2 But after compiling this code : #include<stdio.h> #include<SDL2/SDL.h> int main(int argc,

C++: How to add external libraries

感情迁移 提交于 2019-12-02 01:26:25
I'm trying to add SVL to my project. Without it I'm getting hundreds of errors (undefined reference...). After adding -lSVL all errors are gone, but gcc says: "cannot find -lSVL". Everything else (SDL, SDL_TTF, SDL_Mixer...) works fine. You should inform gcc of the path where libsvl.a is installed, for example: gcc -lsvl -L/my/path/ Also, pay attention to the case if you work under Linux ("SVL" is different from "svl"). There are two parts to adding an external library; you need to tell the compiler [1] where to find the description of the API (i.e., the header files) and you need to tell the

Receiving undefined references to various Windows libraries when compiling with SDL 2 and -static?

孤街浪徒 提交于 2019-12-02 00:45:53
I'm working on a modification of the Wolfenstein 3D engine in SDL2 (using Wolf4SDL as a base) and I've run into a problem - when using -static in the linker options, I get a large variety of undefined references to various things. Here's my build log to show what I mean: -------------- Build: Debug in Lazarus (compiler: GNU GCC Compiler)--------------- i686-w64-mingw32-g++.exe -LC:\SDL2\lib -o Lazarus.exe .objs\alu_cache.o .objs\alu_dbg_mem.o .objs\alu_gfx.o .objs\alu_hud.o .objs\alu_in.o .objs\alu_me_core.o .objs\alu_me_gui.o .objs\alu_me_symbols.o .objs\alu_me_textinput.o .objs\alu_me_tools

SDL Mouse Click

微笑、不失礼 提交于 2019-12-02 00:36:22
问题 So, I'm currently working on an options menu for my game, I have a button that when pressed it changes it's text to the next resolution in an array, so basically the user presses this button to change their resolution to the next string in the array. My problem is getting the click event. Right now, when the user presses the button, it returns true while the mouse is down, instead of when the mouse is pressed. I want to only return true in the mouse event when the mouse is pressed. I've

SDL以及扩展库的交叉编译过程简介

核能气质少年 提交于 2019-12-01 23:32:44
********************************** Writen by Rao 2012年04月20日 星期五 21时57分16秒 ********************************** 下面我介绍一下SDL以及SDL的扩展库在arm11上的交叉编译 在这里我将SDL 交叉编译的相关都安装在/opt/arm目录下 相关简介: SDL官方网站 http://www.libsdl.org/ SDL编译移植(Up-teach6410平台) 系统环境:linux 移植环境:arm11 编译工具链:gcc-4.3.1(系统默认工具链) 1.1 编译jpeg-7 软件名称 libjpeg 功能描述 libjpeg是一个用c语言编写支持jpeg解码、编码的库 下载地址 http://linux.softpedia.com/get/Programming/Libraries/libjpeg-160.shtml 软件版本 jpegsrc.v7.tar.gz 依赖关系 默认 1.2 编译libiconv-1.14 软件名称 libiconv 功能描述 libiconv库为需要做转换的程序,实现了一个字符编码到另一个字符编码的转换 下载地址 http://www.gnu.org/software/libiconv/#downloading 软件版本 libiconv-1

SDL2 won't link properly

白昼怎懂夜的黑 提交于 2019-12-01 22:59:01
I'm using Code::Blocks, that's my code: #include "SDL2/SDL.h" int main(int argc, char* args[]) { SDL_Init( SDL_INIT_EVERYTHING ); SDL_Quit(); return 0; } I'm building like: mingw32-g++.exe -o C:\..\main.exe C:\..\main.o -lmingw32 -lSDL2main -lSDL2 And getting that: undefined reference to "SDL_Init" undefined reference to "SDL_Quit" I'm pretty sure the linker finds the libs cause if I change them to something random it complains "can't find whatever". A bit late, but I just stumbled over a similar problem on Linux. This results in linker errors: g++ $(pkg-config --cflags --libs sdl2) sdl2test