Create CMake file from Visual Studio Project - visual-studio

I have finished a project developed in Visual Studio 2013 (Windows) using OpenCV. Now, my manager told me he needs the code files and the CMAKE file.
I'm reading this documents:
https://cognitivewaves.wordpress.com/cmake-and-visual-studio/
http://www.cmake.org/cmake-tutorial/
but I don't understand properly and I don't know if they are what I need...
I can explain a little bit more my project:
My project has:
main.cpp
Some .cpp created by myshelf.
Some .h created by myshelf.
I use OpenCV libraries (lib, dll, ...)
I use Vimba libraries (lib, dll, ...).
I have never worked with CMAKE files... Could anyone lead me about how create this file/s?? I'm really missed...
THANKS in advance!!!
Any help is welcome!

I have achieve create the makeFile. It's working properly in Windows. I execute cmake and from the code files it create the visual studio project properly and it works fine.
BUT when I try to execute the make command in LINUX I get errors :S:
*In function ..... error: 'infinity' des not name a type const auto....
*.... error: 'infinity' was not declared in this scope
*.... error: 'infinity' was not declared in this scope
*.... error: 'infinity' was not declared in this scope
The line where is the problem is this one:
const auto infinity = std::numeric_limits<int>::infinity();
It's a line from this project: https://github.com/soimy/munkres-opencv/tree/master/src
I think the problem is defining a infinity limit... Could anyone lead me to solve this problem?
THANKS!!!

Related

How do I link OpenSceneGraph libraries and includes to Visual Studio properly?

I am trying to compile and build the first basic example from the OSG 3.0 Beginner's Guide (Rui Wang, Xuelei Qian) run on Windows 10 (Build 18363) with Visual Studio Community 19 (16.7.3).
The code looks like this:
#include <osgDBd/ReadFile>
#include <osgViewerd/Viewer> //the "d" is supposed to be there when in Debug solution configuration
int main(int argc, char** argv)
{
osgViewer::Viewer viewer;
viewer.setSceneData(osgDB::readNodeFile("cessna.osg"));
return viewer.run();
}
But the error messages are:
Error (active) E1696 cannot open source file "osgDBd/ReadFile"
Error (active) E1696 cannot open source file "osgViewerd/Viewer"
Error C1083 Cannot open include file: 'osgDBd/ReadFile': No such file or directory
So I rechecked my solution properties, which I had set up following OSG's online documentation "compiling with visual studio" (Linker, C++ properties, ...), as well as my environment variables in Windows OS.
The recommended cmd commands, should something be out of order, didn't help either.
(I deemed it less cluttered leaving out all those screenshots, but I can of course upload them if wished)
I also compared my settings to this answer: How to add additional libraries to Visual Studio project? , which I thought same.
I should add, that I built OSG on a separate drive than Visual Studio or Windows, but I believed setting the environment variables properly should be ok.
Help would be greatly appreciated.
Thank you.
Have you set %OSG_ROOT% ?
I'm not sure what is in the guide, but my typical installation is to set Windows environment variable OSG_ROOT to the main OpenSceneGraph folder in my Program Files (x86), then to add $(OSG_ROOT)\include to my additional include folders and $(OSG_ROOT)\lib to my additional library folders.
Also, it looks like the example you are using has a "d" added to the folder names - should just be osgDB/ReadFile and osgViewer/Viewer for the Release versions - maybe they wanted you to build the debug libraries and add such folders for your includes? I get having a separate lib and bin but I don't know why they would want a separate include folder for Debug vs. Release, so my suggestion would be to remove the d from the include statements, e.g. osgDBd --> osgDB, osgViewerd --> osgViewer, etc.
Unfortunately, the Example applications in the OSG Solution reference the local build folders, not the installed folders, so will not serve as an example of how to reference OSG from its installed location. However, if you are ok building from the local build folder, you could just use the project settings from one of the Examples.

.lib file not working in visula studio 2010 C++

My client provide me a dll file without any lib file for the project, so I create a lib file from this link.
Now after successfully generating a lib file I follow the answer of this link
Now after following these two links, I simply build my code in which I have not define any thing till now.My code build successfully, but when I build my code after calling a function from my lib file I got this:-
error C3861: 'upgStop': identifier not found
where upgStop is the function that I call.
It seems something went wrong while linking the lib file. So, guys please tell the exact solution of this problem.
'Identifier not found' is a compiler error (not linker error) which implies the header file which specifies upgStop() hasn't been #included in the file from which the function is being called.
Do you have a header file which contains the declaration/prototype of ugpStop()?
Once this is resolved, you may have linker errors isntead - as you either need to link against the dll/lib, or load it dynamically using "LoadLibrary()" (and then find functions within the loaded library by their string name.

How do I make Visual Studio 2010 include Windows DDK 7.1.0 files properly?

I'm trying to build a VS 2008 project written by someone else who is currently AWOL in VS2010. I need help with the WinDDK includes, particularly with hidsdi.h.
I've installed the WinDDK and VS2010 on a clean install of Win7. In Properties -> VC++ Directories -> Include Directories, I have added C:\WinDDK\7600.16385.1\inc\api, as well as \ddk and \crt. In Properties -> VC++ Directories -> Library Directories, I have added C:\WinDDK\7600.16385.1\lib\win7\i386.
However, when I attempt to build the project, I get repeated instances of
"error C3861: 'HidD_SetOutputReport': identifier not found" and "error C3861: 'HidD_GetInputReport': identifier not found
I opened up hidsdh.h from the following code block:
extern "C"
{
#include "setupapi.h"
#include "hidsdi.h"
}
And the functions listed in the error reports are present within the header file in question. Clearly, I'm doing something wrong with the include paths. Some assistance would be greatly appreciated.
You must not be defining NTDDI_VERSION or you're not defining it correctly. As you can see in hidsdi.h, the definition of HidD_SetOutputReport is conditional on this:
#if (NTDDI_VERSION >= NTDDI_WINXP)
NTDDI_VERSION determines what versions of Windows you're going to support. The appropriate values can be found here.

Why Visual Studio cannot find 'tr1/unordered_map?

I want to use google-ctemplate in a project. But if I include the basic file, I get the following error (with Visual Studio C++ 2005):
Error 1 fatal error C1083: Cannot open include file: 'tr1/unordered_map': No such file or directory f:\entwicklung\libraries\ctemplate-0.99\src\ctemplate\template_cache.h 39
I can find the unordered_map.hpp in the boost-directory and the boost-directory is set in the include-path in Visual Studio. How can I solve this problem?
I found out what the problem was. I included the wrong directory from google-ctemplate. Instead of src I have to use src/windows.
But that triggers another Problem, this time from the linker.
As is, you can use:
#include <boost/tr1/unordered_map.hpp>
Alternatively, add your $(boost-directory)/boost/tr1/tr1 to the include path and use:
#include <unordered_map>
See this Header Include Style for more details.
Note: I'm assuming $(boost-directory) is set to something like "C:\boost_1_46_0".
Considering that TR1 was not published until the summer of 2005, I wouldn't be surprised that it isn't present in VS 2005. You might try a more up-to-date version of the compiler!

error LNK2001: unresolved external symbol _CLSID_XYS

There is one idl file defined in microsoft sdk which is not available in VS2005. I am using some of the interfaces from that IDL.
Now this works fine on VS 2010 . I want to make it compile on VS2005.
I copied the header file to my project directory. But it is giving me compilation error.
When I looked into header file , the class id is defined in it as
EXTERN_C const CLSID CLSID_Xyz.
Now it is defined as extern so it means it should be declared somewhere else in code.
So my question is just including .h file is sufficient or do I need to also include _i.c file.
Any suggestions
Once you examine that _i.c file you'll see the indeed the CLSID constants are defined there. So yes, you need to incorporate that .c file into you program - either by #including it into a .c or .cpp file or just by adding it to your project so that it compiles separately and then links into the final binary.

Resources