I am trying to gprof my program. I want a line-by-line profiling.
However, I can't seem to get the syntax right. I am using "make" and not "gcc" so please help only with suggestions that fit make. I wouldbe very grateful if you can give me the full "make" syntax.
Based on this website:
http://sourceware.org/binutils/docs/gprof/Output-Options.html[^]
http://sourceware.org/binutils/docs/gprof/Line_002dby_002dline.html[^]
Here is what I am inputting:
make USE_LOCAL_HEADERS=0 LDFLAGS='-L.' BASE_CFLAGS=-m32 CFLAGS='-fopenmp -pg -l -g'
The output is:
/usr/bin/ld: cannot find -l-g
collect2: ld returned 1 exit status
make[2]: *** [build/release-linux-ppc64/ioquake3.ppc64] Error 1
make[2]: Leaving directory `/r/home7/yasir/minoru/cfe2/yasirTemp/ioquake3dev/svfb_201110271440/ioquake3dev_clean'
make[1]: *** [targets] Error 2
make[1]: Leaving directory `/r/home7/yasir/minoru/cfe2/yasirTemp/ioquake3dev/svfb_201110271440/ioquake3dev_clean'
make: *** [release] Error 2
I need option "-l", "-g" and "-pg".
-pg enables profiling, -g includes symbol names which help interpreting the profile generated.
The -pg option needs to be passed to compiler and linker.
The -l command does not make sense in the way you are using it, as it needs a library name as parameter, so as long as you do not provide one, leave the -l away.
Also during development I'd recommend the -Wall option to enable all warnings during compilation.
So you might try this make command:
make USE_LOCAL_HEADERS=0 LDFLAGS='-L. -pg' BASE_CFLAGS=-m32 CFLAGS='-fopenmp -pg -g -Wall'
You can pass most of those as environment variables, make "should" do the right thing and use them for the compiler:
$ USE_LOCAL_HEADERS=0 \
LDFLAGS='-L.' \
BASE_CFLAGS=-m32 \
CFLAGS='-fopenmp -pg -g' \
make
That will USE_LOCAL_HEADERS, LDFLAGS, BASE_CFLAGS and CFLAGS as environment variables which make and gcc can see. You may have to edit your Makefile to combine them in the correct ways for what you want.
make is simply a "to determine automatically which pieces of a large program need to be recompiled, and issue the commands to recompile them" (man make). It looks like make cannot make sense of your arguments; it doesn't actually get to run any commands before it encounters an error.
I'm sorry I can't help you any further, but your problem is within your make file or similar. You should read up on what a make file is, and how to gprof your program and understand the difference between make and gcc, and reevaluate what you are trying to do. Make may not be useuful to you.
Related
I am attempting to run a make file for a third party piece of software but I am getting an error when I run it:
$ make
gcc -Iinclude/ -Isrc/ -Wall -Wfatal-errors -Ofast -c ./src/gemm.c -o obj/gemm.o
In file included from ./src/gemm.c:2:
In file included from src/utils.h:5:
In file included from src/list.h:3:
include/darknet.h:491:1: fatal error: unknown type name 'pthread_t'
pthread_t load_data(load_args args);
^
1 error generated.
make: *** [obj/gemm.o] Error 1
I'm not very familiar with C, but from what I can tell pthread_t is a datatype that is similar to an int. I looked at the line that is causing the error:
pthread_t load_data(load_args args);
but don't see anything that would be an obvious cause of the problem.
I looked in my make file and I see this line:
LDFLAGS= -lm -pthread
Could this be part of the problem?
Does anyone know what I might need to do in order to get the pthread_t type recognized so I can run the make file?
I apologize if the answer is obvious - I tried googling the specific error message I was getting but didn't turn much up. Please let me know if I need to post any other other code than what I have already included.
Your error comes from not including the pthread library (assuming you are compiling this for a posix compliant system, if you are on windows pthreads are unlikely to work).
See were the pthread library is installed in your machine and include it in the command line.
I am want to begin working on the 4th assginment, RSS searcher, of Online Stanford CS107 Programming Paradigms course. However, I am lagging at the very first step; I can not compile the prepared, to-work-on, unfinished program.
I get this error when I type make;
gcc rss-news-search.o -g -Wall -std=gnu99 -Wno-unused-function -g -lnsl -lrssnews -L/media/D/Programming/assn-4-rss-news-search-lib/ -o rss-news-search
/usr/bin/ld: cannot find -lrssnews
collect2: error: ld returned 1 exit status
Makefile:32: recipe for target 'rss-news-search' failed
make: *** [rss-news-search] Error 1
I have installed libexpat-dev.
Here is the link to the course, its the 4th programming assignment, RSS;
https://see.stanford.edu/Course/CS107
Thanks in advance
That the project comes with librssnews.a is good news. This file is a static library called rssnews and this is what you need to compile the project successfully!
Warning: you almost certainly don't need to follow these steps, go on reading to see why.
Put this file in your project's directory (the one you're running the build from) or in the lib directory, if the project contains one (if it doesn't, don't create one).
Run the build again. If it fails with the same error, go on to next steps.
Find out where the compiler normally looks for libraries by compiling a simple code with the -v flag. For example, gcc simple.c -v. You'll get tons of output that will contain the paths the compiler visited to link your program.
Copy the library file to one of these paths and run the build once again.
Given that the library search path is specified explicitly, you can simply put the library into /media/D/Programming/assn-4-rss-news-search-lib/ and skip the steps discussed earlier altogether. But if it wasn't, you'd probably have to follow them.
Hello i am new to ubuntu. I want to run a c program in ubuntu.On the terminal i typed "make ex1.c" (my file name is ex1) and the after pressing enter button , terminal is telling me that
"no rule to make target 'ex1.c'. stop " .
How can i proceed?
Try this
$ gcc -Wall ex1.c -o ex1
$ ./ex1
-Wall makes all the warnings explicit. It is considered to be a good practice to always enable -Wall option. -o ex1 specifies the output executable to be ex1.
GCC is the default C compiler on Ubuntu. An elegant introduction to gcc can be read in here.
make needs no rules to make a simple C file, all it needs is the basename, without the .c extension:
make ex1
./ex1
I advise you to start using the gcc command though. You will have more control on how stuff is compiled and along the way, you'll learn how building an application works. make will start making sense if you have a larger project with many (inter dependent) files.
More (a lot!) information here: http://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/, or by typing man gcc in the terminal.
Best is to use GCC or you are getting error because you are attaching ".c".So don't put extension in make command.Try without putting extension like following:
make ex1
./ex1
I'm trying to compile an open source project on windows under mingw/msys.
The makefile contains (among others) this line
#${MAKE} --no-print-directory -C . -f physfs.make
physfs.make contains (among others) these lines:
ifndef CC
CC = gcc
endif
when I ran make I get the following error:
Creating obj/Debug/physfs
physfs.c
make[1]: cc: Command not found
make[1]: *** [obj/Debug/physfs/physfs.o] Error 127
make: *** [physfs] Error 2
If I comment the ifndef / endif pair leaving CC = gcc intact, the build works. If instead of make I issue this command:
make -e CC=gcc
the build works as well. But when I run the following command in msys:
echo $CC
nothing is displayed.
I think there is something basic about how environment variables work in MSYS and make that I don't understand.
Could please some help me troubleshoot this issue, so I can understand why simple 'make' command complains and why the ifndef block doesn't function as I expect it to function.
CC is one of several implicit variables automatically defined in a make session, so the line ifndef CC should never evaluate to true.
This explains why you see nothing on the command line for echo $CC. The MSYS environment has no concept of CC.
If you want to see the value of variables from within a make session, you can always use the info function:
$(info $(CC))
This will echo the value of the CC variable to the console at the point when that line in the makefile is evaluated.
I'm trying to build GCC for use with an AVR microcontroller and avr-ada, and I've hit a roadblock caused by my regular compiler being too picky about the version I needed for the AVR. I get the following warning, which in turn causes GCC or Make to report an error:
gcc -c -g -O2 -gnatpg -gnata -nostdinc -I- -I. -Iada
-I../../gcc/ada ../../gcc/ada/exp_ch5.adb -o ada/exp_ch5.o
exp_ch5.adb:177:16: warning: function "Has_Address_Clause" is not referenced
make[2]: *** [ada/exp_ch5.o] Error 1
make[1]: *** [all-gcc] Error 2
make: *** [all] Error 2
Is there a way to instruct GCC or Make to not fail on warnings?
Try make -k instead of just make. That will 'continue' rather than stop.
As an alternative to diving into the build system, try setting -Wno-error in CFLAGS, which you should be able to do through the environment (or at configure time, if using the GNU build system).
The trigger here is the -gnatpg (actually, the -gnatg): this is the "GNAT implementation mode (used for compiling GNAT units)". -gnatp means "suppress all checks".
I'm not sure of the full effect of -gnatg, though it certainly causes warnings to be treated as errors -- like -Werror -- at any rate while building the compiler itself; I think I remember seeing non-fatal warnings while building the RTS.
One possibility would be to compile just exp_ch5.adb by hand without -gnatg; the command you list was issued at gcc/, so
$ cd gcc
$ gcc -c -g -O2 -gnatp -gnata -nostdinc -I- -I. -Iada -I../../gcc/ada \
../../gcc/ada/exp_ch5.adb -o ada/exp_ch5.o
Then back up one level, and 'make' again.
This is a cross-compiler, so you won't (I hope!) need to repeat this for all three stages of a full build.
It seems the -Werror flag is set in the Makefile. Maybe you can look for the CFLAGS options in the Makefile and remove the -Werror flag. The Werror flag will make all warnings into errors.
In general, it is not a good idea to ignore warnings from your compiler. However, if this is a portion of a larger make process there is likely a -Werror flag inserted earlier in the sequence. Start by looking for that.
After looking around, there seems to be a wealth of flags to control warnings while compiling Ada code. For instance, -gnatwF will Suppress warnings on unreferenced formals according to this guide. Possibly the switch you require can be found in the list provided there.
In gcc configure you can add --disable-werror.
Though it's advisable to seek out a proper patch first.
Put "pragma warnings(off, "...")" into the offending parts of your code.
See http://www.adacore.com/2007/11/19/ada-gem-18/.