Can't load debugging symbols on gdb

Hi, guys. I’m trying to compile my cocos2d-x cpp project with debugging symbols, so that I can debug it with gdb on vim, as I’m not a fan of IDEs. I’m doing so with the following command: cocos compile -m debug -p linux. However, after loading the binary onto gdb (with file bin/debug/linux/projectname), I get no results when I search for those symbols. For instance, when I run info types TypeName I get nothing returned to me. Furthermore, if I search for info on a function I’ve declared (with info functions NameSpace::TypeName::funcName), the name of that function and no additional info gets listed under the “Non-debugging Symbols section”, thus suggesting these symbols aren’t being attatched to my binary when compiling.

How can I actually get those symbols? If I were to compile some program directly with g++ I’d be able to just pass the -g flag, but how can I go about doing that with the cocos tool. If I’m not able to do this using the cocos tool, how can I go about compiling my game without it and without an IDE?

what about using CMake to do everything instead of the cocos tool? That should do the trick, I’d suspect. We support CMake, please see out CMake Guide

1 Like

Alright, now I feel kinda dumb, but (since cocos has already written a CMakeLists.txt for me) I should be able to just cmake . && make right? So that’s what I did, except I ran make -DCMAKE_BUILD_TYPE=Debug . && make. Guess what? It worked, now I can load the binary onto gdb with all those pretty debugging symbols. However, when I ran make, the entirety of cocos2d-x was rebuilt from scratch too. Whenever I’d compile through cocos, it’d build only my game, which would save me a lot of time after I changed something in my code. Do you happen to know how can I build just my game and not all of its dependencies, just like cocos did, but using cmake and make?

You could make a prebuilt library. We used to support this but it’s a simple google search.

I’ve found out that cmake --build . --target <gamename> does just that, it’s supposed to be used instead of make.

 

For those looking to ctrlc ctrlv a solution:

make -DCMAKE_BUILD_TYPE=Debug . && cmake --build . --target <gamename>