lcov struggles with folder structure under Windows - gcov

I've got problmes get lcov running smooth in a Windows 7 environmet.
I think there are problems with the folder structure of my project.
I have the following structure
D:\project\Filter_lib\Filter.c
D:\project\Filter_lib\Filter.h
D:\project\foo_lib\foo.c
D:\project\foo_lib\foo.h
D:\project\foo_lib\Test\foo_test.c
D:\project\foo_lib\Test\foo_test.h
Contents of the files:
Filter.h
uint32_t filter_1(void);
foo.h
void foo_init(void)
foo.c
#include foo.h
#include Filter.h
void foo_init(void)
{
...
}
static void foo_hadler(void)
{
...
}
foo_test.c
#include foo.c // Only known way to test static functions
static void test_foo_init(void)
{
... test cases;
}
I've compiled the whole thing with all the needed gcc options to produce a gcov output (gcna and gcno files)
When I try to run lcov I've got the following message:
geninfo.perl: WARNING: cannot find an entry for ^#^#Filer_lib#Filter.c.gcov in .gcno file, skipping file!"
I agree with geninfo that this file (^#^#Filer_lib#Filter.c.gcov) cannot be found in the .gcno file. In the .gcno file the correct include (..\Filter_lib\Filter.c) is mentioned.
I debuged the thing a bit and the file ^#^#Filer_lib#Filter.c.gcov is created with the correct content but I think the filename is later not recognized.
I already read the following thread: https://sourceforge.net/p/ltp/bugs/153/
But this workaround doesn't cover my cover.
Additional infos:
Compiler: MinGW32 installation in an actual version
Language: C
lcov: Version ported for Windows found on Github
Can anyone help me with this problem?
Thanks in advance.

Related

Installing opencv + fatal error: 'opencv2/core.hpp' file not found

I have installed open cv using the official installation process given at:
https://docs.opencv.org/4.5.2/d0/db2/tutorial_macos_install.html
I am doing this on mac and it took ~3 hours for this process. After installation, the installed directory looks like this:
apple#Apples-MacBook-Air.local:~/Learning/openCV/cpp$ pwd
/Users/apple/Learning/openCV/cpp
apple#Apples-MacBook-Air.local:~/Learning/openCV/cpp$ ls
3rdparty CTestTestfile.cmake bin data
opencv_data_config.hpp setup_vars.sh
CMakeCache.txt Makefile cmake_install.cmake doc
opencv_lapack.h test-reports
CMakeDownloadLog.txt OpenCVConfig-version.cmake cmake_uninstall.cmake
include opencv_python_config.cmake tmp
CMakeFiles OpenCVConfig.cmake configured lib
opencv_python_tests.cfg unix-install
CMakeVars.txt OpenCVModules.cmake custom_hal.hpp modules
opencv_tests_config.hpp version_string.tmp
CPackConfig.cmake apps cv_cpu_config.h opencv
python_loader
CPackSourceConfig.cmake basicOp.cpp cvconfig.h opencv2
samples
Now, I am writing a very simple program to test the installation and it looks like that I need to do more things than what I have done so far.
My simple program:
#include<iostream>
#include<opencv2/core.hpp>
int main() {
std::string imagePath = samples.findFile("starry_night.jpg");
cv::Mat imageMatrix = cv::imread(imagePath);
if(imageMatrix.empty()) {
std::cout << "Matrix is empty" << std::endl;
}
}
Compiling this gives error as:
apple#Apples-MacBook-Air.local:~/Learning/openCV/programs$ g++ imageRead.cpp
imageRead.cpp:2:9: fatal error: 'opencv2/core.hpp' file not found
#include<opencv2/core.hpp>
No problem, I can probably understand that due to non-linkage of the open cv libraries.
So, I compiled with:
apple#Apples-MacBook-Air.local:~/Learning/openCV/programs$ g++ imageRead.cpp -I/Users/apple/Learning/openCV/cpp/include -L/Users/apple/Learning/openCV/cpp/lib/
imageRead.cpp:2:9: fatal error: 'opencv2/core.hpp' file not found
#include<opencv2/core.hpp>
And it still give me the same error. Basically, I passed the paths for gcc to consider for linking.
Any suggestions? I can help providing more details on it, if needed.
Did you try #include<opencv2/opencv.hpp> instead of #include<opencv2/core.hpp>?

How to integrate LuaJIT with LuaRocks on Windows?

I downloaded the source of LuaJIT and compiled it with msvc120.dll (VS 2013 x64). When I run it from the command line I have no problems executing some basic lua. Now the LuaJIT installation guide mentions moving luajit.exe and lua51.dll into their own folder. From there it says to create a lua folder and under that a jit folder with the contents of src/jit moved underneath the newly created jit folder.
From my understanding my folder should look like and contain:
luajit.exe
lua51.dll
/lua
/jit
bc.lua
[rest of jit files]
vmdef.lua
Is this correct or am I missing files?
Now after I built my luajit I tried to wire it up into my luarocks to act as my interpreter using
install.bat /LUA C:\LuaJIT\2.0.3\[folder with above content]
However this cannot find the header files. I then copied over what are the header files into the folder above and that wires it up, but I can never actually get anything to compile when pointed over to LuaJIT. Edit: The error I get is the following,
C:\LuaJIT\2.0.3\bin\lua51.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2D0
Error: Failed installing dependency: https://rocks.moonscript.org/luafilesystem-1.6.2-2.src.rock - Build error: Failed compiling module lfs.dll
Is the correct way to handle this to simply point to my lua binaries and from there leverage LuaJIT to run my files or am I doing something wrong with wiring up LuaJIT and luarocks? The former seems to work for the most part, since I only ran into one library compilation issue, lua-cjson.
I've run on exactly the same problem, but they've found a solution right here:
https://github.com/keplerproject/luafilesystem/issues/22
I knew that for "linking DLLs statically" there is a so-called "export" .lib file, which is passed to the linker (and not the DLL itself).
So, for example, when compiling, LuaRocks was doing this:
cl /nologo /MD /O2 -c -Fosrc/mime.obj -ID:/LuaJIT-2.0.4/include/ src/mime.c -DLUA_COMPAT_APIINTCASTS -DLUASOCKET_DEBUG -DNDEBUG -DLUASOCKET_API=__declspec(dllexport) -DMIME_API=__declspec(dllexport) mime.c
link -dll -def:core.def -out:mime/core.dll D:/LuaJIT-2.0.4/bin/lua51.dll src/mime.obj
My LuaJIT was compiled from source in D:\LuaJIT-2.0.4\src, but I made two folders myself: D:\LuaJIT-2.0.4\include with all *.h files copied from src and D:\LuaJIT-2.0.4\bin with luajit.exe, lua51.dll, and then later lua51.exp and lua51.lib. Still same error, but this was the right track.
Fix
Now, check where your LuaRocks configs are:
luarocks.bat help
Scroll down to a section like:
CONFIGURATION
Lua version: 5.1
Configuration files:
System: D:/luarocks/config-5.1.lua (ok)
User : (... snip ...)
Edit the System configuration file, specifically see the part:
variables = {
MSVCRT = 'VCRUNTIME140',
LUALIB = 'lua51.dll'
}
Here! LUALIB should be the .lib file. If your export lib is alongside the DLL, you just need to change to:
variables = {
MSVCRT = 'VCRUNTIME140',
LUALIB = 'lua51.lib' -- here!
}
Verification
And now:
luarocks.bat install luasocket
(...)
link -dll -def:core.def -out:socket/core.dll D:/LuaJIT-2.0.4/bin/lua51.lib src/luasocket.obj (...)
(...)
luasocket 3.0rc1-2 is now built and installed in D:\luarocks\systree (license: MIT)
Note the first argument passed to the linker.

./a.out: error while loading shared libraries: libocilib.so.3: cannot open shared object file: No such file or directory

Below is my simple test code.
I have compile it using
$gcc test.c -DOCI_IMPORT_LINKAGE -DOCI_CHARSET_ANSI -locilib
It compile successfully but when i run it it show error-
./a.out: error while loading shared libraries: libocilib.so.3: cannot open shared object file: No such file or directory
I have added below path to my bashrc file -
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib
export ORACLE_HOME=/usr/lib/oracle/11.2/client
export TNS_ADMIN=/usr/lib/oracle/11.2/client/network/admin
#include "ocilib.h"
int main(void)
{
OCI_Connection *cn;
if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT))
return EXIT_FAILURE;
cn = OCI_ConnectionCreate("sam", "SYSTEM", "oracle", OCI_SESSION_DEFAULT);
printf("Server major version : %i\n", OCI_GetServerMajorVersion(cn));
printf("Server minor version : %i\n", OCI_GetServerMinorVersion(cn));
printf("Server revision version : %i\n\n", OCI_GetServerRevisionVersion(cn));
printf("Connection version : %i\n\n", OCI_GetVersionConnection(cn));
OCI_Cleanup();
return EXIT_SUCCESS;
}
i don't know what's the reason. please help. I know little bit about linux.
The OCILIB shared library folder is not in your LD_LIBRARY_PATH variable....
Can also work by typing when compiling: "-static":
gcc -static test.c -DOCI_IMPORT_LINKAGE -DOCI_CHARSET_ANSI -locilib
and run the program normally:
./a.out

How to write Hello World for OpenWRT and/or dd-wrt

I'm working on running a Hello World program on the Linksys WRT54G-V4 running either dd-wrt or OpenWRT.
Right now this router is running dd-wrt for reasons I'll explain below. I'd like to switch this router to OpenWRT, because I've not been able to build dd-wrt or its toolchain. I 'assume' that the OpenWRT toolchain should produce executable binaries that will run on dd-wrt also.
OpenWRT was pretty straightforward to build, since it has a nice menu driven make system. Using this handy tool I built a toolchain that will cross compile from my x86 Ubuntu box to a MIPS target.
Following the instructions I've been able to build OpenWRT and produce images for brcm47xx and brcm63xx.
For example, here is a successful compile of my little Hello World program:
jim#ubuntu:~/Desktop/tests$ cat helloC.c
#include <stdio.h>
int main (int argc, char **argv)
{
printf("Hello World\n");
return 0;
}
jim#ubuntu:~/Desktop/tests$
jim#ubuntu:~/Desktop/tests$ mipsel-openwrt-linux-gcc -o HelloWorld helloC.c
jim#ubuntu:~/Desktop/tests$
jim#ubuntu:~/Desktop/tests$ file HelloWorld
HelloWorld: ELF 32-bit LSB executable, MIPS, MIPS32 version 1, dynamically linked (uses shared libs), with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x3040000, not stripped
jim#ubuntu:~/Desktop/tests$
Sadly, when I try to run HelloWorld on my WRT54G-V4 running dd-wrt I get a seg fault.
Looking at Wikipedia, I see that this router uses the Broadcom BCM5352.
When I run make menuconfig in by OpenWRT/trunk directory I don't see an option for the BCM5352, which is why I'm reluctant to flash my router with one of the images I've created in the brcm47xx or brcm63xx directories. I don't want to guess wrong and brick the router.
Question 1 - Which Broadcom configuration should I select using make menuconfig to target my WRT54G-V4 with its BCM5352 chipset?
Question 2 - Should my 'HelloWorld' executable file I generated above run directly from the command line on the 54G, or must I make it a package per http://www.gargoyle-router.com/wiki/doku.php?id=openwrt_coding ?
TIA
You can follow the official howto (from: http://www.dd-wrt.com/forum/viewtopic.php?p=21499&sid=de90601a8d51747d1c8ccec29284127d)
1. The helloworld.c source
Code:
#include <stdio.h>
int main ( void ) {
printf( "Hello world!\n" );
}
2. Get and unpack the toolchain in your homedir
Code:
cd ~
wget ftp://ftp.dd-wrt.com/sourcecode/toolchains.x86.debian.sp1.tar.bz2
tar -jxf toolchains.x86.debian.sp1.tar.bz2
3. Add the path to your cross-compiler executable to your path environment variable and compile helloworld.c
Code:
PATH=~/toolchains/4.1.0-uclibc-0.9.28/bin:$PATH mipsel-linux-uclibc-gcc helloworld.c -o helloworld
4. Check if its correctly compiled with the cross-compiler
Code:
file helloworld
helloworld: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
5. Finally, transfer the helloworld binary file to your router, set the executable bit and run it.
Tested with Ubuntu 6.06.1 LTS.

Error linking to OpenCV after restructure of code

I've just reorganised my code (which worked before) and am now getting an error message when I run my executable: The program can't start because opencv_core230d.dll is missing from your computer. The error is accurate, I only have .lib library files for OpenCV, but it worked before and I don't think this should be a problem, should it?
An extract from the cmake file is:
FIND_PACKAGE( OpenCV REQUIRED )
# Define LIBRARY and SRC_FILES to create my library
add_library(${LIBRARY} ${SRC_FILES})
target_link_libraries(${LIBRARY} ${OpenCV_LIBS} )
# Define appName and appFile to create application,
# and link to my library and OpenCV
add_executable(${appName} ${appFile})
target_link_libraries(${appName} ${LIBRARY} ${OpenCV_LIBS})
Am I doing anything obviously wrong, or what else might cause this error?
EDIT: I've now reduced this problem to a minimal example. Inside one directory test I have two files: testApp.cpp and CMakeLists.txt as follows:
testApp.cpp
#include <opencv2/opencv.hpp>
int main(int argc, char* argv[])
{
cv::namedWindow("Test");
cv::waitKey(0);
cv::destroyAllWindows();
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(test)
FIND_PACKAGE( OpenCV REQUIRED )
add_executable(appName testApp.cpp)
target_link_libraries(appName ${OpenCV_LIBS})
message(STATUS "Linking testapp to: ${OpenCV_LIBS}")
With the error as before: opencv_highgui230d.dll is missing.
The problem is that the environment variable PATH does not point to the location where OpenCV's DLLs reside. Search inside OpenCV directories and if you can't find it you'll need to reinstall OpenCV.
Seems this is a common problem which simply needed some more research. To fix, I just added the OpenCV/bin directory to the PATH environmental variable. Still not sure why it was working previously though...

Resources