Hi, i m trying to use qt code in c# project as a dll. i m using qt 4.8.1 in windows, with mingw. and qt creator ide. also i m using opencv 2.3.1 and boost 1.48 libraries. the project is running well as application, but when i use it as dll, it gives me runtime exception.
in my .cpp file, i m spesifying the function that i want to call from C# like this:
extern "C" __declspec(dllexport)bool myFunction();
extern "C" __declspec(dllexport)bool myFunction();
To copy to clipboard, switch view to plain text mode
to create dll and using qt codes as dll, i m editing .pro file like this:
TEMPLATE = lib
TEMPLATE = lib
To copy to clipboard, switch view to plain text mode
There is no problem while creating "myapp.dll". after dll is generated, i use this dll in c#, like this:
[DllImport("myapp.dll", EntryPoint = "myFunction")]
[return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool myFunction();
[DllImport("myapp.dll", EntryPoint = "myFunction")]
[return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool myFunction();
To copy to clipboard, switch view to plain text mode
There is no linker error or something, function in dll does good job until this line;
cv::resize(frame, resized, resized.size(), 0, 0); //throws AccessViolationException.
cv::resize(frame, resized, resized.size(), 0, 0); //throws AccessViolationException.
To copy to clipboard, switch view to plain text mode
if i set the "TEMPLATE = app", whole code works perfectly as an application, but if i edit like "TEMPLATE = lib", only opencv resize() function gives me runtime "AccessViolationException".
before this line, some opencv functions are used, but none of them throw any exception, for example,
cv::Mat frame = cv::imread(imagePath, CV_LOAD_IMAGE_GRAYSCALE); //works well
cv::Mat frame = cv::imread(imagePath, CV_LOAD_IMAGE_GRAYSCALE); //works well
To copy to clipboard, switch view to plain text mode
. is there any idea about what i m missing?
my .pro files containing opencv libraries are given below.
INCLUDEPATH += C:\\OpenCV-2.3.1\\install\\include
LIBS += -LC:\\OpenCV-2.3.1\\install\\lib \
-lopencv_core231.dll \
-lopencv_highgui231.dll \
-lopencv_imgproc231.dll \
-lopencv_features2d231.dll \
-lopencv_calib3d231.dll \
-lopencv_video231.dll \
-lopencv_objdetect231.dll
INCLUDEPATH += C:\\OpenCV-2.3.1\\install\\include
LIBS += -LC:\\OpenCV-2.3.1\\install\\lib \
-lopencv_core231.dll \
-lopencv_highgui231.dll \
-lopencv_imgproc231.dll \
-lopencv_features2d231.dll \
-lopencv_calib3d231.dll \
-lopencv_video231.dll \
-lopencv_objdetect231.dll
To copy to clipboard, switch view to plain text mode
sorry for long post.
Bookmarks