Cannot open source file in a CMake Project in Visual Studio - c++

I have a C++ Project in Visual Studio 2022 (Windows 11) that is put together using CMake. I understand that the difference here is, that my project is not a Solution but rather just folders with code and the CMake tells it how to compile it?
But my problem is, that it doesn't seem to find C's standard libraries and shows error "cannot open sourcefile".
Screenshot
The error is definitely not in the project, since it runs just fine on my laptop, just not on the PC I want it to run on.
How can I tell it where these libraries are? Where are they located even?
Any help would be greatly appreciated and I can share more files on request.
Things I have tried:
Going to properties and choose the correct Windows SDK Version - The properties are empty
Comparing every variable of the CMake Settings with the ones on my laptop where it works
completely reinstalling Visual Studio (yes I did that)
looking through lots of StackOverflow questions but none of them describe my problem

Related

How do I alter the full path of visual studio project so I can use it on multiple computers?

So for a class we have a couple of programs where we are using opengl. To make setup easier we started by cloning glitter https://github.com/Polytonic/Glitter. I then compliled it according to the instructions for visual studio 2017 and added my code to the project I am working on. I did this on my desktop computer but saved the files in onedrive. When I open the same project on my laptop and try to build the project I get the error "the source directory D:/OneDrive/fall_2017/Glitter does not appear to contain CMakeLists.txt" and several other similar errors. On my laptop the directory to the files is C:/Users/Me/OneDrive/fall_2017/Glitter. The visual studio program lists the full path as D:/OneDrive/fall_2017/Glitter which is the path of the folder on my desktop.
Is there a way for me to change the filepath or is the issue with my cmake file? Do I have to rebuild it for every computer I use it on? I don't know a whole lot about visual studio so I don't know what I need to change to get this to work.
Turns out I have to rebuild on every computer. Thanks to those who left comments.

Building OpenCV 3.0.0's DLLs for Visual Studio 2015 with Cmake

Following the instructions here:
docs.opencv.org/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.html#windows-visual-studio-how-to
I setup an OpenCV project in VS 2015 Community and used the pre-built libraries. It works until I get this message:
"MSVCP120D.dll is missing from your computer"
From doing some searching I gathered this means that the pre-build libraries are only supposed to be used with an older version of VS so I figured I'd just compile them myself using this:
docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html#windowssetpathandenviromentvariablehere
While it appears to compile properly and despite flagging "BUILD_SHARED_LIBS" I can't find any DLL files in the output - just a lot of VS solutions:
imgur.com/JdSc5CH
Would someone be able to give me some advice on how to generate the DLLs?
thanks!
I'm a beginner at this stuff. I've since learned a lot about Visual Studio, about CMake and about OpenCV. Got it all working now, took me a day or two.
It turns out you have to compile the openCV library from git repository in order to be compatible with Visual Studio (VS14) 2015. As of this date, no go on pre-compiled version supporting VS14.
I've organized what I've learned, placed it online here in case anybody else has the same frustrations. Its pretty detailed, too much content to post here.
VS2015 uses MSVCP140.dll, I think your error message is about a redistributable package of VS2013.
And try BUILD_SHARED_LIBS as on/off.

GCC suddenly stopped working? Missing dependencies? [duplicate]

I have a problem with our executable. I'm running this C++ 32-bit executable on my Windows 7 64-bit development box that also has all those Microsoft applications (Visual Studio 2008 + 2010, TFS, SDK, Microsoft Office)...
And it's still running just fine.
Now I got the client installation of the very same program and was asked to test it with a clean Windows 7 installation. Thus I got one Windows 7 64-bit VMware and updated it to Windows 7 SP 1 (the very same version my developer box is tuning).
But while on my developer box everything is fine the program does not work with the VMware (30 days trial) box.
The x86 Dependency Walker is telling me that the following DLL files are missing:
API-MS-WIN-CORE-COM-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-0.DLL
DCOMP.DLL
GPSVC.DLL
IESHIMS.DLL
I googled for those API-MS-WIN-... DLL files and found they should actually already be part of Windows 7 (some sites claiming the belong to Windows 8 and Windows Server 2012 though).
I already tried the suggested fixes I found, which are:
running 'sfc /scannow'
installing Visual Studio 2008 SP1 runtime executables
But that didn't solve anything. :-(
Side note: My development box does not have them either, and does not seem to need them. For example, the user32.dll on my box does not link against one of those, while the installation on the VMware does.
Any idea on how to fix this issue?
I tried to find a suitable download / fix on the Microsoft pages, but I failed.
After solving my issue I wanted to report what I found out, and I can't post this as an answer because the question has been closed.
Actually all the DLL files reported missing by the Dependency Walker tool, namely those
* API-MS-WIN-CORE-...
type DLL files were not part of the actual problem.
In my case the registration of three OCX files was missing and after that everything was just fine, BUT Dependency Walker tool still listed all the very same DLL files as before even when the program was just running fine now.
The gist of it: As someone elsewhere stated, the tool is a bit dated by now and does not always work properly with a newer OS. Thus keep an eye open and don't get mislead by missing 'API-MS-WIN-CORE-COM-L1-1-0.DLL', ... the problem probably lies entirely elsewhere.
This problem is related to missing the Visual Studio "redistributable package." It is not obvious which one is missing based on the dependency walk, but I would try the one that corresponds with your compiler version first and see if things run properly:
Visual Studio 2015
Visual Studio 2013
Visual Studio 2010
Visual Studio 2008
I ran into this problem because I am using the Visual Studio compilers, but not the full Visual Studio environment.
Going to dare to inject a new link here: The latest supported Visual C++ downloads. Stein Åsmul, 29.11.2018.
I just resolved the same problem with C++ Qt 5 and Windows 7 64 bits with MSCVC 2012.
In the beginning I thought it was a MSVC/Windows DLL file problem, but as BorisP said, the problem was in my project dependencies. The key is "How to know your project dependencies in Qt 5?".
As I didn't find any clear way to know it (Dependency Walker didn't help me a lot...), I followed next the "inverse procedure" that takes no more than 5 minutes and avoid a lot of headaches with DLL file dependencies:
Compile your project and take the executable file to an empty folder: myproject.exe
Try to execute it, It will retrieve an error (missing DLL files...).
Now, copy all the DLL files from Qt (in my case they were in C:\Qt\Qt5.1.1\5.1.1\msvc2012_64_opengl\bin) to this folder.
Try to execute again, it will probably works fine.
Start to delete progressively and try every time your executable still works, trying to leave the minimum necessary DLL files.
When you have all the DLL files in the same folder it is easier to find which of them are not valid (XML, WebKit, ... whatever..), and consequently this method doesn't take more than five minutes.
I just resolved the same problem.
Dependency Walker is misleading in this case and caused me to lose time. So, the list of "missing" DLL files from the first post is not helpful, and you can probably ignore it.
The solution is to find which references your project is calling and check if they are really installed on the server.
#Ben Brammer, it is not important which three .ocx files are missing, because they are missing only for Leo T Abraham's project. Your project probably calls other DLL files.
In my case, it was not three .ocx files, but missing MySQL connector DLL file. After installing of MySQL Connector for .NET on server, the problem disappeared.
So, in short, the solution is: check if all your project references are there.
As mentioned, DCOMP is part of the VC++ redistributables (implementing the OpenMP runtime) and is the only truly missing component. All the rest are false reports.
Specifically API-MS-WIN-XXXX.DLL are API-sets - essentially, an extra level of call indirection introduced gradually since Windows 7. Dependency Walker development seemingly halted long before that, and it can't handle API sets properly.
So there is nothing to worry about there. You're not missing anything more.
A better alternative to find the truly needed DLL files that are missing (if that is indeed the problem) is to run Process Monitor and step backwards from the failure, searching for sequences of failed probes for a specific DLL file in all the system path.
I also ran into this problem, but the solution that seems to be a common thread here, and I saw elsewhere on the web, is "[re]install the redistributable package". However, for me that does not work, as the problem arose when running the installer for our product (which installs the redistributable package) to test our shiny new Visual Studio 2015 builds.
The issue came up because the DLL files listed are not located in the Visual Studio install path (for example, C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist) and thus had not been added to the install. These api-ms-win-* dlls get installed to a Windows 10 SDK install path as part of the Visual Studio 2015 install (e.g. C:\Program Files (x86)\Windows Kits\10\Redist).
Installing on Windows 10 worked fine, but installing on Windows 7 required adding these DLL files to our product install. For more information, see Update for Universal C Runtime in Windows which describes the addition of these dependencies caused by Visual Studio 2015 and provides downloads for various Windows platforms; also see Introducing the Universal CRT which describes the redesign of the CRT libraries. Of particular interest is item 6 under the section titled Distributing Software that uses the Universal CRT:
Updated September 11, 2015: App-local deployment of the Universal CRT is supported. To obtain the binaries for app-local deployment, install the Windows Software Development Kit (SDK) for Windows 10. The binaries will be installed to C:\Program Files (x86)\Windows Kits\10\Redist\ucrt. You will need to copy all of the DLLs with your app (note that the set of DLL files are necessary is different on different versions of Windows, so you must include all of the DLL files in order for your program to run on all supported versions of Windows).
This contribution does not really answer the initial question, but taking into account the hit-rate of this thread I assume that there are quite a few people dealing with the problem that API-MS-WIN-CORE- libraries cannot be found.
I was able to solve a problem where my application refused to start with the error message that API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL is not found by simply updating Visual Studio.
I don't think that my build environment (Windows 7 Pro SP1, Visual Studio Ultimate 2012) was messed up completely, it worked fine for most of my projects. But under some very specific circumstances I got the error message (see below).
After updating Visual Studio 11 from the initial CD-Version (I forgot to look up the version number) to version 11.0.61030.00 Update 4 also the broken project was running again.
This solved the issue for me:
Uninstall the Visual Studio 2010 redistributable package if you have it installed already, and then install Microsoft Windows 7 SDK.
I solved the problem. When I registered the OCX files, I ran it with the Command Window that had been executed as an administrator.
For anybody who came here, but with a Photoshop problem: my solution was to uninstall the MS VC++ redistributable first x86 and 64 both. Then install one appropriate to the Windows version and architecture (86 or 64).
Installation of SQL Server Management Studio 2014 on a freshly installed Windows 7 resolved this problem at our client after a two-day ridiculous battle.
I came here with this problem occurring, after trying a fresh Windows 7 OEM install, upgrading to Windows 10.
After some searching of Microsoft forums and such I found the following solution which worked for me:
Replace C:\Windows10Upgrade\wimgapi.dll with the one from C:\Windows\System32\wimgapi.dll
I suggest also checking how much memory is currently being used.
It turns out that the inability to find these DLL files was the first symptom exhibited when trying to run a program (either run or debug) in Visual Studio.
After over a half hour with much head scratching, searching the web, running Process Monitor, and Task Manager, and depends, a completely different program that had been running since the beginning of time reported that "memory is low; try stopping some programs" or some such. After killing Firefox, Thunderbird, Process Monitor, and depends, everything worked again.
I had the same problem. After spending hours searching on the web, I found a solution for me.
I copied the file combase.dll file (C:\Windows\System32) to the release folder, and it resolved the problem.
Just to confirm answers here, my resolution was to copy the DLL that was not loading AND the ocx file that accompanied it to the system32 folder, that resolved my issue.

can't setup openGL superBible examples due to problems finding Windows.h

I'm trying to compile the examples from the book OpenGL SuperBible 6th edition.
I got everything from their git repository and I'm trying to open it using Visual studio 2013 by opening the visual studio 2013 solution file that is included.
When I try building the main project inside "sb6_vs2013" It claims it can't find Windows.h : "Error 2 error C1083: Cannot open include file: 'windows.h': No such file or directory"
Now I tried to look at people's solutions on the internet and couldn't find anything helpful.
If I right click on the project and go to properties -> Configuration Properties - > VC directories I can see that it has the line:
$(WindowsSdkDir)\include
When I click on Macros I can see the path of WindowsSdkDir, its pointing to the right place where Windows SDK is, which in my case is: "C:\Program Files (x86)\Windows Kits\8.1" if I look at my file system in that folder and go to "\Include\um\" I can find Windows.h there, but for some reason visual studio 2013 fails to find it.
I thought it was due to bad installation and I even went as far as re-installing windows, visual studio and everything (it was time for that anyway) but nothing seems to fix this problem, even the new fresh installation didn't do the trick.
I'm not sure what else I can do to make this work.
Could someone help me solve this issue once and for all?
Eventually I managed to solved it, after the reinstall all the macros were correct I just need to check "inherit from parent on project defaults" checkbox and it did the trick

Open CV 2.2 Include Directory Missing

I have several Windows 7 64bit systems with OpenCV 2.2 installed on them using CMake and Visual Studio 2008 Standard. CMake generates everything in C:\libs\OpenCV-2.2.0\build just fine and Visual Studio 2008 compiles everything without complaint.
However, every time I do this process on various machines I find that the include directory (C:\libs\OpenCV-2.2.0\build\include\opencv2) is either empty or nearly so. I usually end up thrashing around compiling different versions and poking on random project files until it appears and every time I think I have it figured out. However, with each new install I'm back to the begining.
Is this a known issue for 64bit build of OpenCV 2.2 on Windows 7 64bit using Visual Studio 2008 and is there a known workaround?
Various questions here seem to be hinting at the same thing and guides online are either old or don't reference the problem at all.
To solve this problem compile everything in release and debug then right click the INSTALL project in Visual Studio 2008 and choose Build. This will "install" numerous files and move all the include files into the proper location.
Now /include will contain subfolders
opencv
opencv2
and /include/opencv2 will contain numerous subfolders:
calib3d
contrib
core
feature2d
flann
gpu
highgui
imgproc
legacy
ml
objdetect
video
I just had the same problem. The Answer which explains that you have to rightclick and build the "INSTALL" project after you have built the debug/release works for me now. BUT: for me it was not a "build" folder which was created, but a folder called "install". Inside of that folder there is a include folder now which contains all the stuff you need for the include. The OpenCV version im using is OpenCV v3.2.
well i have the same problem with visual studio 2010,
and the answer
""To solve this problem compile everything in release and debug then right click the INSTALL project in Visual Studio 2008 and choose Build. This will "install" numerous files and move all the include files into the proper location""
cannot work on this. because when you choose 2010 visual configuration
there are no option to do debg or release. u do this afterwars from visual studio
when complile in debug or release mod. has one anny answer.
you my friend that have managed to create a full buld properly
can you please make one with qt support ,and with examples and docs cmake configuration amd please e mail it to me??
it wont take you more than some minutes
and this will be a great help because i try many days to solve it
How are you making \build\ ?
I didn't think opencv did out-of-source builds properly. At least I've never got them to work - have you tried setting the build dir to a completely separate tree?