Missing files with code coverage - fortran

I have a project that I compile with the intel toolchain. All the .f90 files are compiled to corresponding .o files in the bin directory. When I use the codecov utility I get an HTML with the list of covered files. However that list is missing a bunch of files which should be eligible for coverage. Some of the modules contained in those files are even used during the runs.
What could be a reason for these files to be missing from the coverage report?
EDIT
Running the binary with a debugger I noticed something which might be a clue.
If I try to set a breakpoint in the files that are not covered gdb throws an error:
No line xxx in file "disturb_coms.f90".
However disturb_coms.f90 is in the bin folder:
manfredo#cave05:build$ ll bin-dbg-A/disturb*
-rw-r--r-- 1 manfredo staff 15K Jun 29 10:41 bin-dbg-A/disturb_coms.f90
-rw-r--r-- 1 manfredo staff 3.9K Jun 29 10:41 bin-dbg-A/disturb_coms.mod
-rw-r--r-- 1 manfredo staff 4.9K Jun 29 10:41 bin-dbg-A/disturb_coms.o
-rw-r--r-- 1 manfredo staff 221K Jun 29 10:43 bin-dbg-A/disturbance.f90
-rw-r--r-- 1 manfredo staff 4.1M Jun 29 10:43 bin-dbg-A/disturbance.o
-rw-r--r-- 1 manfredo staff 3.2M Jun 29 10:43 bin-dbg-A/disturbance_utils.mod
and was compiled with:
ifort -c -FR -CB -O0 -check -g -prof-gen=srcpos -debug full -debug-parameters all -fpe0 -traceback -ftrapuv -fp-stack-check -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage -gen-interfaces -I../../src/include -I/usr/local/hdf5_mio/include disturb_coms.f90
Furthermore a file called disturbance.f90 contains the following lines:
module disturbance_utils
contains
subroutine apply_disturbances(cgrid)
...
use disturb_coms , only : treefall_disturbance_rate ! ! intent(in)
...
cpoly%disturbance_rates(2,2,isi) = treefall_disturbance_rate
...
end subroutine apply_disturbances
end module disturbance_utils
where disturb_coms is used, and the file disturbance is actually covered.
EDIT
By adding a write instruction inside disturb_coms.f90 and trying to compile I get the following error:
disturb_coms.f90(44): error #6274: This statement must not appear in the specification part of a module.
write(*,*) "try"
^
I don't have much experience with Fortran but it looks to me as if that module is a kind of c-equivalent header file. Would there still be a possibility to cover that file as well? Like just checking that the definitions contained there are used elsewhere?

Related

Undefined reference to `libbgp::BgpFsm::tick()'

I started working with c++ a few weeks ago, and I started a new project to start learning more. I'm encountering an issue with an external dependency. I'm trying to use a library called:
libbgp, and I installed it base on their documentation.
Here is my code:
https://gist.github.com/amb1s1/9b2c72294da0ec9416810c8686d3adce
Error:
/usr/bin/ld: /tmp/ccsdO32O.o: in function `ticker(libbgp::BgpFsm&)':
ambgp.cpp:(.text+0xa7): undefined reference to `libbgp::BgpFsm::tick()'
collect2: error: ld returned 1 exit status
I'm not sure if there is anything else that I have to do after installing the lib for the library to be accessible in my source code.
Update
I ran it with the -lbgp flag and when running it, i get the following error:
g++ -lbgp ambgp.cpp -o ambgp
Error:
./ambgp: error while loading shared libraries: libbgp.so.0: cannot open shared object file: No such file or directory
My Lib:
ls -l /usr/local/lib/
-rw-r--r-- 1 root root 10875880 Jan 18 16:56 libbgp.a
-rwxr-xr-x 1 root root 924 Jan 18 16:56 libbgp.la
lrwxrwxrwx 1 root root 15 Jan 18 16:56 libbgp.so -> libbgp.so.0.0.0
lrwxrwxrwx 1 root root 15 Jan 18 16:56 libbgp.so.0 -> libbgp.so.0.0.0
-rwxr-xr-x 1 root root 4291128 Jan 18 16:56 libbgp.so.0.0.0
drwxrwsr-x 3 root staff 4096 Dec 16 19:27 python3.7
echo $LD_LIBRARY_PATH
:/usr/local/lib
Before running the executable, you have to tell it where to find the libgdp.so file, if it is not stored in a standard place such as /usr/lib or /lib. Following should help you:
$ export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib"
$ ./ambgp
If you do not want to export the LD_LIBRARY_PATH each time you start the shell manually, add the line to your /home/<user>/.bashrc file.
Additionally, i think the -lbgp flag should go after the source file in the compiler command (g++ ambgp.cpp -lbgp -o ambgp)
TL;DR :
ld states it cannot find libbgp.so.0, and you wrote in the comments that you found libbgp.so without a trailing .0. So, creating a symlink to the library could help too:
$ sudo ln -s /usr/local/lib/libbgp.so /usr/local/lib/libbgp.so.0
For linking, you need a library file without a trailing .0, but for loading, the library name must have a trailing .0.
The last thing to try is to directly specify the library location to the linker with -Wl,-rpath=/usr/local/lib (as you worked out already !)

"string.h" not found message in building qt app for iOS

I've recently updated Xcode to version 10.0 and after that when I try to build version for iOS I've the following problem.
1:04:17: Running steps for project Diasteca...
11:04:17: Starting: "/Users/belladellifabio/Qt/5.11.1/ios/bin/qmake" /Users/belladellifabio/Desktop/QtProjects/Diasteca/mqtt_test/mqtt_test.pro -spec macx-ios-clang CONFIG+=iphoneos CONFIG+=device CONFIG+=qml_debug
Project MESSAGE: This project is using private headers and will therefore be tied to this specific Qt module build version.
Project MESSAGE: Running this project against other versions of the Qt modules may crash at any arbitrary point.
Project MESSAGE: This is not a bug, but a result of using Qt internals. You have been warned!
11:04:18: The process "/Users/belladellifabio/Qt/5.11.1/ios/bin/qmake" exited normally.
11:04:18: Starting: "/usr/bin/make" qmake_all
make: Nothing to be done for `qmake_all'.
11:04:18: The process "/usr/bin/make" exited normally.
11:04:18: Starting: "/usr/bin/make"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -fPIC -std=gnu++11 -arch arm64 -arch x86_64 -Xarch_arm64 -miphoneos-version-min=12.0 -Xarch_arm64 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk -Xarch_x86_64 -mios-simulator-version-min=12.0 -Xarch_x86_64 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.3.sdk -fobjc-nonfragile-abi -fobjc-legacy-dispatch -fembed-bitcode-marker -Wall -W -DQT_COMPILER_SUPPORTS_SSE2 -DMQTT_TEST_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I../../Diasteca/mqtt_test -I. -I../../../../Qt/5.11.1/ios/mkspecs/common/uikit -I../../../../Qt/5.11.1/ios/include -I../../../../Qt/5.11.1/ios/include/QtNetwork -I../../../../Qt/5.11.1/ios/include/QtCore/5.11.1 -I../../../../Qt/5.11.1/ios/include/QtCore/5.11.1/QtCore -I../../../../Qt/5.11.1/ios/include/QtCore -I. -I../../../../Qt/5.11.1/ios/mkspecs/macx-ios-clang -o qmqttclient.o ../../Diasteca/mqtt_test/qmqttclient.cpp
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk' [-Wmissing-sysroot]
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.3.sdk' [-Wmissing-sysroot]
In file included from ../../Diasteca/mqtt_test/qmqttclient.cpp:30:
In file included from ../../Diasteca/mqtt_test/qmqttclient.h:33:
In file included from ../../Diasteca/mqtt_test/qmqttglobal.h:33:
In file included from ../../../../Qt/5.11.1/ios/include/QtCore/qglobal.h:47:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:202:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:61:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h:61:15: fatal error: 'string.h' file not found
Probably the real problem is not the file not found error, but is connected to the fact that qty tries to build the app using an SDK that is no more installed on the system. Is this a qt problem? How could I specify the version of iOS SDK to use to build the app? Is it possible?
Finally, I've found and delete .qmake.cache and .qmake.stash files. I've restart QtCreator and now it seems to work.
Qt stores SDK information somewhere deep in the build output and the .pro.user file.
Remove the user file (you might want to backup your user file in case you have custom build steps), the complete (shadow) build tree and modify your .pro file so that there is no such line as QMAKE_MAC_SDK = macosx10.13.
Then call qmake and build your project again, the inconsistency should be gone.
This occurs when the iOS SDK that Qt is expecting is different than the iOS SDK that you have installed. For instance Qt 5.13.1 expects iPhoneOS13.1.sdk but my Xcode currently has iPhoneOS13.2.sdk:
$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
$ ls -l
total 0
drwxrwxr-x 7 root wheel 224 Nov 5 2019 iPhoneOS.sdk
lrwxr-xr-x 1 root wheel 12 Jan 15 2020 iPhoneOS13.2.sdk -> iPhoneOS.sdk
$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs
$ ls -l
total 0
drwxrwxr-x 8 root wheel 256 Jul 22 14:14 iPhoneSimulator.sdk
lrwxr-xr-x 1 root wheel 19 Jan 15 2020 iPhoneSimulator13.2.sdk -> iPhoneSimulator.sdk
To remedy this, we can get Qt to use the iPhoneOS13.2.sdk:
$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
$ ls -l
total 0
drwxrwxr-x 7 root wheel 224 Nov 5 2019 iPhoneOS.sdk
lrwxr-xr-x 1 root wheel 12 Jan 15 2020 iPhoneOS13.2.sdk -> iPhoneOS.sdk
$ sudo ln -s iPhoneOS.sdk iPhoneOS13.1.sdk
$ ls -l
total 0
drwxrwxr-x 8 root wheel 256 Jul 22 14:20 iPhoneOS.sdk
lrwxr-xr-x 1 root wheel 12 Jul 22 14:20 iPhoneOS13.1.sdk -> iPhoneOS.sdk
lrwxr-xr-x 1 root wheel 12 Jan 15 2020 iPhoneOS13.2.sdk -> iPhoneOS.sdk
$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs
$ ls -l
total 0
drwxrwxr-x 8 root wheel 256 Jul 22 14:14 iPhoneSimulator.sdk
lrwxr-xr-x 1 root wheel 19 Jan 15 2020 iPhoneSimulator13.2.sdk -> iPhoneSimulator.sdk
$ sudo ln -s iPhoneSimulator.sdk iPhoneSimulator13.1.sdk
$ ls -l
total 0
drwxrwxr-x 8 root wheel 256 Jul 22 14:14 iPhoneSimulator.sdk
lrwxr-xr-x 1 root wheel 19 Jul 22 14:39 iPhoneSimulator13.1.sdk -> iPhoneSimulator.sdk
lrwxr-xr-x 1 root wheel 19 Jan 15 2020 iPhoneSimulator13.2.sdk -> iPhoneSimulator.sdk
I met a similar problem, because my xcode project was created by different XCode SDK, and it's generated by CMake, so I deleted the cache and solved the problem.

C++ compiler cannot find Boost libraries even after installing them

While compiling few test applications, I get the following error:
g++: error: −lboost_system: No such file or directory
g++: error: −lboost_filesystem: No such file or directory
while running the following command:
g++ -I/usr/include/boost/ -L/usr/lib/x86_64-linux-gnu/ aescuda.cpp -o test.o −lboost_system −lboost_filesystem
The libraries are installed and present in location as shown below:
<prompt>$ ll /usr/lib/x86_64-linux-gnu/libboost_system.*
-rw-r--r-- 1 root root 49178 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_system.a
lrwxrwxrwx 1 root root 25 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_system.so -> libboost_system.so.1.54.0
-rw-r--r-- 1 root root 14536 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_system.so.1.54.0
<prompt>$ ll /usr/lib/x86_64-linux-gnu/libboost_filesystem.*
-rw-r--r-- 1 root root 217628 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_filesystem.a
lrwxrwxrwx 1 root root 29 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_filesystem.so -> libboost_filesystem.so.1.54.0
-rw-r--r-- 1 root root 88936 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.54.0
Can anyone suggest where am I going wrong :(
You have a wrong character in front of the l:
−lboost_system
It should be an ASCII hyphen:
-lboost_system
This causes the compiler driver to treat the whole string as an input file name (which obviously does not exist, hence the No such file or directory error), and not as an option to be passed to the linker.
(Perhaps consider switching the terminal font.)

Eclipse CDT Post-Build commands error

I have a C++ project and I´m using Eclipse CDT 3.8.1 as the IDE tool, with a workspace of 5 different projects...
One of my projects is a shared library, and at the end of compilation I want to copy its code to a test/bin directory for testing.
I´ve gone to Project Properties -> C/C++ Build -> Settings -> Build Steps and at "Post-build steps", "Command", I´ve added:
cp *.so ../../../bin
(OBS: ../../../bin is the correct path from the Debug folder - I´ve checked already).
What happens is that I get the following error on post build:
cp *.so ../../../bin
cp: cannot stat ‘*.so’: No such file or directory
I said: ok, this may be a permission problem, so I changed the post commands to:
whoami;ls -al; ls *.so;
And I got on Eclipse console:
whoami
aeidev
ls -al
total 264
drwxrwxr-x 3 aeidev aeidev 4096 Apr 25 15:55 .
drwxrwxr-x 5 aeidev aeidev 4096 Apr 22 16:27 ..
-rwxrwxr-x 1 aeidev aeidev 242556 Apr 25 15:55 libaeirtuaccess.so
-rw-rw-r-- 1 aeidev aeidev 1763 Apr 23 20:47 makefile
-rw-rw-r-- 1 aeidev aeidev 245 Apr 23 20:46 objects.mk
-rw-rw-r-- 1 aeidev aeidev 526 Apr 23 20:47 sources.mk
drwxrwxr-x 2 aeidev aeidev 4096 Apr 25 15:41 src
ls *.so
15:55:11 Build Finished (took 1s.80ms)
And them I changed again to ls *.so and I got:
ls -al *.so
ls: cannot access *.so: No such file or directory
15:57:50 Build Finished (took 715ms)
It´s a very strange behaviour. In the same workspace I have a different shared library and the original cp *.so works fine...
Any ideas of what´s going on here ?
Is it a known Eclipse bug ?
Thanks for helping...
I believe the commands are not executed in a shell by default, so wildcards are not evaluated. Try executing like /bin/sh -c 'cp *.so ../../../bin/'. Also you should use Eclipse's built-in variables to copy to the desired path.

creating and using a dynamic shared library on solaris

I am reading the procedure to create and use a dynamic shared library on solaris sparc server.
below are the file i have :
> ls -lrt
total 8
-rw-rw-r-- 1 nobody nobody 848 Nov 22 14:45 badmemlib.hh
-rw-rw-r-- 1 nobody nobody 1924 Nov 22 14:46 badmemlib.cc
-rw-rw-r-- 1 nobody nobody 330 Nov 22 14:49 my_prog.cc
>
in the above files badmemlib.hh is the header file using which i am creating a shared library with the below command following what is mentioned in this link.
> CC -G -o libbad.so -h libbad.so -Kpic badmemlib.cc
after i run the above command i have these below files:
> ls -lrt
total 26
-rw-rw-r-- 1 nobody nobody 848 Nov 22 14:45 badmemlib.hh
-rw-rw-r-- 1 nobody nobody 1924 Nov 22 14:46 badmemlib.cc
-rw-rw-r-- 1 nobody nobody 330 Nov 22 14:49 my_prog.cc
-rwxrwxr-x 1 nobody nobody 8284 Nov 22 15:11 libbad.so*
>
as you can see libbad.so is built without any errors.
Now my main is in the file my_prog.cc
i am compiling the file my_prog.cc as below which following this:
and there were no errors.the binary a.out is built.
> CC -L. -lbad my_prog.cc
> ls -lrt
total 184
-rw-rw-r-- 1 nobody nobody 848 Nov 22 14:45 badmemlib.hh
-rw-rw-r-- 1 nobody nobody 1924 Nov 22 14:46 badmemlib.cc
-rw-rw-r-- 1 nobody nobody 330 Nov 22 14:49 my_prog.cc
-rwxrwxr-x 1 nobody nobody 8284 Nov 22 15:11 libbad.so*
-rwxrwxr-x 1 nobody nobody 80224 Nov 22 15:14 a.out*
>
Now if i run a.out then the error i am facing is :
> ./a.out
ld.so.1: a.out: fatal: libbad.so: open failed: No such file or directory
Killed
It mentions that library is not found but as you can see above the library is in the same directory!
Could anybody pls help me!
content of my_prog.cc.it actually generates a sigsegv and and the badmemlib files has a signal handler.
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include "badmemlib.hh"
#ifdef SOLARIS /* needed with at least Solaris 8 */
#include <siginfo.h>
#endif
int main(){
char *where=(char *)0x123;
printf( "About to write to %p\n", where);
strcpy(where,"vijay");
return(0);
}
You need to tell your application to find .so file from your current directory:
CC -L. -lbad my_prog.cc -R <your current directory>
http://docs.oracle.com/cd/E18659_01/html/821-1383/bkana.html#bkawi
You can also try setting the LD_LIBRARY_PATH variable.
You should be doing:
export LD_LIBRARY_PATH = $LD_LIBRARY_PATH:<full path where library is present>