Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

136 Neutral

About Nazzrim

  • Rank
  1. Nazzrim

    Proper DLL use

    DvDmanDT: Okay, does that mean that the way a library is linked is determined only by the library and not by the way I actual code it? If it does I got it :>. I didn't know that a library "sets itself" to static/dynamic. Maybe I should get information about DLL's in general. With this, kept in mind the following sentence I found on SDL site makes sense to me, because now I know that this resulting the dll being a dynamic one. And if I want to know if a library is dynamic or static I have to examine the library itself. Helped me a lot. Thank you Can I use SDL in a commercial application? Yes! If you link dynamically (via .dll's, .so's or using other dynamic linking devices) then you do not need to to anything. If you link statically (include the SDL source inside your project when you compile) you have to provide some way for your customer to relink your application a custom version of SDL. [/quote]
  2. Nazzrim

    Proper DLL use

    You're still confusing your concepts; as I said, the include statement has absolutely nothing to with linking, so there's no association to be made between static/dynamic linking and including header files. I think you should maybe pick up a book on programming in C++ to get your concepts straight, a forum isn't exactly the right place to learn all these elementary things [/quote] Maybe I didn't point out my thoughts clearly: If I use the include statement, the whole content of the header file is included into my executable and because there is no implementation of the functions the Linker will look at the locations I tell it. I think I nearly understood the concept of include statement / dynamic/static link (will do some practice on that) but maybe I am not able to find the right words... My actual problem is that I don't know how to handle this information in C++, or: How does a static/dynamic link look in C++? Until know I thougt thats its static if I use Link-Flags and if not its dynamic. And yes you are right, I thougt my problem is a lot smaller, but I think I should consider some lecture. But thank you very much:-). @DvDmanDT: Thank you. Hopefully got it.
  3. Nazzrim

    Proper DLL use

    @Radikalizm I think I got it now ;-). If I link dynamic there is no need of a Link-flag, because everything gets resolved at runtime. But if I don't want to link dynamic I have to tell the Linker where to look. If I seperate the #include from the rest in my mind, there is no need of an include statement if I use dynamic link, because then I would be forced to include everything out of the header file. But how can I get access on classes/flags used inside a DLL. And not special for SDL: Why can there be more than one linker-flag for one DLL? Can a DLL contain different separated libraries? Hopefully the last two are not SDL specific and more like "problems of general DLL usage" ;-).
  4. Nazzrim

    Proper DLL use

    @Radikalizm Wow, thank you very much. That helps alot :-). So is it right, that DLL's are designed for dynamic linking, and every use of them is a dynamic link? I'm not sure if I got it: I will definitly read about import libraries, but what is the benefit against using #include <...>? Is is, that it would include the whole library instead of only the necessary things? @kloffy Thank you I will read it as soon as possible:). I think I didn't/don't(;-)) understand the meaning of a DLL, because SDL is released with LGPL and it only allows other licences if dynamic linked, so I wanted to learn more about it, poorly the only thing I knew at this point was: "everything comes out of this DLL Oo". So I thought this could be the right way.. But it seems to me that every DLL use is dynamic Oo. Great misunderstanding.
  5. Nazzrim

    Proper DLL use

    Hey everyone. I am learning SDL for some month now, which dramatically increased my C++ skills. But I have some questions about the use/general function of DLL files: 1. My interpretation of DLL file is a collection of functions and classes (not necessarily C/C++) provided for other programs. Is this right? 2. On different sources I read about "static linking" & "dynamic linking" but I am not completely sure about it's meanings: If I use #include <SDL/SDL.h> the header file for SDL.dll is directly included into my project when compiled. I hope till this point I am not wrong... This way the DLL is linked static because the specific header for this DLL version was included, isn't is? So you can't exchange the DLL version because of eventually lacks of compatibility? And if I want to link a DLL dynamic I include <windows.h>. I have a bunch of typedefs for the used functions like: typedef int (*SDL_Init_i) (Uint32); And then I have to get the address of the called function at runtime with some code like this: SDL_Init_i iSDL_init; HINSTANCE hSDL = LoadLibrary("SDL.dll"); if (hSDL) { iSDL_init = (SDL_Init_i) GetProcAddress(hSDL, "SDL_init"); if ( !iSDL_init) { return 1; } } else { return 1; } After that I hopefully can use the function probably this way for example: if (iSDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) { log->log("SDL init error..."); return false; } At the end of my programm I have to free my program with FreeLibrary(hSDL);. This way I have the possibility of changing the SDL.dll for example with a newer version, haven't I? So now the actual questions for 2. ;): - Is my knowledge about DLL linking correct? - If it is: Isn't there a cross platform solution for dynamic linking or: how would this be done in a Linux environment? - I have chosen the example above because it shows an other problem: If I link a DLL dynamic, how can I use special flags or classes out of this DLL (like SDL_INIT_VIDEO or SDL_Rect as class)? 3. If I am compiling I always use the following flags: -lSDL -lSDLmain. I know they are used for the Linker and they tell what to use but why are there two for one DLL? If I also use SDL_image.DLL I have to add -lSDL_image. So exactly: What is the -lSDLmain flag for? 3.a. Is there a difference in linking static/dynamic and the use of flags? Because I "hardcode" the DLL filepath when linking dynamic, so there is no need of extra compiler flags? 4. Why are there Runtime Libraries & Development Libraries? Just a missing documentation or what is the difference? 5. Inside the lib folder of SDL there are .a files. What are they used for? I read some tutorials about DLL's and the .a files are a product of creating DLL's (surprise...). Are they part of dynamic/static links or are they needed always? EDIT: 6. If I link dynamic: Is it better to include all needed DLL-functions/classes/etc. at once at the beginning, or should I load the DLL every time a function is needed? I am not sure because I don't know how fast DLL's are. Maybe they are a bottleneck, I don't know;). Or it would consume too much memory to save all function-addresses the whole Runtime? I hopefully didn't scare you with my bad English skills and/or my newbie problems;). I am thankful for every help. Nazrim
  6. Yes it flushes every time: void Log::log (std:: string message) { logger << message << std::endl; logger.flush(); } I am not completely sure what the difference between release/debug mode (- maybe someone got sources :S? -). So I use Notepad++ for coding, and mingw32 via cmd for compiling. I have a bunch of header files for my classes and .ccp files for the actual classes. I am compiling it using the command "g++ 'all.ccps' -lSDL -lSDLmain -lSDL_image. This are my includes DLLs: libgcc_s_dw2-1.dll libstdc++-6.dll libpng15-15.dll SDL.dll SDL_image.dll zlib.dll The first two are there, because my notebook complains if they are not *shame* The rest are SDL and related DLLs. I must concede that my DLL skills tend towards zero, but I really like to improve them. ;-)
  7. Right after start up before the gameloop starts working state is initialized to MainMenu state. int main (int argc, char* args[]) { if (init() == false) { log->log ("Error on initialisation..."); return 1; } actState = STATE_MAIN_MENU; workingState = new MainMenu(); while (actState != STATE_EXIT) {
  8. Hey everyone. At first: Please excuse my poor English skills :-(. But let me tell you about my problem: I wanted to lean how to use SDL. So, at first I read some articles and tutorials. Then I started to code a "game", less a game, more object of my personal study. I want to create a framework, which grows with my knowledge, where I can implement my ideas and learn out of it. I have chosen C++ because I already have some Skills in it and want to improve them. This is my working state: - I am using Windows 7 64bit Professional - game-state-machine with actual 2 states (menu & "game"-mode) - button, timer, tileMap, animation, player, bitmapFont & log classes - menu state shows a background, with a barely animated cloud and a button, which switches to gameState - game-mode has a tileMap based background with a level read in by a file, A test of the bitmapFont, and a moveable "hero" with a camara following him (2D if there are any uncertainties) and an exit button. All this works fine on the computer I coded it on. Now the actual problem: I placed the compiled .exe and all necessary .dll's and images in my DropBox because I wanted to test it on my notebook and I direct linked the folder with a fellow student. On the source computer it isn't possible to start the game, direct ".exe doesn't work anymore..." (- hope I translated this one right -). On my Notebook (also Windows 7 64bit Professional / no seperate SDL installation) the game starts correct and enters the main Menu, but if click on the new Game button the game closes without any error message. So I set up my log and logged every step happening (See code & log below). This way I pointed out that the program exits without a reason (visible for me) after the end of the constructor of the exit button in game state. (This is the most important problem) On the computer of my friend (he actually tested with ArchLinux) it works fine in some cases or it isn't startable. (Also interesting, but it's more important for me to get a working version on my notebook, but I am interested in articles/tutorials about using SDL cross platform, because reading windows and linux tutorials and then point out the differences isn't fun, I think.) Edit: Talked to my friend again, he used windows, too, but I am still interested in cross platform sources. I am thankful for every help and advice you can provide me. :-) If new Game button is clicked nxtState is set to STATE_HOME_FARM, changeState is called every gameloop before rendering. void changeState() { if (nxtState != STATE_NO_CHANGE) { log->log("start change"); if (nxtState != STATE_EXIT) { log->log("delete act"); delete workingState; log->log("done"); } switch (nxtState) { case STATE_HOME_FARM: log->log("detected home farm"); workingState = new HomeFarm(); log->log("createt state"); break; } log->log("set vars"); actState = nxtState; nxtState = STATE_NO_CHANGE; log->log("done"); } } This is the constructor of my HomeFarm class. actWid = LEVEL_WIDTH; actHig = LEVEL_HEIGHT; log->log("create hero"); hero = new Farmer; log->log("create exit button"); exitButton = new ExitButton(SCREEN_WIDTH/2, SCREEN_HEIGHT-200 , 200, 100, "Buttons/test_button_exit.png"); log->log("create font"); This is the constructor of my ExitButton class log->log("set vars"); CLIP_MOUSEOVER = 0; CLIP_MOUSEOUT = 1; CLIP_MOUSEDOWN = 2; CLIP_MOUSEUP = 3; button.x = x; button.y = y; button.w = width; button.h = height; log->log("load img"); img = loadImg(filename); log->log("set clip"); setClips(); log->log("set initial clip"); state = &clip[CLIP_MOUSEOUT]; log->log("done"); And finally this is my log.txt created if I run the game on my notebook and try to start a Game. start change delete act done detected home farm create hero create exit button set vars load img set clip set initial clip done Nazzrim
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!