Missing files, DirectX SDK (d3dx9.lib, d3dx9.h) - sdk

I installed the DirectX SDK June 10, but when I include the d3dx9.h, the compiler can't find it.
I checked the SDK directory, and I didn't find it there either.
files missing: d3dx9.lib, d3dx9.h, dxfile.h.

The DirectX SDK installation will add a system environment variable DXSDK_DIR that holds the path to wherever the SDK was installed to. Instead of inserting an absolute path in your Include and Library Directories, I'd recommend using this variable to set the Include and Library path for DX dependencies.
As Include Directory add: $(DXSDK_DIR)Include
As Library Directory add: $(DXSDK_DIR)Lib\x86 or $(DXSDK_DIR)Lib\x64 on a 64-bit architecture
So your VC++ Directories should look something like this:
The $(DXSDK_DIR) resolves to the path where you installed the SDK, normally "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)" and works even if you chose another path, which makes it more available between different people.

The library file (d3dx9.lib) should be in C:\path\to\Microsoft DirectX SDK (June 2010)\Lib\x86\ as well as in C:\path\to\Microsoft DirectX SDK (June 2010)\Lib\x64\
Both include files you mentioned exist in C:\path\to\Microsoft DirectX SDK (June 2010)\Include\
If you're still not able to find them, download and install the SDK from here:
http://www.microsoft.com/en-us/download/details.aspx?id=6812
I downloaded and used this one and I can asure you, that those files are present!!

When I had this problem, I found that I had the d3dx9.h in the
[Program Files(x86) \ Microsoft DirectX SDK (June 2010) \ include] folder.
The compiler needed it to be in
[Program Files(x86) \ Windows Kits \ 8.1 \ include \ shared].
I copied the file to the other location and it worked, but I wonder if that was the smartest fix.

in my case, following code works for me:
//#include <d3dx9.h>
#include <d3d9.h>
//#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "d3d9.lib")

Related

How to install OpenCV with contrib modules in Windows 10 on Visual Studio 2019

I am trying to install OpenCV with contrib modules for Visual Studio 2019 on a Windows 10 machine.
I previously had a working version in Visual Studio 2017, but have been unable to get either 2019 or 2017 working recently.
I have been using CMake to install this, adding the extra modules path before generating. Once I have built the ALL_BUILD and INSTALL files I am not sure of where I am meant to add the libraries and include paths and I have found conflicting results between tutorials and neither seem to work.
My code won't include the libraries and says that it can't open the source file.
Here is my code:
#include <opencv2/core/core.hpp>
The error is:
Cannot open source file "opencv2/core/core.hpp"
I have reviewed the following materials to attempt to solve this but there are no up to date guides to include contrib modules nor any that work
OpenCV install tutorial
Previous question not for visual studio
Previous question for 2017 version
Previous question not for visual studio
Youtube guide that worked for 2017 version
this is a problem of the path to include directory.
You can set directly the path in Project setting- C/C++ - General - Additional Include Directory: (c:/opencv/install/include) "Just example". Follow the picture. This will correct the problem with includes.
You have to include additional library Directories as: c:\xxx\xxx\install\x64\vc16\lib
x64 depends if you compiled opencv for 64 or 32 bits, vc16 is Visual Studio 2019.
The Additional dependencies on the following picture provide opencv_MODULE420.lib, where module is core, video, videoio, etc. If you have a problem here, The message symbol is not resolved will occur.
I recently did a tutorial for this here funvision blog HERE
in case you have a problem with installation by CMAKE. The tutorial includes the installation of GSTREAMER as well.

Why doesn't CLion link my project with OpenCV for Windows?

I'm attempting to use OpenCV for Windows as supplied by opencv.org in a project I'm building with JetBrains' CLion IDE. I've installed the opencv library and configured CLion (set(OpenCV_DIR) to reference the build directory under it, but CMake issues the warning:
Found OpenCV Windows Pack but it has no binaries compatible with your configuration.
You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.
I've tried some of the older distributions from opencv.org with the same results. It appears CMake is locating the OpenCV libraries, but doesn't want to use them. Why, and how do I get the OpenCV libraries to work under CLion?
The short answer is, you will probably need to build OpenCV from source in order to use it with CLion. But given the number and range of partially answered and unanswered questions here* and elsewhere on using JetBrains' CLion IDE with the OpenCV library, I think an overview is needed (my notes are from CLion 2016.3 and OpenCV 3.1, YMMV):
Though not produced by JetBrains, CMake is very central to CLion's operation. Understanding CMake therefore helps greatly in diagnosing CLion build problems. In particular CMake maintains a disk "cache" of settings which you may need to clear to incorporate changes to your environment (Tools->CMake->Reset Cache and Reload Project).
To make use of OpenCV in your build you must specify it in your project's CMakeLists.txt file. You request that CMake locate your OpenCV location and link it to your TARGET. An example of a sequence of commands from CMakeLists.txt for an executable named mushroom follows:
add_executable(mushroom ${SOURCE_FILES})
FIND_PACKAGE(OpenCV REQUIRED)
TARGET_LINK_LIBRARIES(mushroom ${OpenCV_LIBS})
(For more on FIND_PACKAGE, see CMake:How To Find Libraries.)
FIND_PACKAGE for package XXX works either by way of FindXXX.cmake files located at CMake's Modules directory, or by consulting environment variable XXXX_DIR. On my system, no FindOpenCV.cmake file was present, so I relied on the OpenCV_DIR environment variable instead. This must be set, not to the root of your OpenCV installation, but to the build folder beneath it. I used an entry in CMakeLists.txt to set this variable, e.g.:
set(OpenCV_DIR C:/Users/myacct/AppData/Local/opencv-3.0.0/build)
To link with OpenCV, CMake uses either FindOpenCV.cmake or OpenCV_DIR (see previous point above) to locate a file named OpenCVConfig.cmake. This file is generated by and ships with a particular build of OpenCV in order to document what components are present and where they are located.
Problems may occur when variable names used by OpenCVConfig.cmake conflict with those CLion has stored in its environment. In particular, if your OpenCV was built by Microsoft Visual C (MSVC), as is the Windows distribution from opencv.org, it won't work with CLion.
Because CLion's build toolchain (ControlAltS-toolchain) uses either MinGW or Cygwin, OpenCVConfig.cmake will search for OpenCV binaries under a subdirectory named mingw or cygwin and will find none because the binaries were built with MSVC (it will look in a directory like vc11 or vc12 instead). This probably means you will need to build OpenCV from source in order to use it with CLion.
Would reconfiguring OpenCVConfig.cmake to point to the MSVC binaries make this work? you may ask. Unfortunately the answer is still no, because libraries built with one compiler typically cannot be linked with another one.
OpenCVConfig.cmake or FindOpenCV.cmake likely contain diagnostic messages, but when CLion executes CMake for you, message(STATUS) calls are not displayed. To make them display, change them to message(WARNING) or message(FATAL_ERROR). But CLion 2016.3 EAP relieves this problem; see https://stackoverflow.com/a/39398373/5025060.
CLion does not indicate which .cmake script issued which diagnostics; don't assume they all come from the same script.
Hopefully this provides some general guidance on resolving CLion / CMake / OpenCV compatibility problems. Note that this does not cover compiler or linker issues; these will not appear until CMake completes its initial makefile build. Compiler or linker issues occur at a later stage and are controlled by include*(), link*() and other commands in CMakeLists.txt.
*Some related SO questions:
OpenCV Windows setup with CLion
OpenCV CLion (Cmake) linking issue - cmake reports a strange error
use OpenCV with Clion IDE on Windows
Compiling OpenCV on Windows with MinGW
Could not find module FindOpenCV.cmake ( Error in configuration process)
CMake: Of what use is find_package() if you need to specify CMAKE_MODULE_PATH anyway?

How to install OpenCV 3.1 with nonfree module?

I'm trying to write a program that uses SURF algorithm and I know that the nonfree module must be installed separately. I've downloaded and installed the latest version of CMake(3.5.2) and I'm following the instructions from:
https://github.com/itseez/opencv_contrib/ . I'm using the GUI and I run Visual Studio 2015 on a 64 bit Windows 10.
Since I know that for SURF you must include xfeatures2d when it asked me the source of the code I only specified the xfeatures2d folder. When I first pressed the configure button I had some errors(I've attached an image of them). I managed to get rid of one of the errors, the one that said to write a line of code at the top of the file
cmake_minimum_required(VERSION 3.5), but I still have one error:
CMake Error at CMakeLists.txt:4 (ocv_define_module):
Unknown CMake command "ocv_define_module".
I'm also attaching a picture of the CMakeLists.txt. Please help me find the problem.
Also, if you could help my install all modules at once, I would be grateful. Or do I have to set as input every folder in the modules folder?
GUI error and CMakeLists.txt
Try using Visual Studio 12 2013 for compilation, this has worked for me, but not the other (newer) versions of Visual Studio.

cvBlobsLib with mingw

Does anybody know how to build cvBlobsLib using MinGW? On official page http://opencv.willowgarage.com/wiki/cvBlobsLib there is only instruction for VS.
There is also linux version of this lib http://opencv.willowgarage.com/wiki/cvBlobsLib?action=AttachFile&do=view&target=cvblobs8.3_linux.tgz , but its makefile cannot be used in windows as i see.
If you use eclipse then you dont have a lot of work:
Create a new project, using MinGW toolchain.
Go to the project properties, and under C/C++ General >> Paths and Symbols add the openCV library paths.
compile the project and it should be OK.
Use this
http://opencv.willowgarage.com/wiki/cvBlobsLib#Build_intructions
if you have more problems (especially NOTE 3)

How to compile OpenCV 2.3 with ffmpeg support with Visual Studio 2010

It's two days I'm search around the web for a tutorial to compile OpenCV 2.3 with ffmpeg support under windows, but nothing found. I'm using pre-built version of OpenCV in VS2010 but I cannot read from network camera, it's why I need ffmeg support.
The answer your looking for is here and it works for the 32 bit and 64 bit configurations.
I used this build of FFMPEG.
http://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-git-1aeb88b-win64-dev.7z
1) Download OpenCV 2.3
2) Open the root CMakeLists.txt and insert the line set(HAVE_FFMPEG 1)
3) Download http://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-git-1aeb88b-win64-dev.7z (or the 32 bit build if u fancy it)
4) Edit avformat.h found in the ffmpeg include dir with #define INT64_C
5) Edit cap_ffmpeg_impl.hpp from the highgui project with #define snprintf _snprintf
6) in your highgui project properties under C/C++>Additional Include Directories add path of the include directory of FFMPEG you just downloaded
7)On the same property page under Linker>General>Additional Library Dependencies add the path of the lib directory of FFMPEG you just downloaded
8)On the same property page under Linker>Input>Additional dependencies add ALL the names of the libraries of ffmpeg found in lib (avformat.lib, avscale.lib, avcore.lib etc)
9) build the highgui project
10) Add the path of the .dll files that came with FFMPEG to the System Path environment variable.
That's it! 10 easy steps ;)
Build OpenCV with CMake from sources. Choose USE_FFMPEG flag.
Get ffmpeg from http://ffmpeg.zeranoe.com/builds/
In my experiment, FFMPEG is not directly supported in window. The flag WITH_FFMPEG only appears under UNIX(opencv 2.3 CMakeLists.txt). So, if you want to build opencv 2.3 with ffmpeg support, you should edit the CmakeLists.txt or the project opencv_highgui yourself. And then get ffmpeg from WWW. You may also need to edit cap_ffmpeg_impl.hpp.

Resources