NOTE: Can't find main function compiled -g

Hi there, I am trying to debug some C code and am coming up with the following error when I run pgbdg:

NOTE: Can’t find main function compiled -g

However, there is a main function and the code starts to run (and eventually falls over, hence the need to debug). The code compiles with a couple of warnings (Function XXX has non-ptototype declaration in scope) and, as I said, starts to run, thereby running the main function before falling over later on. What do I need to do to be able to debug this code and find out where it’s really going wrong?

Any help you can offer would be greatly appreciated.

Hi jonesds,

Try re-compiling your code with “-g” and then rerun using PGDBG. “-g” inserts symbols in the code which debugger can use to associate your source with the assembly code and give you more information as to where you are in the code and what is happening. While you can use the debugger without compiling “-g”, it can be difficult to debug unless you understand assembly code.

For information about using PGDBG, please refer to the PGI Tools Guide (found HERE).

  • Mat

Hi Mat,

Thanks for your suggestion but I have already tried compiling with -g in order to debug the code; this is why the error is so puzzling!

I’d be very grateful for any further thoughts you may have on this.

Fixed it!

My apologies for wasting your time, I’ve just realised that I had -s in the link command. Thereby stripping any markers out of the code and completely negating the -g used on compilation.

What an idiot.