Visual Studio 2019 Freeglut (via nuget) - cannot open "Freeglut.lib" - c++

I've been trying to create a GLUT-compatible Visual Studio 2019 project. Manually installing has caused some extremely complicated issues and breaks the project completely (even after uninstalling it) so I'm just trying to use the Nuget package. The .h files seem to be included correctly after this. However, any use of the line '#include <GL/freeglut.h>' - even in a completely blank project - produces an LNK1104 error:
cannot open file 'freeglut.lib'
Are there additional installation steps I'm missing? The .lib file is present in the folders. Trying to manually link it in project properties changes nothing.

Resolved by using this method and then adding the line
#include <windows.h>

Related

visual studio 2019 - C++ cannot open source file

I am using Microsoft Visual Studio Community 2019 Version 16.8.4 on a Windows 10 machine.
I have established that my include files live in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include" because I can actually see them listed there. However, I get an error with the line #include <cstdio>.
I have tried right click on project name to bring up a context from which I chose 'Properties'. From the "Solution Project1 Property Pages", I selected "Debug Source Files" and then entered the full directory path to the include files.
I still get the error
You need to add the directory where the headers are found to the project properties under either C/C++ -> Additional include directories or VC++ -> Include directories.
And note that you need to make sure that the directory is added for all project configurations/platforms you wish to be able to build. The Debug source files item is only so that files can be found when running the debugger and have nothing to do with the project build stage.
I ran Visual Studio Installer and noted that one of the workloads, 'Desktop development with C++' had not been activated. After activating it and downloading the required or missing binaries, I am now able to create an empty project using an example of the quintessential 'Hello World' program such as #include int main(){printf("Hello, world");return 0;}
#include <cstdio> is part of the C++ Standard Library headers, if you are getting the error E1696: 'cannot open source file, you might have to retarget the solution/project. Do the following:
Right-click the Solution in the Solution Explorer pane;
Retarget solution;
Follow the steps/press OK.
It worked for me when I couldn't find Standard Library headers, hopefully, it works for you as well.

Boost Library cannot get to work in C++, Include directories not working

I recently tried to install boost libraries in C++ 14, and I added it's include paths like:
Solution Explorer > Project Name > Property Pages > VC++ Directories > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost"
I tried to compile after adding this:
#include <boost\variant.hpp>
In Error List window, I can see E1696 - cannot open source file "boost\variant.hpp" and I can't compile like before.
Then I tried with adding a backslash like "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\", still didn't work.
I also read this post and explicitly specified it's directory, but even didn't work.
Again, I read this post and did exactly same what is in given answer (as I already built project several times) , but still no success.
However, if I include a library like:
#include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp"
Now compiler recognizes it, but now I can see more than 100 errors in Error List window, those errors are pointed to header files of boost libraries, not in my project file which has variant.hpp included.
All those errors are E1696 - cannot open source file "boost\<libraryname.hpp>" or E1696 - cannot open source file "boost\<subdirs>\<some other files included in libraryname.hpp>"
So, if I remove the line #include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp" from my project's header file, all errors disappear suddenly and project compiles fine! no any single error now!
I want boost to work anyway, so I can use it in projects, but I can't manually edit all those header files and change <boost\... to original locations.
Please help me to get rid of this issue.
make sure you download and install the correct boost version. Installing it in the visual studio directories is possible, but not advised. I suggest you use one of the packages from here. Assuming you use visual studio 2017 and you are developing for 64bit, this could perhaps be the correct package for you.
make sure you do both: adding the include search path and the library search path to your visual studio.
The include search path should point to the boost-installation root directory (the one that contains the Jamroot file and a boost subdirectory). The library search path should point to the correct library subfolder within the boost installation. This is one of the subfolders that start with lib64-msvc-**.* (or lib32-msvc-* if you're developing for 32bit).
The default install path of the binary boost package above will install it into C:\local\boost_<boost version>. Make sure you use the paths from this installation directory and follow the instructions here.
Example:
Include search path: C:\local\boost_1_64_0
Library search path: C:\local\boost_1_64_0\lib64-msvc-14.1

OpenCV w/ CUDA build fail on Visual Studio 2013 [duplicate]

I'm trying to build OpenCV 2.4.6 on Windows 8 in Visual Studio 2012. Having downloaded the source from https://github.com/Itseez/opencv I generate (leaving the default configuration) using cmake and then load the resulting file ALL_BUILD.vcxproj into Visual Studio 2012. I then try to build it. Several of the modules do indeed build (e.g. core, flann, imgproc, ...) but I am trying to build highgui so that I can use the PDB file for debugging my code (which fails to open a video file). The build errors start with this and many similar errors:
error C2039: 'max' : is not a member of 'std' C:\OpenCV2.4.6\3rdparty\openexr\Imath\ImathMatrixAlgo.cpp 1094 1 IlmImf
One fix for errors like this (e.g. in this answer) is to add #include <algorithm> to the failing files. I tried that on a few files and it seems to work but I'm nervous about locally changing the source for a popular library. It must build on Windows (you can download the binaries, though not the PDB files, from the OpenCV sourceforge site) so I would like to understand how to build it on my machine without changing the source.
Am I missing something out in the configuration step? Is there some path setting etc. missing on my machine? Why am I getting these errors and how should I fix them?
========== EDIT ==========
Looking at the directory path this appears to be a problem with one of the 3rd party dependencies, OpenEXR. Looking on Github it appears to be version 1.7.1 of OpenEXR that is used in OpenCV 2.4.6. The instructions in the OpenCV's Quick Start Installation on Windows state:
In case of the Eigen library it is again a case of download and extract to the D:/OpenCV/dep directory.
Same as above with OpenEXR.
so I downloaded the OpenEXR 1.7.1 source code release and extracted the resulting files putting the directory openexr-1.7.1 into C:\OpenCV2.4.6\dep.
Then I ran cmake and tried to build the resulting Visual Studio solution. Sadly I see the same errors.
I was stumbling on the same issue while compiling OpenEXR. Then I found the solution googling for openexr std::min.
There is an issue opened on OpenCV where it says that, when using VS2013 Preview, you must add the line #include <algorithm> in the file where you're using std::min and std::max.
I put that line into the files where these methods are called and voilĂ ! Compilation succeeded.
You probably need to #define NOMINMAX. Try putting it before any other includes.
If that helps, then put in the you project's preprocessor defines.
There's lots of info about this, just search for NOMINMAX. Here's one post about it.
#include <iostream>
#include <algorithm>
Just include above 2 lines to the cpp file and the compilation error will disappear.

Visual Studio not using additional include directories for KinectBridgeWithOpenCVBasics D2D C++ Sample, but does for other solutions.

I'm working on adding some openCV features to a couple projects that use the Kinect and openGL/freeGLUT. I have downloaded and installed OpenCV using the pre-built libraries and successfully run a simple sample. Now I want to work with the Kinect Bridge with OpenCV Basics sample from the Kinect for Windows Developer Toolkit to get a better idea of how to use OpenCV with the Kinect. I downloaded the sample into my projects folder, opened the solution in visual studio and built it. I got the following errors:
Error 1 error C1083: Cannot open include file:
'opencv2/core/core.hpp': No such file or
directory c:\users\justin\documents\visual studio
2010\projects\kinectbridgewithopencvbasics-d2d\OpenCVHelper.h 17
and
Error 2 error C1083: Cannot open include file:
'opencv2/core/core.hpp': No such file or
directory c:\users\justin\documents\visual studio
2010\projects\kinectbridgewithopencvbasics-d2d\OpenCVFrameHelper.h 13
Initially I thought these errors were due to forgetting to specify the additional include directories. I added the same property sheet that my other OpenCV projects use to this one, but the errors remained. I tired copying the header files into the project folder: same thing. It seems like the only thing that works is specifying the full absolute file paths in the #include statements. I want to avoid doing this because visual studio wants me to change every #include in every file used in the project, including the openCV header files. I also tried shortening the name of my project folder in case the file path was too long (though I'm pretty sure that's more of an issue for the header file paths), but again no change.
The include directories and #includes that I'm trying to use are the same as in my other projects. I'm using Visual Studio 2010 on Windows 7 x64 based system.
Why would the additional include directory work for other projects, but not this one?
Usually when I see something like this it turns out to be a bad character in one of the prior include paths or other options that's messing everything up after it. I would take a look at your the command line page in the project configuration and see if you can spot anything amiss.

Using fuzzylite in Visual Studio 2010

Has anyone done this before ? I am not able to get it to work.
Following are my steps:
Download the windows package from link
I can run qfuzzylite (gui-tool) without any problem. Now I want to use the fuzzylite lib in my Visual Studio + Qt Integration Project.
In the CMake GUI I give fuzzylite source folder as the input folder and select Visual Studio 2010 as the compiler.
I am able to generate the Visual Studio fuzzylite solution in CMake without any errors.
Then, I tried to build the Visual Studio solution, but it fails with some weird errors. However, it does generate the fuzzylite-dbg.lib file (which I need).
Then I use this lib file and the fuzzylite.dll and include the path to the Headers in the VS Project. The project builds without any errors.
Now in the code I am doing
fl::Engine* engine = new fl::Engine("simple-dimmer");
This fails with the following exception:
exception text: bad allocation
exception type: class std::bad_alloc
Thank you for your detailed steps, but the solution seems to be a bit random (or weird as you put it). Unless more information is provided about the error, I strongly discourage the use of such a solution to attempt any fix to fuzzylite.
If you are running into problems, I strongly encourage you to report the problem in the forums at http://www.fuzzylite.com, where I and others will be very happy to help you.
As for the compiling errors, fuzzylite treats warnings as errors. A warning that is being raised in fuzzylite 4.0 when compiled using Visual Studio (not from console via nmake), and potentially in previous versions, is warning C4702, which refers to unreachable code. You can fix this by adding in file fl/fuzzylite.h the following line within the #ifdef FL_WINDOWS (together other #pragmas):
#pragma warning(disable:4702) //Ignore unreachable code
If the library was not built correctly, errors are bound to happen during runtime.
Ok, got it :)
Here are the steps for future reference:
Download the windows package from link
In the CMake GUI I give fuzzylite source folder as the input folder and select Visual Studio 2010 as the compiler. Now, if you want to use the lib in Debug mode tick the FL_DEBUG box (this is where I went wrong)
Now on clicking "generate", it will generate 5 projects:
ALL_BUILD
fl-bin
fl-shared
fl-static
INSTALL
ZERO_CHECK
Now in the Project properties in fl-bin, shared and static go to the Project Properties. In C/C++ go to Preprocessor get rid of the space in FL_DATA="mm.dd.yyyy " to "mm.dd.yyyy" (weird).
The solution should build fine and will generate fuzzylite-dbg.dll and fuzzylite-dbg.lib in the lib folder.
Use these files in your VC Project by adding the fuzzy-dbg.lib as the linker input and place the dll in the solution folder. Give the path "path\to\fuzzylite\fuzzylite." to the Include Directories.
Do the same process for Release mode (don't tick the FL_DEBUG flag)