cannot open graph file gcov with gcc - c++

I am using gcov as my code coverage tool for my c++ project with gcc (currently 4.6.3 but soon to be 4.8) on Ubuntu 12.04 and am getting the error cannot open graph file. What does this error mean? And how do I get rid of it so that I can see my code coverage?
I've seen other solutions to this problem the most popular being to use clang (gcov: cannot open graph file) instead of gcc but I can't switch compilers, I have to use gcc so that is not a workable solution for me. Plus, the documentation on gcov says that it should work with gcc.
Another solution was to fix a configuration file (http://ubuntuforums.org/showthread.php?t=1547252) but I'm not sure what configuration file this user is speaking of so if that is my problem as well I don't know how to fix it
my .gcda and .gcno files are correctly being generated in my obj directory
beyond going into my top directory where I compile my code and doing gcov *.c I'v also tried
gcov -o directory/to/obj *.c
and
gcov -o directory/to/obj *.gcda
and
gcov -o directory/to/obj *.gcno
but none of these solutions work; i still get the cannot open graph file error.
Any help or advice would be appreciated!

The above problem is due to absence of .gcda and .gcno file in the directory where your source code present .
So my suggestion is 1st copy one .gcda and .gcno file of particular .c file in your source code where your .c resides then execute gcov filename.c.
If you get coverage ,then try to soft link all your .gcda and .gcno to source code if dont want to copy from obj directory then as u stated problem ll be solved

Let me clarify few of the things that you were doing wrong.
First: you always tried to specify *.gcda, *.gcno, *.c etc after obj directory path, which is totally wrong.
What you need to do is to specify it as "-o path/to/obj/ " (path to directory)
You can even specify path to gcda file of that particular c/c++ source file and specify path to obj directory in "-o" flag to get the report for that file.
And if you use gcovr instead of gcov for your reports then you can get all the kind of reports by specifying only the root directory (directory above src & obj) with "-r -root=ROOT" flag.
Refer to this user guide for details on gcovr.

Related

SpiderMonkey Link Error: FloatingPoint.h not found

I'm very new to spiderMonkey and have followed this tutorial to get started (I'm using MAC OS X): https://developer.mozilla.org/en/docs/How_to_embed_the_JavaScript_engine
Every time I try to do the linking command in Step 6:
cl helloworld.cpp -link dist/lib/mozjs185-1.0.lib
I get the following 2 problems:
1) mozjs185-1.0.lib is not present in any directory (I've downloaded both the spiderMonkey and Mozilla source code)
2) Once I edit the path to point to the .lib file I do have I get the following error: FloatingPoint.h not found. However, I can find FloatingPoint.h on the system just at a different directory.
Could anyone give me a clue as to in which directory these header files should be? Or how to get the required .lib file? I've followed instructions on the mozilla development site meticulously and still can't get a hang of this.
After a few hours battling with this, I've managed to link properly by adding the hello world.cpp file in the build-release folder (as described in the Build Documentation; for more info see: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Build_Documentation).
From the terminal, I then cd into the build-release folder and type in the following command:
g++ -Idist/include -Ldist/bin -lmozjs185 helloworld.cpp -o helloworld
Unfortunately I am still getting this error:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/atomic:539:2: error: atomic is not implemented
I am pretty sure this has to do with the c++ compiler installed, and I still have to find a workaround, but at least it's properly linking now!

How to set output folder for resource compiler

I am trying to use a resource file (*.rc) in a command line compiled application, using a make file. I discovered that even though the current directory was the output directory, and that cl seems to be building its object files to this output directory, that the rc compiler will only put its output .res file in the same location as the .rc file. How can I, with some flexibility, tell rc to put its output file in a different location without a manual 'move' operation?
i.e.:
This will put source.obj file in the (current) c:\foo\bar\ directory:
c:\foo\bar>cl c:\foo\src\source.cpp
Whereas this will put a .res file in the c:\foo\res\ directory:
c:\foo\bar>rc c:\foo\res\resource.rc
The main problem is it is awkward to find a way to have the make file script do the post-compile move of the res file. Is there a way to change the output folder?
Probably an answer to your question:
MSDN specs for RC
This is the NMAKE line I have for resource compiler:
$(RC) -fo$# $**
It puts the resource file where I direct it.
It seems, however, that the directory has to exist beforehand, or RC throws its hands up in the air in dismay. Maybe I've misunderstood this problem, but I'm right about that, it's pretty lame behavior. And in that case, depending on the order of execution, you may need a MKDIR command in your makefile.

how to run the .o file after make

I have been trying to run a c++ program from https://github.com/rinon/Simple-Homomorphic-Encryption
As specified in the README I have run the following commands,
make
make test
make demo
Now, I have the following files in my directory,
zakirhussain#zakirhussain-K52F:~/Simple-Homomorphic-Encryption$ ls
circuit.cpp demo_vote_counter.cpp fully_homomorphic.cpp main.o security_settings.h test_suite.o utilities.o
circuit.h demo_vote_counter.h fully_homomorphic.h makefile security_settings.o type_defs.h
circuit.o demo_vote_counter.o fully_homomorphic.o README test_fully_homomorphic utilities.c
demo_fully_homomorphic fully_homomorphic main.cpp security_settings.cpp test_suite.cpp utilities.h
Could someone help me with running demo_vote_counter.o file?
An object file (.o) is not executable. You want to be running ./demo_fully_homomorphic (e.g. the file without extension). Make sure you have execute permissions (chmod a+x demo_fully_homomorphic).
You can not run a .o file. This is an object file and has to be linked into the final executable. A .o file is usually lacking additional libraries, which are added at the linking stage.
Looking at your outoput I would assume that one of demo_fully_homomorphic, test_fully_homomorphic or fully_homomorphic are the executables that you can run.
I think I am late, but the code below maybe helpful for someone, I guess.
Using cd into your folder contains the c/c++ file, then compile it.
gcc my_test.c -o my_test
Complied file will be generated. Then still in same folder. Run the command.
./my_test
As already mentioned in several other answers, you can execute a binary file and not the object file. However, Just in case, if what you want is to display the contents of object file in readable format?
$>objdump -d object_filename.o
You can't run the object file. It has to be linked first to make an executable.
As I see there is a "demo_fully_homomorphic" "fully_homomorphic" and a "test_fully_homomorphic" in your directory. Those are your linked executables, you may execute them with ./[executable_name]
In this case the executable is called demo_fully_homomorphic, try
./demo_fully_homomorphic

Can't get cygwin to compile C++ Boost libraries

I'm trying to get up and running with Boost, so I'm trying to compile the simple example problem from Boost's "Getting Started" page. I've had two issues, and I'm not sure they're related (I'm better than a novice, but not by much) but maybe they're related...
1st issue: the "tar --bzip2 -xf /path/to/boost_1_49_0.tar.bz2" command didn't work (yes, I put the correct path in, but it gave me some errors, I forget what they were) so I used "tar -xjvf " from the directory where boost_1_49_0.tar.bz2 was located. That de-compressed the zip file and I proceeded with the example...
2nd issue: The example.cpp file will not compile, the first statement in the code is #include "boost/lambda/lambda.hpp" but then for every header file lambda.hpp is trying access, there's a "No such file or directory" compile error. For example, here are two (of the six, and I get errors for all 6) header files within lambda.hpp and the errors displayed by the cygwin compiler:
boost/lambda/lambda.hpp:14:33: boost/lambda/core.hpp: No such file or directory
boost/lambda/lambda.hpp:21:52: boost/lambda/detail/operator_actions.hpp: No such file or directory
If it helps, this is the command I'm running to compile (I generally create the executable in a separate -o command):
g++ -c example.cpp
Why can't the system find these? I added the installed directory (path/to/boost_1_49_0) to the PATH variable before I started so I know that's no it. Thanks for any advice...
(I've looked on stackoverflow and there were similar issues, but no solutions that worked)
It looks like you've already solved the first issue: namely, that you must specify the -j flag on tar to untar a bzip2'd file.
For the second issue, you need to specify boost on your include path, either by specifying it with the -I command line option or via the CPLUS_INCLUDE_PATH environment variable.

Does anyone know what the "-FC" option does in gcc g++?

Does anyone know what the "-FC" option does in g++?
I have it in my SConstruct script that builds the command line g++ command, I have searched google
You know, if all fails, read the manual :-).
Fdir
Add the framework directory dir to the head of the list of directories to be searched for header files. These directories are interleaved with those specified by -I options and are scanned in a left-to-right order.
[...]
Source: http://gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/Darwin-Options.html#Darwin-Options
So -FC will apparently add the framework directory "C" to the header file search path.