Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

140 Neutral

About Maeriden

  • Rank
  1. Maeriden

    Subdirectories in makefile

    I know. It just didn't seem a smart solution so I looked for something else
  2. Maeriden

    Subdirectories in makefile

    Mmm it's not very different from mine. To get around the issue of directories the target objects are written directly with obj/ prepended. I wanted to avoid this solution because I didn't understand how to make make (no pun) work out the headers dependencies with a rule like $(OBJECTS): obj/%.o : src/%.cpp and thus decided to write a rule for each .o to avoid recompiling the whole project. Doing so meant that I had to manually write the directory variable in each rule, which seemed kind of dumb. From the informations I was able to gather (I couldn't find an example that explained problems with GPATH) it looks like the solutions are: writing the path manually for each rule, using the general rule and have all the sources recompiled every time an header changes, or learning to use .d files (which will wait since I got fed up with make for a while). Or use a different make system. Thank you all for your advice, I really apreciate it :)
  3. Maeriden

    Subdirectories in makefile

    Well, I don't actually plan on cleaning the .o files very often, and I prefer not to keep them in the project root directory I don't specifically need to write a file that works with other tools, but I suppose it would be better to learn how to do it. Which extensions did I use? I've been wondering about this kind of rules. I've seen "$(OBJ): %.o: %.cpp" (here) but I can't understand how that would handle recompilation in the case a header file included by the source is modified   Thanks for the offer, but I've already seen quite a bit of examples. What I need is someone who would explain them
  4. Maeriden

    Subdirectories in makefile

    That's what I thought at the beginning (see the note). In that case if any .o is not found it gets built in $(OBJ_DIR), then make links files in $(OBJ_DIR) and makes me happy. But every time that a file does NOT need to be rebuilt, the path where make finds it is remembered (so main.o becomes obj/main.o) when used both as target and dependency. Proceeding to the link command it becomes g++ -o bin/exe obj/obj/main.o   What really makes my head hurt is why make ignores GPATH. I wouldn't have any problem if only that worked
  5. In an effort to try to learn makefiles I wrote this   C = $(CXX) CFLAGS = -g -Wall -Wextra -I$(SRC_DIR) -std=c++0x SRC_DIR = src BIN_DIR = bin OBJ_DIR = obj vpath %.cpp $(SRC_DIR) vpath %.h $(SRC_DIR) vpath %.o $(OBJ_DIR) GPATH = src obj SRC = main.cpp resources.cpp ui.cpp OBJ = $(SRC:.cpp=.o) .PHONY: clean all all: $(OBJ) $C -o $(BIN_DIR)/exe $^ main.o: main.cpp defaults.h $C -c $< -o $(OBJ_DIR)/$@ $(CFLAGS) resources.o: resources.cpp resources.h $C -c $< -o $(OBJ_DIR)/$@ $(CFLAGS) ui.o: ui.cpp ui.h defaults.h $C -c $< -o $(OBJ_DIR)/$@ $(CFLAGS) clean: rm -f $(OBJ_DIR)/*.o When I run make and the obj directory is empty it compiles all the .cpp files and places them in $(OBJ_DIR)/$@ -> obj/file.o However when it is time to execute the all target, g++ doesn't find .o files, because $^ contains only the files without the directory prepended According to http://www.gnu.org/software/make/manual/make.html#Search-Algorithm this is the intended behavior (though not what I want at all) and it says I can modify it using the GPATH variable, which I set but seems to be ignored by make Notes: if I run make again it finds the files in the obj directory, and since they don't need to be recompiled the path is preserved, so I can't even modify all to be $C -o $(BIN_DIR)/exe $(addprefix $(OBJ_DIR)/$^) A first invocation of make would build and link the files correctly, but the second time it would try to link obj/obj/file.o and fail What am I doing wrong?
  6. I noticed it just recently, as I've been writing quite a bit without debugging. What is weird is that it didn't use to happen before (or maybe I just never noticed? But it seems unlikely...). So after hours of trying to see if I screwed up somewhere I decided to make a simple test program [source lang="cpp"]#include <SDL.h> #include <iostream> #undef main // To use standard output int main ( int argc, char** argv ) { if(SDL_Init(SDL_INIT_VIDEO) < 0) { std::cout << "Unable to init SDL: " << SDL_GetError(); return 1; } SDL_Surface* screen = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE); if (!screen ) { std::cout << "Unable to set 640x480 video: " << SDL_GetError(); return 1; } SDL_Quit(); // Error here return 0; }[/source] Running gdb from codeblocks shows me 4 sigsegv before the debugger shuts down. This is the call stack for the first one (in the others the addresses of unknow functions change). Sometimes it stops at EndTask and sometimes at lstrlenA #0 76D27CDA USER32!EndTask() (C:\Windows\syswow64\user32.dll:??) #1 00000000 0x01967979 in ??() (??:??) #2 00000000 0x0028fdc4 in ??() (??:??) #3 1000D676 HydraDMH!HookMessages() (C:\Program Files (x86)\ATI Technologies\HydraVision\HydraDMH.dll:??) #4 00000000 0x00360820 in ??() (??:??) #5 00000000 0x00000000 in ??() (??:??) #0 76E0AD97 lstrlenA() (C:\Windows\syswow64\KernelBase.dll:??) #1 00000000 0x385f24bb in ??() (??:??) #2 00000000 0x00000100 in ??() (??:??) #3 00000000 0x40380000 in ??() (??:??) #4 76D27C95 USER32!EndTask() (C:\Windows\syswow64\user32.dll:??) #5 00000000 0x0028f938 in ??() (??:??) #6 76D27CEC USER32!EndTask() (C:\Windows\syswow64\user32.dll:??) #7 00000000 0x40380000 in ??() (??:??) #8 00000000 0x383353d9 in ??() (??:??) #9 00000000 0x0028fdc4 in ??() (??:??) #10 1000D676 HydraDMH!HookMessages() (C:\Program Files (x86)\ATI Technologies\HydraVision\HydraDMH.dll:??) #11 00000000 0x00230848 in ??() (??:??) #12 00000000 0x0028f9b4 in ??() (??:??) #13 00000000 0x00000000 in ??() (??:??) [/quote] I have no idea of what to do. My skills in debugging are also close to 0. Can anyone help please?
  7. Well, the issue is pretty simple: I'm trying to debug my code and when the debugger hits the call to module->Build() first the program closes itself, then the debugger stops itself too, with the message "The program is not being executed" I'm still a real novice when it comes to debugging, and I started trying out AS only recently, so I'm wondering if there's anyone who can help me understand what's going on. I'm using C::B 10.05 and its debugger (which I believe is called DBG?). I'm not posting info right now since I have no idea what could be relevan to the problem.
  8. That doesn't really work because the states are not already in the vector, ChangeState() pushes them into it (honestly I would have used a different system which doesn't involve a vector at all, but the tutorials on internet say to do it like this, and supposedly they know better than me, so...) But I think you nailed the problem! In the implementation file for each state I didn't include the header of the other state that was being passed to ChangeState(), so I guess it couldn't see that it was derived from GameState, it would see it as a, say, PlayState pointer because it is declared like that in GameManager.h. Including the states headers in GameManager.h made it work because then each state header, by including GameManager.h, would have included the other states headers as well Thank you very much I'll keep that in mind. Since in the source file where ChangeState() is defined the states headers are included, and it is the same file where the states are instantiated, ChangeState() knows that they are derived and I thought it was enough to make it work.
  9. I am trying to make a game states system. I made a virtual base class 'GameState' and derive the various states from it. The states are pushed in a std::vector<GameState*> At first I declared the class holding the vector, the GameState base class, and derived states classes all in the same header and implemented them in the same source file, and everything was ok. There is a function called by the states that changes the current state [source lang="cpp"]void ChangeState(GameState* newstate)[/source] Then I decided to put each class in a separate header-source and the problem appeared. If i try to pass to it, say, a pointer to an instance of class PlayState (derived from GameState) the compiler gives the following error [source lang="cpp"]game->ChangeState(game->play_state)[/source] error: no matching function for call to 'GameManager::ChangeState(PlayState*&)' note: candidates are: void GameManager::ChangeState(GameState*) [/quote] 'game' is a pointer to GameManager that every state has GameManager holds the vector and pointers to states' instances (like play_state). Trying random stuff, I noticed that if I include the headers of each derived state in GameManager.h (instead of GameManager.cpp) the problem gets fixed (at first I just forward declared the classes since GameManager holds only pointers). I'd like help in understanding what's going on. Sorry if the explanation isn't very clear but I have trouble identifying the issue myself and I didn't want fill the post with all the headers (I'll do it if it's necessary though)
  • 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!