Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with gprof on OS X: [program] is not of the host architecture

Tags:

macos

gcc

gprof

I'm having trouble running gprof on OS X. The file test.c is:

#include <stdio.h>

int main() {
  printf("Hello, World!\n");
  return 0;
}

and my terminal looks like:

$ gcc -pg test.c
$ gcc -pg -o test test.c
$ ./test
Hello, World!
$ gprof test
gprof: file: test is not of the host architecture

Edit: also, it doesn't generate the file gmon.out.

What's going on here?

like image 559
Jesse Beder Avatar asked Jul 09 '09 02:07

Jesse Beder


1 Answers

The series of events here is supposed to work as follows:

  1. Compile code with -pg option
  2. Link code with -pg option
  3. Run program
  4. Program generates gmon.out file
  5. Run gprof

The problem is that step 4 never happens. There's very little information out about this specific failure. The general consensus over the past few years seems to be that Apple would rather use shark instead, and they've been very lax about fixing bugs and such with gprof.

In short: Install Xcode, man shark

like image 133
Curtis Tasker Avatar answered Sep 17 '22 20:09

Curtis Tasker