Setting Up OpenCV and .lib files - c++

I have been trying to set up OpenCV for the past few days with no results. I am using Windows 7 and VS C++ 2008 express edition. I have downloaded and installed OpenCV 2.1 and some of the examples work. I downloaded CMake and ran it to generate the VS project files and built all of them but there with several errors, and couldn't get any farther than that.
When I ran CMake I configured it to use the VS 9 compiler, and then it brought up a list of items in red such as BUILD_EXAMPLES, BUILD_LATEX_DOCS, ect. All of them were unchecked except BUILD_NEW_PYTHON_SUPPORT, BUILD_TESTS, ENABLE_OPENMP, and OPENCV_BUILD_3RDPARTY_LIBS. I configured and generate without changing anything and then it generated the VS files such as ALL_BUILD.vcproj. I built the OpenCV VS solution in debug mode and it had 15 failures (maybe this is part of the problem or is it because I don't have python and stuff like that?)
Now there was a lib folder created after building but inside there was just this VC++ Minimum Rebuild Dependency file and Program Debug Database file, both called cvhaartraining. I believe it should have created the .lib files I need instead of this. Also, the bin folder now has a folder called Debug with the same types of files with names like cv200d and cvaux200d.
Believe I need those .lib files to move forward.
I would also greatly appreciate if someone could direct me to a reliable tutorial to set up VS for OpenCV because I have been reading a lot of tutorials and they all say different things such as some say to configure Window's environment variables and other say files are located in folders such as OpenCV/cv which I don't have. I have gotten past the point of clear headed thinking so if anyone could offer some direction or a simple list of the files I need to link then I would be thankful.
Also a side question: why when linking the OpenCV libs do you have to put them in quotes?

If you're just getting started, you should probably grab the prebuilt libraries for OpenCV instead. It's OpenCV-2.1.0-win32-vs2008.exe from this page.
Once you have that, there is really no setup. Just link to the (already built) lib files in any VS project you create, and make sure the OpenCV include directory is in the projects include path.

Related

Setting up Apache Arrow and Parquet Libraries in C++

I'm trying to do something simple: save data in Apache Parquet format in C++. However, I cannot figure out how to properly link the Apache Arrow library to my project in order to use the necessary #include<".h"> headers. I haven't used C++ in decades and I wasn't very good even back then, so this is out of my league.
I've used NuGet (for pthreads library) and have physically linked libraries using the Project Properties of Visual Studio 2019 on Windows 10 (for Npcap library), but following the Apache Arrow instructions (https://arrow.apache.org/docs/developers/cpp/index.html) is currently beyond me.
So far I've installed Git and CMake and I can get CMake to put arrow VS Project files into a ./build folder I've created, but I cannot run any example nor can I link the header files. I've tried adding a VS Project to the 'arrow' solution in the build folder, but I never got that code to compile. In previous attempts I've used CMake through VS as well as used Ninja to try and build the libraries. But for the most part, I am straight-up guessing on pretty much every step of this process.
Some questions that come to mind are: do I even want to specify the "Visual Studio 16 2019" generator to CMake or should I do something different? How do I use the files that were built? Do I need to modify the CMakeLists.txt files included in the arrow download? Do I need to write a script for the build or is it preferable to run from the command line?
Regarding the Optional Components of the build; I'm pretty sure I should have -DARROW_PARQUET=ON but what about -DARROW_PLASMA=ON? It's related to Shared Memory Object Store and in order to save as a parquet file I'll need to load my data into an arrow Table in the memory, so is this applicable? What about the other 50 or so options?
I apologize in advance for my naiveté on this subject and appreciate any help or advice. Thank you.

Llinking ITK (Insight Toolkit) to C++ VS2008 solution without using CMake?

Question
Is there an easy, straight forward way of including the ITK libraries into my project (VS2008 solution) without using CMake?
Background
I have just started looking into ITK this week. So far I successfully compiled ITK & VTK and got the WikiExamples to compile (and run) as well. My next goal is to include any ITK functionality into my own project. I have no experiences with CMake except the use of it during the documented installation process.
My own project codebase is in itself a rather complicated, SDK environment in rather large, complex VS2008 solution to which I only want to add a bit of ITK functionality. As I have built ITK already, can I simply set includes to the .h files and add the lib directories to the linker?
Is there a good way to do this, as the .h files are spread over the whole ITK code tree?
I've realized that this question is similar, but the given answer was too cryptic for me, sorry.
Edit: After a 2nd and 3rd read, it actually wasn't. It led to my answer below.
When configuring ITK with CMake (or cmake-gui) one can set the variable CMAKE_INSTALL_PREFIX to a destination for all output. The default value is C:/Programm Files (x84)/itk
After Configure and Generate have been performed successfully, the solution file (ITK.sln) has been created in the given "Where to build the binaries" directory and can be opened in Visual Studi0 2008. The solution has the default project ALL_BUILD which builds the solution, but it also has a INSTALL project which is skipped by default.
Building this solution (after ALL_BUILD) copies all required lib, .h, .dll etc. files into the path specified before.
This folder structure is the place to link my own project up to.
Linking in your own project
In your own project of VS Studio (I'm on VS 2008) you have to modify your project properties to include the include files:
And you have to modify your project properties to include the library files for linking:

Install OpenCV 2.4.7 in Windows 7 for any editor

I have problem with installing OpenCV under Windows 7 x64. Following this. Downloaded executable and ran it. But I do not see any bin folder, instead there are 2 folders: build and source. What to do next I do not know, what to include to system path and how?
Note:
I am not using visual c++, instead I use devcpp editor.
The OpenCV windows installer comes as a self-extraction program. It essentially packs everything including the source files, docs, and most importantly, the pre-compiled files.
The pre-compiled files are located in build, and sources files are located in source. If you are intented to use opencv libraries solely, all you need to do is to
add build/include/ into your IDE additional include list.
selectively add build/lib/.. into the additional link list according to your vs version.
add build/bin/ to your system PATH, so your program can find them.

Opencv - Can't find header files

I'm trying to start development with opencv. The problem is, until now I coul barely setup the opencv cos I cant find its header files.
I made some research regarding to this subject but none of them were realy helpful, below some of the links:
Where are the opencv2 include files?
http://answers.opencv.org/question/14712/opencvhpp-not-in-opencv2/
I made the built the files using CMAKE GUI - Built the code with MVS 11 x64 both debug and release. The compilation suceeded and I cant found libs and dlls, but no headers at all anywhere.
Checkout the pics:
Opencv2 folder
Local folder
So, now I ask, What am I missing here?
Thanks for the help
EDIT ONE:
Is that what you meant?
EDIT TWO:
I found some headers inside the source of opencv, and each of them is inside an specific folder, like core, highgui and so on - that is it? or something still wrong? cos I thought I should take the headers on the build, no on the source..
append "opencv/build/include" to your include path.
if you built the opencv libraries yourself using cmake, make sure you run the INSTALL project, and add the folder, where it installed to.
When you run make install then the include files that you need are copied to a single directory determined by the makefiles and probably displayed as a part of the output.
I know what's going on. After built the entire solution, under the "opencv" solution strcutre, there is a folder called "CMakeTargets", expand this folder, you can see "INSTALL" project, and right-click this project, then select "build" option, then after installation, all libraries and head files will be located at the correct path. Like the following picture shows:
here
Take a look at the settings that were in use when you built OpenCV - the include path must point to where the include files are for your build to have succeeded.

Using a DLL with unmanaged code in Visual Studio 2010?

I'm fairly new to C++ and an trying to figure out to use the TagLib library for a project I am working on. I'm working with unmanaged C++ in Visual Studio 2010 on Windows 7 64bit. I've never used an external library before so I'm very confused on how to go about this.
From this blog entry I got the libtaglib.a and taglib.dll files. I ran across this SO question on how to use TagLib, but it deals with QT Creator, not Visual Studio and I'm not knowledgeable enough about the subject to understand what is being said to translate it into what needs done for Visual Studio.
So, some questions:
Is it even possible to do this with unmanaged code?
What exactly is the function of a .a file?
Most importantly, how do I go about using the taglib.dll in my program??
I've been all over Google looking for a way to do this, but my major problem is that everything I run across is over my head. Please let me know if more info is required. Any help is very much appreciated! Thanks!
I seem to have gotten it working successfully. Here's a rough outline of what I did:
1.) I used CMake to generate the Visual Studio solution.
2.) I attempted to build the tag project in the VS solution, but it failed.
3.) I made the corrections to a few source files as outlined here: http://old.nabble.com/taglib-fails-to-compile-with-MS-VC%2B%2B-2010-td29185593.html
4.) I built the tag project again in release mode. This time it was successful.
5.) I copied the resulting dll, def, and lib files to the same directory as the source files for my project.
6.) I copied the header files from the taglib source to a subdirectory in my project (not sure if this entirely good practice)
7.) In my project settings, I set the subdirectory with the header files as an additional include directory.
8.) I added the dll, exp, and lib files to my project by just going to Add>Existing Item.
9.) I added some code from the taglib examples and built it. Everything worked so I think I got it.
One caveat I ran into, since the DLL was built in release mode, my project had to be run in release mode or it would crash. I'm guessing that if I replaced the DLL with one built in debug mode I could run my program in debug mode, but I have not tried this.
You cannot use libraries specific to GCC (you can tell because they have .a extensions) with Visual Studio. You will have to build the library from source in order to use it with MSVC. Once you have done that it's a simple matter of adding the .lib generated from the build process to your project and things should work out of the box. (Note that it's a .lib you need whether you're compiling for dynamic linking or not -- doesn't matter in msvc land)
EDIT -- after looking at TagLib itself --
In order to compile TagLib you'll need to get the CMake build system, and TagLib itself, and have CMake build you a visual studio solution. Using that solution you'll be able to build the .libs and .dlls you need. Note that because TagLib is a KDE library, you'll probably need to also build some QT bits in order for everything work work successfully. However, I don't have specific experience with the library so I'm not going to be all that helpful here.
Yo do not have to recompile the source (to create the .lib file) if you have the .dll file. With dumpbin /exports and lib (both came with Visual Studio) yo can create a lib that you can link with your application. In this link you can see a nice explanation: http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/
But as Billy Said, probably you would need other parts of QT to use this library.