How to replace the source file with my own source file (from download or edit) in Xcode? - c++

I'm using Xcode as an IDLE editor of C language. I downloaded an SDK package from a algorithm competition website and compiled it successfully on the terminal, but now I have a need to compile and run the source .cpp file(that inside the SDK packadge) directly by Xcode, so:
Is there a way to replace the CPP source file of command-line-tools project with the CPP source file that I specify the path of it?
Or is there a way to creat a new command-line-tools project from the specified path CPP source file?

I've now Solved this problem through the method one whitch says "Is there a way to replace the CPP source file of command-line-tools project with the CPP source file that I specify the path of it?", but still have no idea about method two.
Just creat a symbolink of CPP source file and right-click the project, add the alias to project. Because the "add" is copy in fact, instead of "import" or "open". Only by copying the alias can the purpose of modifying the source file be achieved.

Related

Adding a CSV file to a project in Visual Studio

I am working on a project where I have to read in serveral pre-existing CSV (dog.csv, horse.csv, etc.). I want to know how would I add these file into my project so that I may test to see if my print functions work (the code is written in c++). Would I have to copy and paste the files into the debugging folder or would I place it under the test folder of the project?
You can include the files in your project in whatever (sub)folder you wish by using Right click -> Add -> Existing Item. Then, right-click on each file and choose Properties. Set up "Copy to output directory" to "Copy if newer".
Then after build, your files will be copied into the bin/debug folder.
To read the file, you can just use:
System.IO.File.ReadAllText("dog.csv");
Another possible way is to add a file within project, right click and select properties, and then in Copy to Output Directory, select Copy always. This way, csv file will be automatically copied in your debug and release packages too.
string executableLocation = Path.GetDirectoryName(
Assembly.GetExecutingAssembly().Location);
string csvLocation= Path.Combine(executableLocation, "file.csv");
Above code will read file location from bin directory where your csv file will be stored.
This link should help guide you how to add CSV files to a project.
If you wanted to do a down and dirty way you could just save the CSV's somewhere on your local machine, and then hard code the file path to that location.
Example:
c:\test\Dog.csv and then set that as a variable for whenever you need to read in the csv file.

VS2015 Express & VS2017: Document cannot be opened: It has renamed, deleted or moved

Hey I know people have started forums already concerning this problem.
I'm trying to create a SFML project template in VS2015 Express (I've also tried it in VS2017). I've followed many guides and answers to this problem on here, MSDN forums and others.
No matter what I try, the project template cannot open up my source and header files from the original project I created the template from. "Document cannot be opened: It has renamed, deleted or moved."
I'm working with/on:
Win10 PC; 64-bit
VS Express 2015 for Windows Desktop; v. 14.0.25431.01 Update 3
VS 2017; v. 15.3.5 (rather use VSE 2015 though)
What I've tried:
- Opening the MyTemplate.vstemplate file in texteditor, adding true in TemplateData;
adding: filename.cpp or
filename.h, replacing the filename with the .cpp and .h filenames in the TemplateContent section
unchecked Automatically import template when exporting template
unzipping, adding source files, rezipping and placing zip file in Templates\Project Templates zipped and unzipped
adding new mentioned zip file above (with source files inc.) into My Exported Templates folder
haven't deleted Properties folder in MyTemplate.vstemplate bc I couldn't find a file there?
I've been at my desk for around 3 hours and have hit my first roadblock, I don't know what to do. Please assist, guys.
EDIT: Found the problem; although the original .cpp and .h files aren't being added into the exported template.
When I create a new project using my custom template, the source files (from the original project used to create the template) are not automatically added into the new project's files. So I have to manually copy the files from my original project to the new project's folder.
Any way to have the original source files added into the new project's files so I don't have to this manually every time?
I know this is pretty old but I'm going through the same thing and it was driving me crazy. So I figured out how to edit the project template to make it work.
I used Winrar, but I'm sure there's a bit simpler approach but here it goes:
I went to C:\Users\MyName\Documents\Visual Studio 2015\Templates\ProjectTemplates
and opened my SFML template with winrar. I then copied all of my .h and .cpp files from the original project into the template. I did this with another instance of winrar by dragging and dropping the files.
Then, I edited the MyTemplate.vstemplate file. I added a new "ProjectItem"Line by copying and pasting one of the ones already there. For example:
<ProjectItem ReplaceParameters="false" TargetFileName="ReadMe.txt">ReadMe.txt</ProjectItem>
This was an original line and I copied it and edited it to match one of the files I added. For example, I changed ReadMe.txt to SFML.cpp in a new line.
I did this for all of the new files, saved it and then it worked!
Let it be noted that I did not extract the template .zip at any point.

Visual Studios 2012 Export Project Template with Files

I can export a project to a template just fine, however, things are missing in the new project.
My goal is to create a template for code testing that requires some custom project/build/linking configurations. I found that I can preserve all these custom settings in an exported project. In addition to these settings is a directory that contains a .dll and .lib file. I have my paths set up as $(ProjectDir)\supp\tester.dll
-and-
$(ProjectDir)\supp\tester.lib
in their respective locations for linking.
The problem is that when I export the project as a template, and create a new project from the template, I am missing the tester.lib file in the supp directory. I even tried unzipping the template file and adding the tester.lib file back to SUPP, and rezipping it. I still cannot create a project from the template that includes the tester.lib file. Only the tester.dll file is created.
Do I have to set something up to tell VS to include this file in the template??
Thanks!
I got it working, although I am not sure if it was the most correct solution.
I had to export my project, unzip the resulting template, copying the tester.lib file to the unzipped file, and manually edit the templates .vstemplate file by adding:
<ProjectItem ReplaceParameters="false" TargetFileName="tester.lib">tester.lib</ProjectItem>
under the <Project><\Project> section. I then rezipped the files and put it in the Templates directory in the Visual Studios user area. Project I create with this template now include both the tester.dll and tester.lib files.

git pull shows merge conlict in .cproject file

What is exactly the .cproject file?
I didn't add any new files to my project.
I didn't change any project properties.
Is it auto-generated?
Is it safe to take the remote version if I didn't touch this file explicitly?
add this file to your git ignore so it will not be added to the repository.
You can use this online tool for that:
http://gitignore.io/
or simply edit (or create) '.gitignore' it in your root folder with the following content:
.cproject
This file is auto-generated, which contains your project setting information. you can use a notepad to open it. Without this, you need to re-configure your project.

File with .cpp,v extension

I 've a c++ code. but its with .cpp,v extension. I want to debug and compile the code. Can anyone please throw some light on that topic. I want to know what v indicates? & how to debug the code?
It's a file from CVS or some related version control system. The files ending with ",v" are not the actual source files, rather these are housekeeping files used by CVS.
You will need to go back to the CVS repository and get the .cpp and .h source file(s).