Multiple definition error using GFLAGS with tcmalloc - code-coverage

~/common/lib/libglog.a(libglog_la-utilities.o): In function `google::LogMessageVoidify::LogMessageVoidify()':
~/glog/glog-0.3.2/src/utilities.cc:80: multiple definition of `FLAG__namespace_do_not_use_directly_use_DECLARE_bool_instead::FLAGS_symbolize_stacktrace'
~/common/lib/libtcmalloc.a(libtcmalloc_minimal_debug_la-debugallocation.o):~/tcmalloc/optimized/gperftools-r218/src/libc_override_glibc.h:100: first defined here
Getting above mentioned error while doing code coverage for project code. Without code coverage its compiling, but not with code coverage. Code coverage library used is -lgcov.

Related

Is there a way to make Dafny generate C# code without also compiling the code to a .dll or .exe?

The following options seems relevant but the result is no .dll/.exe and no .cs:
/compile:0 /compileTarget:cs
There doesn't seem to be any other command line options to control this.
I found the answer:
/compile:0 /compileTarget:cs /spillTargetCode:2

Some exported symbols disappear after creating a dynamic framework with the ios_framework rule

I am facing quite a strange situation trying to build a mixed-language dynamic iOS framework with Bazel.
The source code of the framework consists of *.c, *.cpp, *.m, *.mm, *.h, *.hpp files.
My first naive attempt was to declare a single objc_library rule referencing all the sources. That failed with an error message reading something about conflicting rules. Then I declared four distinct objc_library rules for *.m, *.mm, *.c, and *.cpp files respectively, and then referenced all these four rules as dependencies for the final ios_framework rule.
At this point, everything compiled and linked just fine (barring several compiler warnings which were expected). However, now the black magic begins:
The static library resulting from compiling ObjectiveC++ sources does contain all the necessary symbols (verified with the "nm" tool)
The .apple_binary_lipobin file resulting from the linking phase does not contain symbols from ObjectiveC++ sources
I believe I carefully went through the command lines used for compiling and linking, both for Bazel and xcodebuild.
The only anomalies I was able to spot:
xcodebuild passes a -single_module argument when linking, while Bazel cross tool does not.
Bazel cross tool adds '-stdlib=libc++' '-std=gnu++11' command line arguments when invoking wrapped_clang_pp during linking, while xcodebuild does not pass these arguments. I guess Bazel does this because there're these lines in the default Apple CROSSTOOL:
action_config {
config_name: "objc++-executable"
action_name: "objc++-executable"
tool {
tool_path: "wrapped_clang_pp"
execution_requirement: "requires-darwin"
}
flag_set {
flag_group {
flag: "-stdlib=libc++"
flag: "-std=gnu++11"
}
but I am not sure if these flags are really needed when invoking the linker.
I must admit I've run out of ideas except for trying to patch the CROSSTOOl file to make it behave as close as xcodebuild as possible.
Please help.
Can you try adding alwayslink = 1 to the objc_library target containing the C++ symbols? The linker is deadstripping the C++ symbols as they are not being referenced anywhere in the binary.

Using JavaCV with Kotlin

I'm currently attempting to start a project using JavaCV in Kotlin. I'm using IntelliJ Idea as my IDE. I'm using JavaCV 1.3.2 and OpenCV 3.20.
This is my setup for the module's dependancies for OpenCV:
and for JavaCV:
I have opencv before javacv in the dependancies.
To test that OpenCV is present and valid, I wrote the below to test. As I can loadLibrary and the version number shows correctly I can assume that OpenCV is actually working.
import org.opencv.core.Core
import org.opencv.core.Mat
import org.opencv.core.CvType
import org.opencv.core.Scalar
import org.bytedeco.javacv.OpenCVFrameGrabber
fun main(args : Array<String>) {
println("Test Built Successfully")
System.loadLibrary(Core.NATIVE_LIBRARY_NAME)
println("Running OpenCV Version ${Core.VERSION}")
val grabber = OpenCVFrameGrabber(1)
}
The line where we initialize the grabber rasies the following exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
Caused by: java.lang.UnsatisfiedLinkError: no opencv_imgproc320 in java.library.path
Perhaps I am missing something here, but I have followed the instructions provided by the README.md in the Git repository for JavaCV. I haven't seen anybody else trying to use this library with Kotlin on StackOverflow, though have checked out some posts about the same exception being raised using java.
Handling this error is no different in Kotlin from Java; you need to specify the path to the native libraries for opencv. By default on Windows it will look for the native libraries in whatever is set in your PATH environment variable.
You can also explicitly specify which directory to look for the native libraries by specifying the system property java.library.path (as indicated by the error message).
For example, you can add a run configuration like this:
Where ${PATH_TO_DYNAMIC_LIB} would be where ever the native lib opencv_imgproc320.dll is - I think in your case it would be C:/Users/ms/IdeaProjects/CVTest/opencv/build/java/x64.
I was able to resolve this by leaving my VM options blank and adding all necessary OpenCV libraries as native library paths in my JavaCV library configuration.
on MacOS, you don't need to install a native library. On OpenCV3.41, as fetched from
<!-- https://mvnrepository.com/artifact/org.openpnp/opencv -->
<dependency>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>3.4.2-1</version>
</dependency>
I looked in the library (jar tf ~/.m2/repository/org/openpnp/opencv/3.4.2-1/opencv-3.4.2.-1.jar) and found dlls and whatnot in it:
jar tf *1.jar | grep nu
...
nu/pattern/opencv/osx/
nu/pattern/opencv/osx/x86_64/
nu/pattern/opencv/osx/x86_64/README.md
nu/pattern/opencv/osx/x86_64/cmake.log
nu/pattern/opencv/osx/x86_64/libopencv_java342.dylib
...
This led me to this StackOverflow question on nu.pattern which show how to use the nu.pattern in code.
static {
nu.pattern.OpenCV.loadShared();
System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
}
This prologue code enabled sample apps which used to fail as above to run.

gcov file checksums do not match when processing gcda

After using XCode 5.1, I got an error like this:
gcov: Unknown command line argument '-v'. Try: '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/gcov -help'
Then I find an answer from this page: XCode 5.1 Unit Test Coverage Analysis Fails On Files Using Blocks
However, I got another error like this:
Processing *****.gcda
File checksums do not match: 1280071245 != 5 in ().
Invalid .gcno File!
geninfo: ERROR: GCOV failed for ****.gcda!
For me the cause was that the *.gcno files were stale and did not match the *.gcda files. In fact most of them had gone missing.
Fixed this by doing the following:
Ensured that both: 'instrument program flow' and 'generated test coverage' were set in both the App's target and the test target.
I then added the following to the AppDelegate.
- (void)applicationWillTerminate:(UIApplication *)application
{
extern void __gcov_flush(void);
__gcov_flush(); //ensure all coverage data is flushed before shutdown
}
. . this is for application hosted iOS tests. Depending on your requirements you could make this a little less 'invasive' (eg, mix in the coverage flushing so that its only in your test target), but this should be a good starting point to get it working first.

Get warnings when programmatically parsing Dart file with analyzer_experimental

I am using analyzer_experimental to parse a Dart file into a CompilationUnit:
import 'package:analyzer_experimental/analyzer.dart';
var unit;
try {
unit = parseDartFile(path);
} on AnalyzerErrorGroup catch(e){
print(e);
}
The above code will catch any parsing errors encountered.
I am also interested in seeing any warnings associated with the file (e.g. 'Undefined name "foo"'). I know that the experimental_analyzer library has the capability to generate these warnings when running from the command line but it does not seem to be possible to get the warnings programmatically, without directly referencing classes in the src folder (which seems like a bad idea).
Is there any way to achieve this?
It's likely this package was very incomplete at the time.
There's now an analyzer package on pub and also a (work-in-progress) STDIN/STDOUT Analyzer Service aimed to help making tooling support easier for IDE extension authors.

Resources