[英]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. 我正在尝试为不是用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. 我有一个聪明的主意,可以在Code :: Blocks中编译和运行代码(因为我们正在ubuntu中运行它),因此我们可以观察它在运行时内部在做什么。 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. 但不是在Code :: Blocks中编译时。 How would I compile in Code::Blocks like I would on the command line? 我将如何像在命令行上那样在Code :: Blocks中进行编译?
Oops, missed the main question: how would you compile as-in code blocks. 糟糕,错过了主要问题:您将如何编译as-in代码块。 That's probably just adding in -g
to build debug symbols plus likely -O2
to optimise the code. 那可能只是在-g
添加以构建调试符号,并可能添加-O2
以优化代码。 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: 但是,除非您随后能够在IDE中进行调试,否则可以尝试使用gdb调试器:
-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) 在编译行中添加-g
以构建调试符号(如果要分别编译和链接,则将其链接到包括链接行在内的所有行) run the program with gdb 用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. 不幸的是,gdb是命令行的并且很难实现,但是您应该尝试使用bt
打印堆栈跟踪,然后可以print <var>
来转储状态,等等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.