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.
Related
I am working on native code coverage for AOSP11, I am referring following links.
Native Code coverage with android soong build system
Android Native Unit test Coverage for cpp via gcov and lcov
I have generated *.gcno and also genrated *.gcov, but after running
lcov --directory . --base-directory . --gcov-tool /usr/bin/gcov --capture -o cov.info .gcno
to collect the code coverage results, I am getting version mismatch issue, i.e.
gcno:version '402', prefer 'a75'
So I checked, and can see my host machine's gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) and gcov version (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0. And I ran "file *.gcno" (on generated *.gcno intermediates). Its printing GCC--> gcno coverage (-ftest-coverage), version 4.2 So, root cause is quite clear, but how to resolve this for Soong build system?
I'm a newbie, I wanna learn Dart language.So basically I wanna display my coverage report. Follow in this https://pub.dev/packages/test_coverage. When I using genhtml command it not working
'genhtml' is not recognized as an internal or external command,
operable program or batch file.
And in my pubspec.yaml
name: fordart
description: A sample command-line application.
# version: 1.0.0
# homepage: https://www.example.com
environment:
sdk: '>=2.7.0 <3.0.0'
#dependencies:
# path: ^1.6.0
dev_dependencies:
pedantic: ^1.8.0
test: ^1.6.0
test_coverage: ^0.4.1
dependencies:
lcov: ^*
What I missing and can all you guys advice more coverage tools supported Dart language.I searched in Google there are many coverage tools like CodeCOV, Coverall, Codacy,... but it's so hard to set up in Dart projects beacause Dart language is not a popular language and the coverage tools maybe not supported for it .If you guys know how to set up please contact me.Thanks
Right now doesn't seem like repositories with only Dart work with Codacy
The lcov package puts down the genhtml command.
If you're on OSX:
❯ brew install lcov
Warning: lcov 1.15 is already installed and up-to-date.
To reinstall 1.15, run:
brew reinstall lcov
❯ command -v lcov
/opt/homebrew/bin/lcov
❯ command -v genhtml
/opt/homebrew/bin/genhtml
If you're on other Linux, including Amazon Linux 2:
❯ yum install lcov
❯ command -v genhtml
/usr/bin/genhtml
❯ command -v lcov
/usr/bin/lcov
If you get a message the package cannot be found, you might need to enable the repo, especially true on Amazon Linux 2:
❯ yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
See: Add repositories on an Amazon Linux instance
I want to install MongoDB C++ Driver, so first is mongocxx
I follow this installation:
http://mongocxx.org/mongocxx-v3/installation/
but I can not pass step 4
when I run this in mongo-cxx-driver/build
sudo cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
it shows
-- Auto-configuring bsoncxx to use MNMLSTC for polyfills since C++17 is inactive
CMake Error at src/mongocxx/CMakeLists.txt:37 (find_package):
By not providing "Findlibmongoc-1.0.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"libmongoc-1.0", but CMake did not find one.
Could not find a package configuration file provided by "libmongoc-1.0"
(requested version 1.13.0) with any of the following names:
[![enter image description here][1]][1]
libmongoc-1.0Config.cmake
libmongoc-1.0-config.cmake
Add the installation prefix of "libmongoc-1.0" to CMAKE_PREFIX_PATH or set
"libmongoc-1.0_DIR" to a directory containing one of the above files. If
"libmongoc-1.0" provides a separate development package or SDK, be sure it
has been installed.
second question,
Step 2: Choose a C++17 polyfill how can I set MNMLSTC/core?
does anyone can help me,I already trap here for a long time ?
my env:
mongo-c-driver 1.15.1
libmongoc-1.0
mongocxx-3.4.x
Cmake is complaining about not finding a package configuration file (xxx.cmake), probably because you didn't build libmongoc/libbson.
I've tried to reproduce your issue and hit the same problem when I only installed them (apt-get install), so my suggestion is that you get the sources and build them as described at: http://mongoc.org/libmongoc/current/installing.html
Here's the list of commands (with the latest version of mongo-c-driver=1.15.1) which I just tried and worked fine:
wget https://github.com/mongodb/mongo-c-driver/releases/download/1.15.1/mongo-c-driver-1.15.1.tar.gz
tar xzf mongo-c-driver-1.15.1.tar.gz
cd mongo-c-driver-1.15.1
mkdir cmake-build
cd cmake-build
cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..
make
sudo make install
At this point you can go back into mongocxx/build and run again the command you were stuck at:
cd ../../mongo-cxx-driver/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
I am running gcov to measure coverage but I get "has arcs from exit block" message for each of the functions I use in the c code. Is there any problem with this message? Should I ignore them?
This can mean that your gcno file has been generated with newer/different version of gcc compiler. See if at the beginning you have also warning like 'version '404*', prefer '402*' If yes, solution below:
Check if g++ --version and gcov --version give you the same results. If not, update your tools like sudo apt-get install gcov, or specific version like `sudo apt-get install gcc-4.7.
If you have many versions of gcc installer you can switch between them using update-alternatives:
Query (what do you have) example: sudo update-alternatives --query gcc.
Add/make changes example: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 60
I got this issue recently, and wanted to add a piece of information in addition to #tutejszy 's answer
If you are cross-compiling your code (or using a toolchain that is not the default installed one), you will need to use this particular toolchain gcov.
And if you want to use lcov on just created gcov objects, you will need to specify the path of the toolchain gcov using option --gcov-tool <path to gcov> when running lcov
I want to compile my IOS appication from linux terminal(command line)....
Is it possible to do so, if yes, then how?
Yes, it's possible.
At least you need:
Assembler and Linker: cctools and ld64 from apple opensource.
Compiler: Clang/LLVM
SDK, include headers and libraries.
Utilities: such as ldid codesign tool.
Step 1 : The compiler
Clang/llvm >= 3.2 is highly recommended and tested.
If you want to build clang/llvm from scratch, Please refer to this link to build a svn version for your linux distribution.
If your distribution already provides clang/llvm packages,make sure it is 3.2 release or above. Lower version may work but isn't tested.
for Ubuntu 13.04 and later, clang/llvm already provided in repos, please run:
$sudo apt-get install gcc g++ clang libclang-dev uuid-dev libssl-dev libpng12-dev libicu-dev bison flex libsqlite3-dev
to install some dev packages, other dev packages related to llvm/llvm-dev should be installed automatically.
Step 2 : The assembler and linker
The latest cctools-855 and ld64-236.3 had been ported from Apple opensource to linux. the porting process is a little bit complicated, also with a lot of codes modified for linux, let's just skip it.
please check out the codes from:
svn checkout http://ios-toolchain-based-on-clang-for-linux.googlecode.com/svn/trunk/cctools-porting
Build it:
$ sed -i 's/proz -k=20 --no-curses/wget/g' cctools-ld64.sh
$ ./cctools-ld64.sh
$ cd cctools-855-ld64-236.3
$
$ ./configure --target=arm-apple-darwin11 --prefix=/usr
$ make
$ make install
For Ubuntu 13.04, since the clang/llvm 3.2 package use a customized libraries/headers path. please setup CFLAGS and CXXFLAGS first before run configure.
$export CFLAGS="-I/usr/include/llvm-c-3.2"
$export CXXFLAGS="-I/usr/include/llvm-c-3.2"
Step 3: The iPhoneOS SDK.
The old iPhone SDK with ARC support extracted from xcode had been provided in Download Sections. You can directly download it and extract it to /usr/share
For iOS 4.2: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS4.2.sdk.tar.xz
For iOS 5.0: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS5.0.sdk.tar.xz
For iOS 6.0: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS6.0.sdk.tar.xz
For other iOS versions, You may need follow these steps to get the SDK for your self.
Step 4: The utilities
iphonesdk-utils is a utility collection for iOS development, provides below utilities:
NOTE: (Some of them are collected from internet with some modifications.)
ldid : codesign tool, with armv7/armv7s support and other changes from orig version. it will be involked by ld64 after link complete.
ios-clang-wrapper : automatically find SDK and construct proper compilation args.
ios-switchsdk : switch sdk when multiple version of SDK exist.
ios-pngcrush: png crush/de-crush tool, like Apple's pngcrush.
ios-createProject : project templates
ios-genLocalization : iOS app localization tool based on clang lexer.
ios-plutil : plist compiler/decompiler.
ios-xcbuild : convert xcode project to makefile, build xcode project directly under linux.
Download the source tarball from: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iphonesdk-utils-2.0.tar.gz
Build and install it:
$./configure --prefix=/usr
$make
$make install
Build App
Now you can build and install your project simply doing:
$cd ProjectDir
$make
$make install IPHONE_IP=<your own device IP
Complete info you can find here — https://code.google.com/p/ios-toolchain-based-on-clang-for-linux/wiki/HowTo_en
The above solution given by Barjomet is correct incase if its not mavericks, but if it is Maverics then following is the solution:
1) Install the appropriate command line tool
2) for building :a)xcodebuild -list -project .xcodeproj
b)- xcodebuild -scheme build
For detail reference you can refer the following link:
https://developer.apple.com/library/ios/technotes/tn2339/_index.html.