Eclipse CDT MinGW path variables - c++

My Eclipse didn't show any console outputs.
I tested the ".exe" in the debug file of my C++ project, with wich i received an error that "libgcc_s_dw2-1.dll" was missing.
I read abit on this and i found that i could simply copy/paste that file from my c:/MinGW/bin folder to the ".exe" in the "/debug" folder of my project.
That helped me with that error but i then received the message that "libstdc++-6.dll" was missing, so i did the same again.
Now The ".exe" works fine and I get an output in my eclipse.
But now i'm afraid that i will get simillar erro's at my next build if i use some what more complex programming.
I also think that it would be very timeconsuming if i have to add those files too all of my future projects.
Question:
So my question now isn't there a way to tell eclpise that those .dll files are at "c:/MinGW/bin"?
PS.
I suspect that a similar question already exists but I wouldn't have a clue on what tags I'd have to search for.

Speacial thanks to #Deniz !
right click on "my computer" => properties .
on the right select "Advanced system settings".
open "Enviormentvariables"
search for "path"
select Edit
you'll have a list of paths, hit "end" on your keyboard to make sure you are at the end of this list.
then add ";" to close the previous path and add the path to your MinGW/bin location. (by default C:\MinGW\bin).
result in adding ";C:\MinGW\bin"

Related

Xcode 8.2 can't find header files from added search path?

I am having trouble getting Xcode to find opencv header files. In the 'Build Settings' tab I added the recursive path '/usr/local/Cellar/opencv3/include' to 'Header Search Paths' and 'User Header Search Paths' and I have an include of #include "opencv2/core.hpp"
I added the path to both keys because it wasn't working for either one individually so that's just the way I have it right now. The error I get is 'opencv2/core.hpp' file not found. Any suggestions? I'm pretty sure this should be working.
EDIT 1: I also have the key 'Always Search User Paths' set to 'Yes'
My apologies to those who spent time trying to figure out what was wrong. The problem was that I had set the build settings for the UI tests target rather than the application project.
In case others come across the same mistake, This is where the target can be changed:
I don't remember ever changing it in the first place, but apparently I did at some point.
Hopefully this is helpful to the next guy that makes this simple mistake.

"Error C1083: Cannot open source file" Shouldn't Be Looking For The File At All

I was trying to #include a cpp file with some functions so I can use that cpp file later with other projects. It gave me an 'already defined in .obj' error and since then that .cpp file was like binded with my project. (I understood that's not the way, the answer here helped me with the already defined)
If I exclude the .cpp file from the project, remove it from the directory and remove the #include line it still looks for it:
c1xx : fatal error C1083: Cannot open source file: 'std.cpp': No such file or directory
Diagnostic:
Outputs for D:\MY DOCUMENTS\C#\PROJECT\D3DTESTC++\COWS AND BULLS\CBMAIN.CPP|D:\MY DOCUMENTS\C#\PROJECT\D3DTESTC++\COWS AND BULLS\STD.CPP: (TaskId:15)
It shouldn't be looking for the std.cpp at all, I removed it! So is there a way I can reset the project and recompile so that the program doesn't look for it? I already tried Rebuild and Clear -> Build Project
When I ran across a similar problem with VS Express, I wound up having to open up the the .vcxproj file (which is just XML), and remove the offending
< ClInclude Include="FILEPATHANDNAME" > tags.
Many of the solutions here will not work
Fullproof method:
Open the vxproj file that is giving you trouble in a text editor.
remove all references to the file it cannot find.
OK, I have no idea how I did it but I'm still going to try to write what I did.
Save all and Close solution
Open the .vcxproj file (not .sln)
Build -> Clean [Project Name]
Save all and Close
Open the .sln file again.
Build -> Project Only -> Clean Only [Project Name]
Build -> Project Only -> Build Only [Project Name]
That's exactly what I did and worked for me. I think the main thing to do is clean, save, close, open, build, but I'm not sure.
In Solution Explorer you can select/deselect option "Show All Files".
Try both options and make sure excluded file is not included in project for both of them.
That's what I had:
I used "Show All Files" option (so you can see all the files in project directories). I excluded one of my .cpp files from project. However, it behaved as this file is in project.
That's how I managed to fix it:
I switched "Show All Files" off and saw this file still belongs to project! So I excluded this file once again.
As I see, that's a known issue.
This worked for me, hope it will be useful for someone else.
Try to verbose builder output to see exact steps of what's going on. I suppose, you use Visual Studio, right?
Go to menu "Tools -> Options"
In options dialog, select "Projects and Solutions -> Build and Run"
Change current mode of "MSBuild project build output verbosity" from "Minimal" to something like "Diagnostics" or "Detailed".
Rebuild your project and investigate Output windows
Builder dump should shed more light on your current settings (I suspect you have more references to that file than you expect)
This happened to me because I renamed folder from inside the IDE. None of the above solutions worked. The only way to fix this is by opening vcproj in notepad and you should see the offending files in the <ItemGroup>. Just delete those lines.
Or sometimes, like in my case, the issue is simply in the naming of the folders in the location. I had a very long path with folders that I like to name with special characters so they show up at the top and it's easy to access them.
As soon as I put my solution in a folder just in D: drive, the issue was gone.
When I renamed a file, I found I had to go to SolutionExplorer, Source File, select the file, first exclude from Project, then re-add it to project, and rebuild the solution it lives in. It was still showing up as the old file name under Source Files for me.
I had the same problem, but I had another .sln worked fine. After tooling around with the Project->Properties-> to make them look identical, nothing worked. I opened both .vcxproj files and copied the contents of the working version into my non-working version. (I noticed that the two files had different lengths. The non-working version was longer by about 20 lines.) I just changed the RootNameSpace to the non-working version's name. I saved the non-working file and presto! It worked.
I removed those sources from Project and re-added them. Somehow, references were messed up after a hurry project refactoring.
For people having problem related to "error C1083: Cannot open source file":
Error is caused by settings in *.vcxproj file. Probably you deleted/moved source file by file explorer, not by Visual Studio's "Solution Explorer". Thus, your *.vcxproj file is corrupted. Fix is to manually correct settings in *.vcxproj file.
How Visual Studio settings files work
Visual Studio saves solution's info into file. This file is usually in project's solution directory, has extension .sln and base name is same as name of solution, f.ex.:
NameOfSolution.sln
Similarly, project's info is saved into one file (each project has its own file). Base name of this file is name of project, extension is .vcxproj, and usually is located in subdirectory named as your project, f.ex.:
NameOf1stProject/NameOf1stProject.vcxproj
NameOf2ndProject/NameOf2ndProject.vcxproj
Both *.sln and *.vcxproj files are textual files. You can open them by using Notepad.
How to fix problem
Find *.vcxproj file responsible for your project.
If you don't know where it is, open in Notepad the *.sln file of your solution. Search for name of your solution. You will find line like:
Project("{9AA9CEB8-8B4A-11D0-8D22-00B0C01AA943}") = "NameOf1stProject", "NameOf1stProject\NameOf1stProject.vcxproj", "{A8735D0A-25ED-4285-AB8F-AF578D8DB960}"
Value under "NameOf1stProject\NameOf1stProject.vcxproj" is location of *.vcxproj file of your project.
Open found *.vcxproj file by text editor (f.ex. Notepad).
Search for line on which is filename you are struggling with.
Example: if you are looking for "RemovedFile.cpp", then you should find line:
<ClCompile Include="RemovedFile.cpp" />
Delete that line.
If you have opened Visual Studio, it asks you if it should refresh solution - select yes. If it is not opened - just start using it.
In case of any problems, try to rebuild solution (top banner -> Build -> Rebuild Solution)
In my cases, it worked. 30 mins of trying to fix, <1 minute of fixing.
This helped in my case. To sum it up, my path to the project was too long, so I moved my project to something shorter i.e. D:\my_project and everything worked in a blink of an eye.
I had this same problem, but for me the issues was that I was using Bash on Windows (WSL) to clone the repository and then using VS to compile.
Once I deleted my clone and used Windows command line (cmd.exe) to clone the repo then the error 1083 went away.
This is caused by not removing/deleting the file properly. Go to Solution Explorer, select your solution, at the left corner, activate the icon: show all files.
(if you already removed the problem file, restore it from recycle bin)
Select the problem file, do remove and delete from within Solution Explorer and you should not have this problem. And remember to do it the proper way from now on.
This is on MS 2010
If you have that file in your project directory but you still got the error, on your IDE go to Solution explorer--> Remove that file-->then open the project directory on your file explorer-->Select that file and drop it on a specific location in IDE solution explorer. I fixed it this way. I use the Windows platform.
I got this error when I got a code from my peer and I tried directly running it on my system. Ideally to avoid such errors, I should have just copied the source and header files and should have created the VS solution of my own.
To resolve the errors I removed the files from the Solution Explorer and added them again. Following image shows the Solution Explorer window.
The remove option comes after right clicking on the file names.

Where does Xcode create .txt files to?

http://www.cplusplus.com/doc/tutorial/files/
I just finished executing this but I didn't get any file on my desktop.
So where does the .txt file get placed on my computer?
// basic file operations
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}
Damn... I've seen this post never answered many times..
Here's the solution
In your project navigator when you're working in your current project there are many files. Try products (if I remember) and look for the executable file. Now go to the properties inspector or whatever is called. (Right side of your Xcode.)
There you will find somewhere a part called PATH the path that is written over there. It's the path where the executable runs. That means there is where you'll find all the files you create with your program.
Try it... that's how I manage and look my .txt files since sometimes I wanna give them some kind of formatting.
I hope I've solved your problem... cheers! ;)
Click on the executable in the Products tab on the left hand side, and you should see the path to it displayed on the right in the utilities section. This is where they are saved. On my computer this path is:
/Users/myName/Library/Developer/Xcode/DerivedData/CurrentXcodeProject-adsnvetbleazktcgitfymfcbhkkt/Build/Products/Debug/filename.txt
In the "current directory", meaning the working directory of the environment from which you ran the executable.
I can't tell you what that is, but in basic cases it may be the directory where the executable is located. In many other cases it may not be.
Performing a search for the file on your hard drive will reveal its location to you.
Right click on your product and select "Show in Finder". Thats opens the path to where the output files go. Also you can add input files there to be read in by your program.
Found best answer here:
File creation in C++ on Xcode
Basically you can specify a known directory so that all files created go there.
If you are on Mavericks Right click in your user folder with your documents and pictures and stuff (~/Users/yourusername)
Now right click and view options. Check "show library". Now follow to the path that the first user above said.
What I've always done when an application saves a file and I don't know where... is just go back to that application, and hit File>Save As...
So re-open Xcode and go to the "File" menu, and click "Save As..."
It will show you the same directory it just saved to.
I have checked the "Current Directory" but I believe I have to specify the location. Not even
~User/Desktop
will work.
What I do is create an empty file with a the correct name on my desktop then drag that file into my Xcode project to get its path. I then delete the file.
Same with adding files to my project. I can add them from the File menu, but I will need to drag them in to the spot in my code where I want to reference them.
It is kind of convoluted but it is the only system I have.
Some of the answers are confusing. Here's the simplest solution.
1. Expand your Products folder on the left-hand side
2. Right click on the terminal icon(sorry I do not know what it's called)
3. Click show in Finder.
You should be able to see your output file in there.
" Where does Xcode create .txt files to? "
You can decide where you want: follow these->
" Product->Scheme->EditScheme "
chose options tab in the new popup "options"
"working directory" tick "use coatroom working directory" and locate the folder where you want.
The .txt file that you "create", or that you want too "read" has to keep in this folder.
In 2022, click on the project name in the "breadcrumbs" area above the editor. Select the correct thing in "Products", then in the right area, see "Full Path".

How to get minGW to find the path to compile and link correctly

I am currently using Sams Teach yourself C++ in 24 Hours for my computer science class that starts in about a week and it told me to download minGW and then change the path variable to ;C: \MinGW\bin, which I did, but then when I attempted to compile and link the "program" it told me to create, it says no such file or directory. Does anyone know why it is saying this or how it can be fixed? I even put the file which is named motto.cpp into the bin file and it is still saying that it cannot be found.
Are you on Windows 7? If so, try opening Start Menu, searching for "Variables" and select "Edit System Variables" then search for the button at the bottom "Environment variables..." and push it. Then select "new..." under "User variables for ", assign it a name and put the C:\MinGW\Bin path for the value. Press "OK" twice and try it from command line.
I am unsure if you are using a compiler IDE such as DevCPP or CodeBlocks, so I am assuming you are doing this from command line. If this is a compiler issue, try editing the compiler settings for include, bin and lib. Point them to the MinGW bin for bin and include for include etc...

XCode c++ file reference

I'm trying to write a few algorithm programs practising for Google Code Jam but I can't get XCode to read from an input file (easily).
I have added the file to the project and it appears in the left hand file navigation bar. But I can't reference it relatively. In Code::Blocks I just input from "FileName.txt" and it works but with XCode it just can't find it.
If I put the full file path (i.e. /Users/myname/Documents/Google Code Jam/ProjectName/ProjectName/FileName.txt) then it works but that just seems ridiculous.
Is there anything I can do to get XCode to work? When I added the file I ticked the copy file into project directory and also the add to target executable.
Any help is appreciated.
Thanks!
I just found this and the comments by Julio Gorgé is just what I needed. The default working directory when running in debug mode is some esoteric folder (as you can see in iOS if you include system("pwd"); at the beginning of your main().
It's in the "Options" tab of the Edit Scheme... menu that you can tick "Use custom working directory" and find the test file you put in in the Arguments tab.