Configuration of C++ on Windows OS - c++

I installed the MinGW-w64 C/C++ package on C:\.
What are the system environment variables I should add into the Windows OS so that I can code in C/C++ on VS Code e.g. C:\MinGW-w64...\bin, etc?

You shoul add the path of the GCC compiler
mostly it should be like C:\MinGW\Bin
(here C:\ can also be something if you put that at some other place or a different drive, I normally install it directly in C drive and it works well)
Search for Path in Windows Search, you'll find an option of "Edit Environment and Path Variables"
Open it
Go to system variables (so it can be available to all users)
Click on the path, there will be some blank lines, paste your copied path from Windows Explorer, or click the browser option to browse it.
The main thing to add in path in MinGW\Bin which contains all compile binaries)
I hope you get what I went to say.

Related

"SDL2.DLL missing from computer" but is in the same folder as program?

SDL Folder in the same directory:
Contents of SDL folder:
I cant get my program to run as it says it cannot find SDL2.DLL? Any ideas?
Programs don't search your entire hard drive for DLLs. That would be expensive, horribly insecure, and bug prone.
Instead they have a search path, which depends on how you load it. Often your PATH environment variable is used, together with various other system places, as well as the directory of the process loading the dynamic library.
This list rarely includes "a subdirectory of the process executable called SDL". You can, however, modify the search path; how exactly depends on how you are trying to load SDL.
The easy solution is to try to copy them all into the same directory.
You can use a Post-Build-Event to copy sdl2.dll into the directory where your .exe is built. Manually copying the file is fine for a quick test, but having Visual Studio do it for you has some advantages. For example, this lets you completely delete your Debug and Release directories and have the correct file copied when you do a clean build.
In your directory listing I see bin32 and bin64 directories inside the SDL directory. I assume that there is a copy of sdl2.dll directly inside each of those directories, but there are no separate debug and release versions, just 32-bit and 64-bit. Let me know if this is incorrect, otherwise, you can do this:
Open the Solution Explorer and select your project (not the solution). Then use Alt+Enter to go directly to the Property Pages. (Or right-click the project and select Properties at the bottom of the menu.)
In the selection panel on the left, go to Configuration Properties/Build Events/Post-Build Event.
At the top of the property sheet, set the Configuration dropdown to All Configurations and the Platform dropdown to All Platforms.
Click the edit box to the right of Command Line and enter this command:
copy "$(SolutionDir)SDL\bin$(PlatformArchitecture)\sdl2.dll" "$(TargetDir)"
Now click OK, and save and build your solution. You should find that it copies the correct version (32-bit or 64-bit) of sdl2.dll into the build directory.
The various $(FooBar) entries in the command line are macros which ar automatically expanded according to things like your project directory location, the type of platform you're building for, etc.
$(SolutionDir) is the directory containing your .sln file, with a trailing backlash.
$(PlatformArchitecture) is 32 or 64 depending on which platform you're building for.
$(TargetDir) is the directory that VS creates your .exe file in.
So this command line is an ordinary copy command as you might use in a command prompt, with the paths filled in to copy either SDL\bin32\sdl2.dll or SDL\bin64\sdl2.dll to your build target directory. We use quotes around the source and destination paths in case you have any spaces in your project path.
In some cases you may need specific commands for a particular configuration (Debug/Release) or platform (Win32/x64). You can do this by selecting that configuration or platform at the top of the property sheet. In our case, we can use one command for both 32-bit and 64-bit builds thanks to the $(PlatformArchitecture) macro.
To learn more about the macros, you can select the Command Line box in the property page and then click the drop-down arrow that appears to the right of the box, and select <Edit...>. This opens a multiline edit window (you can use more than one command in the build event), with an Evaluated value below it that shows the actual command that will be used for your current configuration and platform. You can inspect this command to see if it looks right, and you can also copy the evaluated command and paste it into a command prompt window for a quick test.
To see a full list of available macros and what they expand to for your current configuration/platform, click the Macros>> button below that and look through the list or use the search box at the top.

Always have to define PATH variable in Eclipse on windows

I've recently started using eclipse to develop c++ applications(or at least im trying to) but I'm having trouble because something seems to be wrong with my PATH variable, as in order to get eclipse to compile my c++ applications correctly I have to go to the projects properties and manually add the cygwin64 bin folder's path as the PATH variable EVERY time, this isn't a HUGE deal, but it'd be nice if i could just set it as default or something, I've tried setting the PATH default in the advanced windows settings but to no avail..
I've tried setting the PATH default in the advanced windows settings but to no avail..
If you have done that, then you would need to open a new cmd Windows, check that the PATH is correct (type set PATH) and launch eclipse from there.
Then you should see the cygwin tool chain will be shown when you open a new c/cpp project wizard.
(from this blog post)
More on:
"Eclipse + Cygwin + Make: Windows path problems"
"How to deal with Eclipse CDT+Cygwin?"

NetBeans 7 c++ remote development host include path

Maybe this is a little bit esoteric, let's see how it goes.
I'm writing a c++ program using NetBeans 7 on a Windows 7 x64 box, but building on a remote development host, which is actually an Ubuntu Server 10.4 x64 virtual machine running on VirtualBox 4.
Source files are shared using VirtualBox shared folders. I've been able to create projects, build and debug them with no problems.
However, the code assist features of NetBeans keep on complaining that none of my include files can be found, and therefore I get a code assist "unable to resolve identifier" error for every single function call.
This is not very surprising, as the include files are actually in /usr/include, which is not part of the shared folder scheme, and therefore are not directly readable by NetBeans (it can and should read them using ssh though). But I would expect for NetBeans to allow me to set remote directories for code assist. I've looked through many settings and haven't found anything resembling what I'm looking for.
Sure, it's possible to just ignore this errors, but apart from me being near-OCD, that would be the same as disabling code assist, and I really appreciate it when the IDE tells me about a typo or other things that can be done with code assist.
Any ideas?
You might want to try the following settings in Netbeans, which solved my problem of code assist on remote hosts:
1) Project Build Settings
a - Right-click on the project in the project pane, select "Properties"
b - Expand "Build" and click "C++ Compiler"
c - In the "Include Directories", make sure you set the correct Configuration (Debug or Release) at the top, click the "..." to open the "Include Directories" window
d - Put the full path of the include directory. Notice that when you click "Select", Netbeans will automatically prepend the Windows path information. Since you are developing on a remote Linux host, you must now click the "Edit" button and edit this path to resemble the Linux file path (without the C:)
2) Netbeans Code Assistance Options
a - In the Netbeans menu bar, click "Tools" and then "Options"
b - Click "C/C++" at the top, then select the "Code Assistance" tab
c - Make sure the "Tool Collection" is set to the proper remote host at the top
d - For bot the "C Compiler" tab and the "C++ Compiler" tab, click "Add" and manually type the full path to the directory you want Code Assist to index.
e - Again, when you click "Select", Netbeans will automatically prepend the Windows path PLUS change the slashes to Windows slashes (ugh)... so now you must click "Edit" and edit those paths to represent the correct Linux syntax
Hope that helps!!

How do I add the MinGW bin directory to my system path?

I am using Windows XP. I am trying to add a new library to Dev-C++. For that, I need to install MinGW and then I have been instructed to add the bin directory of MinGW to my system path. But, I don’t know how to do it. Please guide me (step by step) to add this to my system path.
To change the path on Windows XP, follow these instructions, and then add the directory where you install MinGW plus bin. Example: if you install MinGW in C:\ then you have to add C:\mingw\bin to your path
Just for completeness here are the steps shown on the link:
From the desktop, right-click My Computer and click Properties.
In the System Properties window, click on the Advanced tab.
In the Advanced section, click the Environment Variables button.
Finally, in the Environment Variables window, highlight the Path variable in the Systems Variable section and click the Edit button. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon as shown below.
C:\Program Files;C:\Winnt;C:\Winnt\System32;c:\mingw\bin

OpenCV - DLL missing, but it's not?

I am trying just a basic program with OpenCV with the following code:
#include "cv.h"
#include "highgui.h"
int main()
{
IplImage* newImg;
newImg = cvLoadImage("~/apple.bmp", 1);
cvNamedWindow("Window", 1);
cvShowImage("Window", newImg);
cvWaitKey(0);
cvDestroyWindow("Window");
cvReleaseImage(&newImg);
return 0;
}
When I run this, I get
The program can't start because
libcxcore200.dll is missing from your
computer. Try reinstalling the
program to fix this problem.
However, I can see this DLL. It exists. I have added the following to the input dependencies for my linker
C:\OpenCV2.0\lib\libcv200.dll.a
C:\OpenCV2.0\lib\libcvaux200.dll.a
C:\OpenCV2.0\lib\libcxcore200.dll.a
C:\OpenCV2.0\lib\libhighgui200.dll.a
What gives? I'm using visual studio 2008.
When I link the .dll files instead of .dll.a files, I get
fatal error LNK1107:invalid or corrupt
file: cannot read at 0x3F8
libcv200.dll
I followed instructions on http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010 but was still stuck on exactly the same problem, so here's how I resolved it.
Fetched MSVC 2010 express edition.
Fetched Win 32 OpenCV 2.2 binaries and installed in default location.
Created new project.
Project setup
Project -> OpenCV_Helloworld Properties...Configuration Properties -> VC++ Directories
Include Directories... add: C:\OpenCV2.2\include\;
Library Directories... add: C:\OpenCV2.2\lib;C:\OpenCV2.2\bin;
Source Directories... add:
C:\OpenCV2.2\modules\calib3d\src;C:\OpenCV2.2\modules\contrib\src;C:\OpenCV2.2\modules\core\src;C:\OpenCV2.2\modules\features2d\src;C:\OpenCV2.2\modules\flann\src;C:\OpenCV2.2\modules\gpu\src;C:\OpenCV2.2\modules\gpu\src;C:\OpenCV2.2\modules\highgui\src;C:\OpenCV2.2\modules\imgproc\src;C:\OpenCV2.2\modules\legacy\src;C:\OpenCV2.2\modules\ml\src;C:\OpenCV2.2\modules\objdetect\src;C:\OpenCV2.2\modules\video\src;
Linker -> Input -> Additional Dependencies...
For Debug Builds... add:
opencv_calib3d220d.lib;opencv_contrib220d.lib;opencv_core220d.lib;opencv_features2d220d.lib;opencv_ffmpeg220d.lib;opencv_flann220d.lib;opencv_gpu220d.lib;opencv_highgui220d.lib;opencv_imgproc220d.lib;opencv_legacy220d.lib;opencv_ml220d.lib;opencv_objdetect220d.lib;opencv_video220d.lib;
At this point I thought I was done, but ran into the problem you described when running the exe in debug mode. The final step is obvious once you see it, select:
Linker -> General ... Set 'Use Library Dependency Inputs' to 'Yes'
Hope this helps.
Just add C:\OpenCV2.0\bin into your PATH environment variable
or
When you install OpenCV,
Choose the option, Add OpenCV to the system PATH for current user which is not default one
Just for your information,after add the "PATH",for my win7 i need to reboot it to get it work.
In Visual Studio 2013 you need to add this to the Environment Variables and then Restart your pc. This is the path where .dll file located in.
I have had numerous problems with opencv and only succeded after a gruesome 4-6 months. This is the last problem I have had, but all of the above didn't work. What worked for me was just copying and pasting the opencv_core2*.dll (and opencv_highgui2*.dll which it will ask for since you included this as well) into the release (or debug folder - I'm assuming. Haven't tested this) folder of your project, where your application file is.
Hope this helps!
You just need to add the folder of the needed dll file (or files) to your system "Environment Variables" in "Path".
Your problem will 100% be resolved. I had this problem too.
just open the bin folder and copy and paste the .dll files to the folder you are working in..it should fix the problem
As to #Marc's answer, I don't think VC uses the path from the OS. Did you add the path to VC's library paths. I usually add the DLLs to the project and copy if newer on the build and that works very well for me.
you can find the opencv_core248 and other dlls in opencv\build\x86\vc12\bin folder. Just copy the dlls you require into system32 folder. And your app should start working in a flash ! Hope it helps.
This might be like resurrecting a dead horse. But just so it's out there, the reason why the answer to these types of questions to simply put dll's into the system32 folder is because that folder is in the os's system path.
It's actually best practice to provide the os with a path link.
With windows 10
open up file explorer
right click on "this pc" and select "properties"
Now in the "Control Panel\System and Security\System" window that comes up, click on "Advanced System Settings" from the left hand panel.
At the bottom of the next window, click on the "Environment Variables" button.
On the next window, there are two panels, the top one is for modifying variables to the current user, and the bottom panel is for modifying variables to the system. On the bottom panel, find the variable "Path" and click it to select it, then click on the "edit" button.
Here you can then create, edit, delete, or update the different paths for the system. For example, to add mingw32-make to the system so you can access that command via command prompt, click new, then paste in the path to the bin. Example path, "D:\Qt\Tools\mingw730_64\bin", no quotation marks nor additional whitespaces.
Click ok on all the windows so that the changes are saved, then reboot your computer for the changes to be loaded.
The ".a" at the end of your DLL files is a problem, and those are there because you didn't use CMAKE to build OpenCV 2.0. Additionally you do not link to the DLL files, you link to the library files, and again, the reason you do not see the correct library files is because you didn't use CMAKE to build OpenCV 2.0. If you want to use OpenCV 2.0 you must build it for it to work correctly in Visual Studio. If you do not want to build it then I would suggest downgrading to OpenCV 1.1pre, it comes pre-built and is much more forgiving in Visual Studio.
Another option (and the one I would recommend) is to abandon OpenCV and go with EmguCV. I have been playing with OpenCV for about a year and things got much easier when I switched to EmguCV because EmguCV works with .NET, so you can use a language like C# that does not come with all the C++ baggage of pointers, header files, and memory allocation problem.
And as for the question of 64bit vs. 32bit, OpenCV does not officially support 64bit. To be on the safe side open your project properties and change the "Platform Target" under the "Build" tab from "Any CPU" to "X86". This should be done any time you do anything with OpenCV, even if you are using a wrapper like EmguCV.
Copy all .dll from /bin in System32
Just copy the .dll files to C:\windows\system32\
No need to do any of that. It is a visual studio error.
just go here:
http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=31354
and download the appropriate fix for your computer's OS
close visual studio, run the fix and then restart VS
The code should run without any error.