Eclipse CWT crashes with grey window - linux

I'm writing an OpenCV program for university and got some troubles with Eclipse.
I am running a 64bit Linux Mint (13) with Eclipse Juno. I installed OpenCV using this guide, except I installed Version 2.4.3.
Since the project my partner on MacOS shared with me didn't work, I created a plain C++ Project. I added the information needed in the build settings as followed:
Cross GCC Compiler -> -I -> "/usr/local/include/opencv" and "/usr/local/include/opencv2"
Cross G++ Linker -> Libraries -> -I -> "cv" and "highui"
-> -L -> "/usr/local/lib"
This is the code I'm using. Right, it does nothing:
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main(int argc, char** argv) {
return 0;
}
So, everytime I'm running this, i get an ugly grey window, like a message window would look like, but nothing in it. This is the same es the actual program with code in it, so it's nothing to do with OpenCV commands.
Sometimes, this window disappears with killing Eclipse, with doens't response then. Sometimes, it even survives that and I have to start a new X session.
This is what it looks like:
The error messages you can see are not related to the crash itself, but shown before.
Sometimes it just says "Binary not found", which those messages come from. It somehow doesnt find the libraries.
This is pkg-config --libs opencv
/usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so
/usr/local/lib/libopencv_core.so /usr/local/lib/libopencv_features2d.so
/usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so
/usr/local/lib/libopencv_highgui.so /usr/local/lib/libopencv_imgproc.so
/usr/local/lib/libopencv_legacy.so /usr/local/lib/libopencv_ml.so
/usr/local/lib/libopencv_nonfree.so /usr/local/lib/libopencv_objdetect.so
/usr/local/lib/libopencv_photo.so /usr/local/lib/libopencv_stitching.so
/usr/local/lib/libopencv_ts.so /usr/local/lib/libopencv_video.so
/usr/local/lib/libopencv_videostab.so
This is pkg-config --cflags opencv
-I/usr/local/include/opencv -I/usr/local/include
It hast to do something with my OpenCV/CWT setup I guess. Since I tried out a lot of variations, does anybody got any idea what I did wrong?

Related

Cross-compiling from WSL and Linux causes missing entry point DeleteCriticalSection

I'm trying to cross-compile from WSL and Linux to Win32 using i686-w64-mingw32-gcc. The program is dependent on some DLL:s that I have downloaded, and are known to work when used for an exe cross-compiled on Cygwin. Compilation and linking works without throwing any errors or warnings, but when I run the resulting executable on Windows (by double-clicking on it in an Explorer window) I get a Windows-error-prompt:
The procedure entry point DeleteCriticalSection could not be located in the DLL...
and then it points to the program (the .exe) itself, not a DLL (message translated from Swedish ;-).
When I do the exact same thing on Cygwin with the same archive for the DLL:s and the same DLL:s the resulting exe works as it should.
The new(ish) Dependencies shows some red lines for COMCTL32 and OLEAUT32, but those are the same for both.
A very simple windows GUI app compiles and runs, so it's not the cross-compile as such that is causing the issue. The DLL:s in combination with WSL/Ubuntu/GNU cross-compilation seems to be the culprit.
Instructions
EDIT: after explicitly following my own instructions and explicitly re-installing the cross-compilation tool-chain the instructions below no longer creates a faulty exe. But the original problem remains.
I'm happy to take any ideas on what to try next.
Here are instructions to repeat what I have. Create an empty directory in WSL and run
$ sudo apt install binutils-mingw-w64-i686 gcc-mingw-w64-i686
$ wget https://github.com/DavidKinder/Windows-Glk/releases/download/1.50/WindowsGlk-150.zip
$ unzip WindowsGlk-150.zip
Then create startup.c with the following content
#include <unistd.h>
#include "glk.h"
#include "WinGlk.h"
int winglk_startup_code(const char* cmdline)
{
return 1;
}
void glk_main(void) {
sleep(10);
}
(Fix the capitalized include of "glk.h" in Glk.c or you'll get an error.)
Compile and link with
$ i686-w64-mingw32-gcc -mwindows -I Include/ Glk.c startup.c Glk.lib
to get an a.exe. The message only shows up in Gui-mode so you need to run it from an explorer window:
explorer.exe .
and double-click on a.exe.
WSL and Linux vs. Cygwin
I've done the same cross-compilation on a "real" Ubuntu 20.04 and getting the same problem. Again, doing the exact same steps in Cygwin produces a runable exe. This points to a cross-compilation problem with some facet of
what the exe and the DLL:s are doing. (There is no code in the exe that does anything with critical sections. Could this be an API mismatch?)
Since the DLL:s are the same it is reasonable to suspect the actual cross-compilation of sources in my program.
Is there anything in the cross-compilation toolchain on Linux that might differ? Which Windows run-times and API-versions are targeted?
I'm happy to take any ideas on what to try next.

copy_to_user undefined in linux kernel version 4.12.8

In my project I am using char driver to communicate between user space and kernel space. I use the function copy_to_user(void user *to, const void *from, unsigned long n) to copy data from kernel space to user space buffer. We can find this function under #include < asm/uaccess.h > header file.
I complied the project using Linux Kernel version 4.4.0-59-generic, Ubuntu OS version 16.04 LTS and its working fine without any error and warning. I get the desired output.
I compiled the same project using Linux kernel version 4.12.8, Ubuntu OS version 16.04.2 LTS and it throws me an warning during compile time WARNING: "copy_to_user" [/home/ldrv1/Desktop/Vijay/code/build/uts.ko] undefined!. When I do insmod of my module I get error as follows insmod: ERROR: could not insert module uts.ko: Unknown symbol in module. I think that #include <asm/uaccess.h> header file is still supported in 4.12.8 kernel version else I would have got fatal error: no such file or directory error while compiling. I tried updating the linux kernel headers using apt-get install linux-headers-$(uname -r) command and I got the following response:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-4.12.8
E: Couldn't find any package by glob 'linux-headers-4.12.8'
E: Couldn't find any package by regex 'linux-headers-4.12.8'
This OS version 16.04.2 LTS has linux-headers-4.10.0-35.
How do I get rid of this warning? Suggestions and support appreciated. If more information is required please feel free to ask.
You should use #include <linux/uaccess.h> for 4.12.8.
Here is the definition.
In 4.4 some drivers use #include <asm/uaccess.h> whilst the others
use #include <linux/uaccess.h>.
#include <linux/uaccess.h> is preferable, I think.
You should do apt-get update and then apt-get install linux-headers-generic.
The function copy_to_user and copy_from_user defined in asm/uaccess.h . I think you have some issue when you define this function. I wrote the character device driver with some example about data transfer between Kernel space and User space. View my github: my code for reference. Please star if you feel it is helpful for you :). it has small bug in example 3. I am figuring them, but example 1 and example 2 work well
The answer given by Bronislav Elizaveti is correct. If instead of #include <asm/uaccess.h> we use #include <linux/uaccess.h>, then we won't get the warning.
If you still want to use only #include <asm/uaccess.h>, then you'll need to use _copy_to_user instead of copy_to_user (with the same arguments). A simple _ will do the job.

Qt Hello World Tutorial doesn't work

I am trying to run a hello world program and the tutorials don't work for me.
I am guessing that it's got something to do with qt4 <-> qt5 and linux <-> windows confusion.
I'm on Ubuntu 14.04, 64 bit. I did a sudo apt-get install build-essential and a sudo apt-get install qt5-default.
This is the code in my main.cpp:
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Linux is wonderful", 0);
app.setMainWidget(label);
label->show();
return app.exec();
}
I run these commands:
qmake -project
qmake test.pro (for some reason it's not "main.pro")
make
Here is the generated .pro file:
######################################################################
# Automatically generated by qmake (3.0) So. Okt. 25 15:51:35 2015
######################################################################
TEMPLATE = app
TARGET = test
INCLUDEPATH += .
# Input
SOURCES += mymain.cpp
And then I get QApplication: No such file or directory. Why?
You are missing the necessary module from .pro file. Apparently qmake -project does not add that by default (makes sense, since not all Qt apps are widget applications). So check for and add this:
QT += widgets
This is because Qt5 has widgets in a separate module (Qt4 had them in gui), and QApplication is part of that, as shown by docs too. The two modules which qmake adds automatically (and you have to remove if you don't want them) are core and gui (documented here), others you have to add to .pro explicitly.
Some notes: You generally run qmake -project only once to create initial .pro file. Then you need to edit it by hand, and don't want it to be overwritten! Then you never edit Makefiles by hand, instead you regenerate them by running qmake after editing the .pro file.

Linux - setting Code::Blocks to compile multithreading C++ code

I have searched through forums here, but nothing helped to the end in my case.
I'm trying to write and compile some C++ multithreading code in Code::Blocks 13.12, for now the only code I have is:
#include <iostream>
#include <thread>
void cpp11()
{
std::cout<<"C++11 MULTITHREADING\n";
}
int main()
{
std::thread t(cpp11);
t.join();
}
Initially I could not compile and run that code (both in Code::Blocks and Terminal) because I was getting an error:
Terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not
permitted.
I found that I'm able to compile and run that code calling g++ in the Terminal like that:
g++ -std=c++11 -pthread main.cpp -o Program
but I cannot set the same in Code::Blocks.
I went to Project -> Build options, in the Compiler settings tab I selected Have g++ follow the C++11 ISO C++ language standard [-std=c++11].
In the Compiler settings -> Other options I typed -pthread.
In Linker settings -> Other linker options I typed -pthread.
It does not work, after I build and run my project in Code::Blocks I get the same error message.
Thank you for any help!
Follow instructions for this question
How do I link to a library with Code::Blocks?
in the last step, when Add library dialog pops up type pthread.
UPDATE
Again go to build options > Compiler settings . click on other options and type -pthread

Can't Access sys/socket.h using Cygwin

I need to compile C/C++ pthread and socket code in windows 8 where I've installed MicGW GCC and G++ 4.7.
When I compile my test code using g++ test.cpp -o test
Code is:
#include<iostream>
#include<sys/socket.h>
#include<sys/types.h>
using namespace std;
int main() {
cout<<"Got Socket";
}
This gives error fatal error: sys/socket.h not found and the
same occur with types.h
The error I found is that cygwin is using MicGW GCC and g++ but I want it to use its own instead of MinGW's so that I can include Linux libraries.
I have not been able to reproduce your problem on my Cygwin.
Are the headers present in /usr/include/sys?
Search the sys folder in [installed directory]/usr/include if the socket.h was not there download one Copy it there manually.
don't afraid of manual works ;-)

Resources