简体   繁体   中英

Compile in Code::Blocks like in command line

I am attempting to test a program for a colleague that was not written in an IDE. When we go to run it, something goes wrong and we are having a heck of a time trying to figure out what it is.

I got the bright idea to compile and run the code in Code::Blocks (as we are running it in ubuntu) so we could watch what it was doing internally as it was running. The code compiles when you type in:

g++ fe_cmd_arg2_new.c -pthread K_drv_21.cc urg_drv_425.cc o_structures.c ri,cc star_cam_374.cpp com_Unit.o

but not when it is compiled in Code::Blocks. How would I compile in Code::Blocks like I would on the command line?

Oops, missed the main question: how would you compile as-in code blocks. That's probably just adding in -g to build debug symbols plus likely -O2 to optimise the code. But if you're debugging it might help to leave off the optimisation switch.

However unless you're then able to debug in an IDE you could try the gdb debugger:

  • add -g to your compile line to build in debug symbols (if you're compiling and linking separately then to all lines including the link line)
  • run the program with gdb

     gdb ./a.out run <command line args> 

Unfortunately gdb is command-line and difficult to approach but you should try bt to print a stack trace, then you can print <var> to dump state, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM