Introduction to UFO SDL Programming the first project just built a project, encountered a problem, is the SDL header file and library path problems, always prompt to find the library,
Baidu has a lot of methods, are not able to solve the problem, very depressed, and finally in an article to install the SDL saw, SDL has test procedures, you can test the effect, so I interviewed in test the next routine, sure enough to run. Since it can be run, it must have the correct path set. Haha, the key to solving the problem. Below please come with me to see how to solve (^ level limited Ah, the shortcomings please correct ^)
Now this problem is solved, hope to be helpful to everyone; Use the Eclipse compilation environment to learn SDL programming, environment configuration steps first include header file # include "Sdl2/sdl.h" #include "in the program Sdl2/sdl_ Image.h "Then set the header file path in the project configuration project->properties->c/c++general->paths and symbols inside the gun C Header File path setting the SDL library path method is as follows: If you are installing SDL by manual source, there is a test folder under the SDL installation package, go to the Test folder, run./configure, then make, then you will see a lot of test programs, these are the programs that can run directly. What is the use of this step, do not worry; Open the makefile file, find the path inside, that is, we programmed to use the path can be seen, the header file path is just above the one, Libs represents the library file path, you can see-l/usr/local/lib- LSDL2 This is what we need, open just project configuration library Paths,add input usr/local/lib, such as; and then open Libraries,,add input SDL2, such as; Sdl_ The header file and library path of image are added in the same place as the SDL base library, except for the names. With the addition of the SDL base library, the other sdl_image,sdl_mixer,sdl_net,sdl_ttf are dependent on the basic SDL library, so the path is the same. After configuration, you can build project, then run, you can see the program results, the window name is Hello,: Source: #include <stdlib.h> #include "sdl2/sdl.h" #include " Sdl2/sdl_image.h " int Main (int Argc,char *argv[]) {sdl_window* window = 0; sdl_renderer* render=0; Sdl_texture *texture=0; Sdl_rect SRC,DST; int width,height; Sdl_init (sdl_init_everything); Window=sdl_createwindow ("Hello", sdl_windowpos_centered, SDL_WINDOWPOs_centered,1366,768,sdl_window_shown); Render=sdl_createrenderer (window,-1,0); Texture=img_loadtexture (Render, "tux.jpg"); sdl_querytexture (texture,null,null,&width,&height); src.x=src.y=0; Src.w=width; Src.h=height; dst.x=30; dst.y=20; Dst.w=width; Dst.h=height; Sdl_setrenderdrawcolor (render,0,0,0,255); Sdl_renderclear (render); Sdl_rendercopy (RENDER,TEXTURE,&SRC,&DST); Sdl_renderpresent (render); Sdl_delay (30000); Sdl_destroywindow (window); Sdl_destroyrenderer (render); Sdl_quit (); return 0;} //ufo&et original, Welcome to Exchange
Ubuntu Eclipse SDL programming first project