OpenCV 2.3 - undefined reference to cvCreateButton - Eclipse - c++

I am trying to use the Qt new functions described here:
http://opencv.willowgarage.com/documentation/cpp/qt_new_functions.html#cv-createbutton
And I also found this topic on SO:
openCV 2.2 createButton LNK 2019 error in Visual Studio 2010
but compiling with QT didn't work.
Anyway, according to my searches it seems to be a linking problem. My doubt is that I already compiled OpenCV (without QT) but I can use the createTrackbar normally.
I tried using the createButton as this:
cv::createButton("buttonCanny", buttonCallBackCanny,NULL,CV_RADIOBOX,true);
But I get this error:
undefined reference to `cv::createButton(std::string const&, void
()(int, void), void*, int, bool)'
I tried the cvCreateButton but I get the same error.
I have this setup
C/C++ Build -> Settings -> Tool Settings -> MingGW C++ Linker -> Libraries (all the .dll from compiled OpenCV)
libopencv_calib3d230
opencv_ffmpeg
libopencv_contrib230
libopencv_core230
libopencv_features2d230
libopencv_flann230
libopencv_gpu230
libopencv_highgui230
libopencv_imgproc230
libopencv_legacy230
libopencv_ml230
libopencv_objdetect230
libopencv_video230
C/C++ Build -> Settings -> Tool Settings -> MingGW C++ Linker -> Search Path ("C:\opencvbin\bin" where the Dll are)
C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler -> Includes
"C:\OpenCV2.3\build\include"
Any suggestions?
Thank you!

Ok, I made some mistakes.
Firstly, I wasn't downloading the source code of QT, only the SDK, without source code.
The necessary libs and executables where there.
Secondly, I had to add some entries in the CMake Gui,
I was ignoring this message:
Could NOT find Qt4 (missing: QT_QMAKE_EXECUTABLE QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE QT_UIC_EXECUTABLE QT_INCLUDE_DIR QT_LIBRARY_DIR QT_QTCORE_LIBRARY)
then, I set
QT_QMAKE_EXECUTABLE = C:\Qt\4.8.0\bin\qmake.exe
QT_MOC_EXECUTABLE = C:\Qt\4.8.0\bin\moc.exe
QT_RCC_EXECUTABLE = C:\Qt\4.8.0\bin\rcc.exe
QT_UIC_EXECUTABLE = C:\Qt\4.8.0\bin\uic.exe
QT_INCLUDE_DIR = C:\Qt\4.8.0\include
and it worked fine.
Trackbar seems to work without Qt, so they probably use their own implementation of a trackbar when there is no Qt available.
Thanks!

Related

OpenCV CUDA Function Missing - namespace "cv:cuda" has no member "resize"

I'm trying to use OpenCV 4.1 with CUDA 10 to resize lots of large tif stacks, but VS2017 doesn't see the function resize in the library. It's happy with a subset of the cv::cuda library, but doesn't see all the functions as listed here: https://docs.opencv.org/4.1.0/d1/d1a/namespacecv_1_1cuda.html
I'm including #include <opencv2/opencv.hpp>, and Intellisense shows me the autocompletes of cuda:: of PtrSz, registerPageLocked, resetDevice, setBufferPoolConfig, but no resize...?
I adapted the old OpenCV 3(?ish; here https://www.opencv-srf.com/p/introduction.html) tutorial online to setup my VS project:
Created a system level environment variable $(OPENCV_DIR) pointing to the OpenCV build folder
In the Project properties I added:
All Configurations:
C/C++ -> General -> Additional Include Directories $(OPENCV_DIR)\include
Linker -> General -> Additional LibraryDirectories $(OPENCV_DIR)\x64\vc15\lib here, and below, I've changed the vc## folder to reflect that I'm using VS2017
Debugging -> Environment PATH=$(OPENCV_DIR)\x64\vc15\bin;%PATH%
In Configuration Manager...
Set Active solution platform: to x64
Debug:
Linker -> Input -> Additional Dependencies opencv_world410d.lib
Release:
Linker -> Input -> Additional Dependencies opencv_world410.lib
If I try to compile using cv::cuda::resize(...) I get the compile error of namespace "cv::cuda" has not member "resize". If instead I try to use one of the functions it sees in that namespace, e.g. std::cout << "CUDA device count: " << cuda::getCudaEnabledDeviceCount(); it outputs CUDA device count: 0 and trying something like std::cout << "CUDA device: " << cuda::getDevice(); gives the following error:
OpenCV(4.1.0) Error: No CUDA support (The library is compiled without CUDA support) in throw_no_cuda, file c:\build\master_winpack-build-win64-vc15\opencv\modules\core\include\opencv2\core\private.cuda.hpp, line 107
I'm confused, firstly, why it only sees a subset of the functions available in that cv::cuda namespace, and secondly, why I don't have CUDA support?
Do I need to compile OpenCV on my machine first?
Make sure you are including the proper header files. In your case cudawarping.hpp should be the right one. Most likely you like to do some matrix arithmetic as well so you need to include cudaarithm.hpp .
#include <opencv2/cudaarithm.hpp>
#include "opencv2/cudawarping.hpp"
Here is the api documentation to resize: Documentation
Hope it helps...

Adding my method to OpenCV

I want to add new method in OpenCV library. I made my_funct.cpp whose code is as simple as:
#include "precomp.hpp"
#include <stdio.h>
void cv::my_funct(){
printf("%s\n","Hello world!");
}
and I added header CV_EXPORTS_W void my_funct(); to files C:\opencv\build\include\opencv2\imgproc\imgproc.hpp and C:\opencv\sources\modules\imgproc\include\opencv2\imgproc\imgproc.hpp. Then I used CMake to build new binaries for whole library, but when I make a new project in which I use my_funct() I get an error:
The procedure entry point _ZN2cv8my_functEv could not be located in
the dynamic link library path_to_this_project\project.exe.
Other opencv functions work just fine. I'm using mingw32 to compile library and the version of OpenCV is 2.4.9. Can you tell me what am I doing wrong?
This looks like an MinGW run-time error. So going by the assumption that you didn't get any compiler or linker errors while building project.exe, your executable most likely doesn't find the matching .dll to your .dll.a import library (which must have included the my_funct() definition).
I would recommend during developments phase - not talking about the install() scripting - to add a post-build step using add_custom_command() and generator expressions to copy the right DLL next to your project.exe:
add_custom_command(
TARGET project
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"<... path to matching DLL ...>"
"$<TARGET_FILE_DIR:project>"
)
Certainly you could also let CMake find the matching DLL, but before I could go into details there I would need to see your project.exe CMake script.
Maybe also good idea - if you are in the process of extending OpenCV code - would be to use ExternalProject_Add() to include OpenCV into your project.
References
MinGW-w64 - for 32 and 64 bit Windows - Wiki: Procedure entry point OpenProcessToken? could not be located in the dynamic link library kernel32.dll
MinGW "The procedure entry point libiconv could not be located ..."
Getting started with OpenCV 2.4 and MinGW on Windows 7

C++ Error RC2104 trying to compile PuTTY-PSCP (for Windows) on Visual Studio 6.0

I was about to use PuTTY Development source code for Windows to create my own client application (found here: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) but as I tried to compile the PSCP project (SCP Client), I got the following error :
C:\work\2015\Putty\windows\version.rc2 (18): error RC2104 : undefined
keyword or key name: BINARY_VERSION
I've been going through the various posts involving this error but didn't find anything working :
error RC2104: undefined keyword or key name: DS_SETFONT :
On this post I noticed that the version of MSVC was brought up so I figured maybe something has to be done to get PuTTY to work on VC 6.0 ?
Also I tried to add #include <windows.h> in both version.rc2 (version.rc2 is used for inclusion in all .rc files) and pscp.rc, none worked.
I'll be quick to answer if you need any information (project properties, source code...)
USING Visual Studio 6.0 with SP6 on Windows 8.1
Probably, wrong version.h is seen.
Correctly, the file version.h in the project folder should be seen.
Please try to modify version.rc2:
#include "version.h"
to
#include "..\\..\\..\\version.h"
At least, resource compiler will end successfully.
If you search through the PuTTY source files, you'll notice that BINARY_VERSION is defined in version.h and used in windows/version.rc2, which #includes version.h.
Since your version.rc2 isn't seeing version.h, try to figure out why: Is version.h still present and does it still contain BINARY_VERSION? Are your include paths correct? Is there another version.h somewhere else in your include path that's getting picked up by mistake?
Which source code are you using ?
I tested latest(0.64) "Release source code for Windows".
direct link is
http://the.earth.li/~sgtatham/putty/latest/putty-src.zip
I had tried to compile using VC++ 6.0 Professional with SP6, on my PC,
running Windows XP SP3.
After extracting putty-src.zip to somewhere with keeping folder
structures, did you correctly opened 'putty.dsw' in "putty-src\windows\MSVC" folder?
You should be find in 7 projects in 'FileView' tab of the workspace
in Visual Studio 6.0.
You can switch active project to 'pscp' with context menu via
right button click on 'pscp' project.
With modified version.rc2, resource compiler finished successful.
But two (sshshare.c, winsftp.c) C source files failed compiling
with 20 errors. in 'pscp' project.
Errors while compiling 'winsftp.c' is caused 'TIME_POSIX_TO_WIN'
and 'TIME_WIN_TO_POSIX' macros.
'ull(unsigned long long)' is a 64-bit integer-suffix, newly defined in C99. Since C99 standard is not support on VC6, then caused errors.
I had temporally modified
11644473600ull ------> ((ULONGLONG)11644473600)
10000000ull ---------> ((ULONGLONG)10000000)
and confirmed errors are cleared. (Sorry, no validation the code is correctly generated)
3 errors while compiling 'sshshare.c' is also caused another macro.
I cannot understand why you got 116 errors.

How do I specify, which version of boost library to link to?

I'm trying to migrate a project written in VS2012 to VS2013.
I successfully compiled boost 1.53.0 (I first tried 1.54.0, but got some compiler errors) and got libraries like
libboost_filesystem-vc120-mt-1_53.lib.
But when trying to build my project, the linker complains:
error LNK1104: cannot open file 'libboost_filesystem-vc110-mt-1_53.lib'
I've been looking for some project settings in my entire solution to find out, why it's trying to load the older library version, but I didn't find anything.
How does the linker know, which library to use?
And how can I fix my problem?
I found the answer to my question and the solution to my problem in TheArtTrooper's answer to this thread:
How do I build boost with new Visual Studio 2013 preview?
The linker does know which library to use, because it is specified in boost/config/auto_link.hpp.
This file is missing a few lines of code to handle the vc120 version:
# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1800)
// vc11:
# define BOOST_LIB_TOOLSET "vc110"
# elif defined(BOOST_MSVC)
// vc12:
# define BOOST_LIB_TOOLSET "vc120"
Now it compiles and links just fine!

C++; eclipse linker error

So working on getting my eclipse IDE going so I can develop my arduino uno in eclipse.
My C++ is weak so this is probably a nube error on my part.
I have a blink program that looks for an arduino library I compiled from the arduino IDE's library.
My code points to the header file and my code find it fine; meaning I can click on:
#include <arduino.h>
and go view the header
this: "C:/programs/arduino-1.0/hardware/arduino/cores/328p_lib/libuno_library.a"
is a valid path... but I get the following error:
>****** Build of configuration Debug for project project1 ****
>make all
>Building target: project1.elf
>Invoking: AVR C++ Linker
>avr-g++ -Wl,-Map,project1.map,--cref -L"C:\programs\arduino->1.0\hardware\arduino\cores\328p_lib" -mmcu=atmega328p -o "project1.elf" ./code/code1.o >-l"C:/programs/arduino-1.0/hardware/arduino/cores/328p_lib/libuno_library.a"
>c:/programs/winavr/bin/../lib/gcc/avr/4.3.3/../../../../avr/bin/ld.exe: cannot find ->lC:/programs/arduino-1.0/hardware/arduino/cores/328p_lib/libuno_library.a
>make: *** [project1.elf] Error 1
>**** Build Finished ******
Well after wasting 2 days or so of fun time I finally found the problem.
http://sourceforge.net/projects/avr-eclipse/forums/forum/664382/topic/4640554
When adding the static library to the linker you have to remove the lib prefix and the .a suffix. not sure what that is about.
Right click on the project>Click on C/C++ BUild> Settings > GCC C++ Linker> Libraries
Click the first icon Add> Add the library name ( without the .a suffix, the suffix will be added automatically)
This will ensure that the library is added to the project.
If the library is part of another project >Go to GCC C Compiler> directories >Add the directory
This will ensure that the library is there for getting the compilation done.