This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC, '-pg' option and 'mcount' undefined

On 1/3/2012 12:45 PM, Angelo Graziosi wrote:
For the sake of completeness, I want to flag the following issue I have
found on Cygwin.

I have an application that doesn't build on Cygwin (gcc-4.5.3) because
undefined reference to `_mcount' etc... I have tried to reproduce it
with this simple example:

$ cat hello.c
#include <stdio.h>

int main()
printf("Hello World\n");

$ gcc -c -pg hello.c
$ gcc hello.o -o hello
hello.o:hello.c:(.text+0xa): undefined reference to `_mcount'
hello.o:hello.c:(.text+0xf): undefined reference to `__monstartup'
collect2: ld returned 1 exit status

If I try the same above example (and the true application) on Mac OS X
Lion with gcc-4.5.3 or on GNU Linux distributions like Fedora14 (gcc
4.5.1), Kubuntu (gcc-4.6.1), Ubuntu (i386, gcc-4.6.1), it works just fine,

$ ./hello
Hello World

If I want to build the above example on Cygwin, I need to link using the
same option '-pg',

$ gcc -pg hello.o -o hello
$ ./hello
Hello World

Yes, I can patch my true application to use '-pg' option when it needs,
but I would know if you (Dave?) have other ideas here.

It's entirely normal to require the -pg option for linking pg compilations. You may even get a version of some libraries with pg profiling enabled.

-- Tim Prince

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]