home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!think.com!rpi!zaphod.mps.ohio-state.edu!uunet.ca!ohrd!twriter
- From: twriter@rd.hydro.on.ca (Timothy Writer)
- Subject: Re: profiling g++ code
- Message-ID: <1992Dec21.223548.8464@rd.hydro.on.ca>
- Reply-To: twriter@rd.hydro.on.ca
- Organization: "Ontario Hydro - Research Division"
- References: <BzHJwy.LpG@cs.columbia.edu>
- Distribution: usa
- Date: Mon, 21 Dec 92 22:35:48 GMT
- Lines: 42
-
- ykim@cs.columbia.edu (Yong Su Kim) writes:
-
-
- >I have a C++ program and I would like to profile it to see which
- >functions are taking the most time so that I can optimise those
- >functions.
-
- >I tried g++ -p, but I get an error message saying that the symbol
- >"mcount" is undefined.
-
- On many systems you need to link with a profiling library, for example
- /usr/lib/libc_p.a (Sun) or /usr/lib/libprof1.a (SGI). The -p option of
- g++ (gcc) is supposed to take care of this for you; however, on some
- systems it may not, for example, my SGI. On my system g++ -p -v
- illustrates the problem:
-
- ...
- /very-long-path/ld /usr/lib/mcrt1.o ... file.o -lg++ -lgcc -lc_p ...
-
- Do you see the problem? g++ is trying to link libc_p not libprof1. Of
- course, the proper fix is to patch g++ which is not difficult but I
- haven't had time. The short term solution is to add -lprof1 to the g++
- command line and create a dummy libc_p.a in the current working
- directory:
-
- ln -s /usr/lib/libc.a libc_p.a
- g++ -L. -p -v file.o -lprof1
-
- As you didn't tell us what kind of system you are using, I can't say if
- this fix will work for you but you should be able to do something
- similar.
-
- >Are there other ways, or other programs which will allow me to
- >determine which functions are taking the most time?
-
- Tim
-
- --
- Tim Writer phone: (416) 231-4111 ext. 6990
- Ontario Hydro Research Division fax: (416) 237-9285
- Toronto, Ontario e-mail: twriter@rd.hydro.on.ca
- CANADA
-