Catkin_make with Gcov - gcov

These days I have tried so hard to test my rosapp. I want to use Gcov when testing my rosapp. However, I am not so familiar with that. I have tried to add Gcov in my CMakeList.txt but no .gcda files were generated. Does anyone konw how to solve it?

The following options can be passed to catkin tools to add coverage instrumentation to the files within your catkin workspace:
$ catkin config --cmake-args \
-DCMAKE_CXX_FLAGS="--coverage" \
-DCMAKE_LD_FLAGS="--coverage"

Related

Trying to build OpenSfm but my OpenCv build doesn't have the proper Cmake file

I tried running 'python setup.py build' to build Open SfM. I had used the instructions off the OpenCV website to build OpenCV using gitbash and Cmake in my lib folde without any errors.
However the OpenSfM build error says: Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
I can't for the life of me find these files. I tried downloading the OpenCv package again and running it through a Cmake GUI but I get an error saying there's no CmakeLists.txt files.
Help?
You need to not just generate the files using CMake but also use either an application like VisualStudio or command line to build the files.
Once you build the files, the OpenCVConfig.cmake files are generated, which you use to point to the OpenSFM compilation.

run configure to generate shared libraries [Ubuntu]

I'm running a ./configure script and make to build a library. However, only .a libraries are generated. Is there an option to generate shared libs?
It's going to depend on the project you're trying to build. Run
./configure --help
to get a list of all options you can pass to ./configure, there may be a --shared option or something similar.

code coverage with gcovr and Xcode 5 is not working

I'm using gcovr to generate code coverage for cobertura.
Everything was working fine with xcode 4.6. Now I updated to xcode5 and everything I get is 0% coverage...
my setup:
gcovr 3.0
Xcode 5 (Apple LLVM 5)
'Generate Test Coverage Files' is set to YES
'Instrument Program Flow' is set to YES
and to command I use:
gcovr -r . --object-directory Build/Intermediates/myApp.build/Debug-iphonesimulator/myApp.build/Objects-normal/i386 --exclude '.*Tests.*' --exclude '.*KiwiUnitTest' --exclude '.*main.*' --xml > reports/coverage.xml
is someone having the same issue or better, have a solution? :)
And now it works again... :)
as #kenji said, Xcode 5.1 solved the problem. thx btw
here is my working environment and configuration for the one who are interested
Xcode 5.1.1 (from the AppStore)
gcovr 3.1-prerelease (installed with easy_install)
and in my project under 'Build Settings' I set the following:
'Generate Test Coverage Files' is set to YES
'Instrument Program Flow' is set to YES
after I run the tests, I execute the following command: (happens with jenkins)
gcovr -r . --object-directory Build/Intermediates/MyProj.build/Debug-iphonesimulator/KiwiUnitTest.build/Objects-normal/i386 --exclude '.*Tests.*' --exclude '.*KiwiUnitTest' --exclude '.*main.*' --xml > reports/coverage.xml
done.
sorry guys for making you wait for an answer and thank you everyone for your help.
At first make sure that your .gcda and .gcno files are created!
(Check: ~/Library/Developer/Xcode/DerivedData/{YOUR-PROJECT-NAME}/Build/Intermediates/{YOUR-PROJECT-NAME}.build/Debug-iphonesimulator/{YOUR-PROJECT-NAME}.build/Objects-normal/i386 )
If they have been successfully created you need to do the following:
(If not check the comments under your question)
copy the all the files from the folder i386 (full path as described above) into you
workspace where your .h and .m files are.
run terminal and change you parent working directory to your workspace
cd [YOUR WORKSPACE PATH]
run gcovr
gcovr -r . --xml > reports/coverage.xml
If you are using jenkins (which i assume) this will be your further steps:
Generating gcda files to view the code-coverage from XCTests in IOS with Jenkins
Let me know if you still have questions!

Clang Code Coverage Invalid Output

So I've checked out and built the clang trunk by following these instructions http://clang.llvm.org/get_started.html. I can build my binary with --coverage and run it to get the .gcno and .gcda files, but when I run lcov I get "GENINFO: ... reached unexpected end of file".
Now I'm stuck and came to SO to look for help :)
I'm working with Ubuntu 13.04 and writing c++11, just in case that makes a difference.
I had the same problem with clang with lcov on Ubuntu 13.04.
Here is the solution which worked for me on more than one Ubuntu setup.
You will find there are two versions of gcov on Ubuntu. gcov-4.6.4 & gcov-4.7.3. By default the gcov link is set to gcov-4.7.3. Change that to gcov-4.6.4
Furthermore, use lcov version 1.10 instead of what is available via apt-get install
This should generate the code coverage report.
EDIT: Mine was a upgrade from Ubuntu 12.04 to 13.04. Just in case you don't see two versions of gcov.
Just summarising the steps for the answer already shared by #Himanshu in case somebody's looking for the exact steps to go about it:
Install gcc 4.6
sudo apt-get-install -y gcc-4.6
I couldn’t find locv 1.10 version out of the box so I compiled it myself:
git clone https://github.com/linux-test-project/lcov.git
cd lcov
Switch to a new branch with the commit that published lcov 1.10 version as base
git checkout -b 1_10 b5c1bdd
Compile lcov
sudo make install
Confirm that lcov installed is 1.10
lcov --version
With all these things in place, use the command:
lcov --gcov-tool /usr/bin/gcov-4.6 --capture -d gcov_data/ -o gcov_data/coverage.info
This avoids tinkering with the link of the default gcov on the system.
Then generate the visual coverage file
genhtml -o gcov_data/html gcov_data/coverage.info
where gcov_data is the folder containing the gcno and gcda files.

Compiling using cmake with dependencies installed using macport

I'm trying to build project that has dependency to OpenCV. I installed Opencv using macports and when I try to build project, cmake gives the following output:
CMake Error at CMakeLists.txt:47 (FIND_PACKAGE):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
I searched a little bit about this problem and added the following env. variables to my $HOME/.profile file
export DYLD_LIBRARY_PATH=/opt/local/lib:$DYLD_LIBRARY_PATH
export CMAKE_PREFIX_PATH=/opt/local
without success. I checked and I have all opencv files istalled in /opt/local/lib and /opt/local/include/opencv directories. There is also OpenCVConfig.cmake in the following path:
/opt/local/lib/cmake/OpenCVConfig.cmake
How to make cmake know the path where opencv is installed? Previously I've build OpenCV on my own using cmake and installed into /usr/local and then it worked fine without any other fix. However I had some problems with ffmpeg and right now I switched to using macports.
Another option that works for me was set the env value OpenCV_DIR at the cmake opencv dir:
export OpenCV_DIR=/opt/local/lib/cmake/
macports traditionally installs OpenCV to /opt/local/ instead of the standard /usr/local/.
The solution to your problem is stated at:
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files.
When building your project in the command-line, make sure you execute:
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/local/lib/pkgconfig
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib
And then set the flag CMAKE_PREFIX_PATH for cmake:
cmake -D CMAKE_PREFIX_PATH=/opt/local ../
Not a MACPORT problem, but someone may find this helpful. Followed #hugh-pearse 's and #leszek-hanusz 's answers in this question, with a little tweak. I had installed opencv from ubuntu 12.10 repository (libopencv-)* and had the same problem. Couldn't solve it with export OpenCV_DIR=/usr/share/OpenCV/ (since my OpenCVConfig.cmake whas there). It was solved when I changed some lines on the OpenCVConfig.cmake file:
# ======================================================
# Include directories to add to the user project:
# ======================================================
# Provide the include directories to the caller
#SET(OpenCV_INCLUDE_DIRS "${OpenCV_INSTALL_PATH}/include/opencv;${OpenCV_INSTALL_PATH}/include")
SET(OpenCV_INCLUDE_DIRS "/usr/include/opencv;/usr/include/opencv2")
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})
# ======================================================
# Link directories to add to the user project:
# ======================================================
# Provide the libs directory anyway, it may be needed in some cases.
#SET(OpenCV_LIB_DIR "${OpenCV_INSTALL_PATH}/lib")
SET(OpenCV_LIB_DIR "/usr/lib")
LINK_DIRECTORIES(${OpenCV_LIB_DIR})
And that worked on my Ubuntu 12.10. Remember to add the target_link_libraries(yourprojectname ${OpenCV_LIBS}) in your CMakeLists.txt.
I finally read the header of the OpenCVConfig.cmake file.
It instructs to include these lines to use from an external project:
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(MY_TARGET_NAME ${OpenCV_LIBS})
(adding include_directories to CMakeLists.txt fixed it for me)
Make sure you have compiled OpenCV, once you compiled, OpenCVConfig.cmake will be generated in build directory.
follow these steps to compile
then , export OpenCV_DIR=<path to build directory with OpenCVConfig.cmake>
It should work now !
I tried all the above ideas in vain.
I eventually found a way to have the compilation work: Besides using #kengregson steps, I simply renamed the folder /usr/local/include/opencv2 so that it is not chosen when compiling my cpp file.
Since I compile my own OpenCV in a multiple-users server, so I can't install the OpenCV libs in /usr/local directly, but in my home folder instead, then exactly the same issue occurs to me.
Below is how I fix it:
Flowing the steps in OpenCV official doc: Using OpenCV with gcc and CMake
Add displayImage test program, and use this CMake file
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV)
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
The same error happened, so add one environment variable in my .tcshrc
setenv OpenCV_DIR "${folder where contains OpenCVConfig.cmake }"
\# mine is:
setenv OpenCV_DIR "~/local/OpenCV2.4.13/share/OpenCV"

Resources