I am currently enrolled in a C systems programming course, I want to use Xcode (instead of vi). What type of project do I create when I open Xcode?
You probably want Command Line Utility > Standard Tool. This will give you just the ordinary C environment you get on every other OS.
Mac OS X > Application > Command Line Tool. But I suspect you'd be be better off using vi, emacs, or something like TextMate. I'd guess that most C systems programming courses are going to use Makefiles.
Open xcode 6,
Create new project (file menu, new, then project...
Then you'll see a screen "choose a template for your new project"
Choose command line tool.
That's it. You could google creating a command line tool in Xcode, how do I... if you have any further queries.
If all you want is to write C code, you want a command line tool application.
Related
As you can see above I have 1 file in my program
second file is added.
When i try to execute one of my file i encounter with this problem
Can you please help me with this error.
Thank you.
I mentioned problem above
You have two main functions in your project, one in each file. A C program can have only one main function.
Remove one of the main functions or rename one of them to get the project to build.
If you're writing lots of short C programs, you shouldn't use Xcode. With Xcode you have to create a new project for each program. Use a text editor like Visual Studio Code, TextMate, or Sublime Text instead. Text editors like these have bundles you can install that let you build and run C programs from within the editor.
I'm trying to set up a simple project that will contain c source code. I can't find anything via google for newer versions of Xcode.
Best I could figure out is to create a new command line project and then manually add in a C program file. Is this the only method?
After selecting Command line app, hit next. Then be sure to select language type to "C" and then continue.
I am extremely new to programming and have found that a good majority of my mentors use Visual Studio to code in C.
I would like to get an early start using SAMS C Programming.
Can anyone please tell me how to create a .c file in VS 2017? I am only able to create a .cpp file at this time.
Thanks
What you most likely actually want to do is create a project. Go to File-> New-> Project. Most likely, the first programs you will write are console applications (meaning they appear on that screen that resembles an old computer monitor, or what some computer screens look like when booting). If you want to create a console application, go from Project to Visual C++-> Windows Desktop-> Windows Console Application. Ignore any additional pop-up windows and just keep clicking continue. A file called main.cpp will automatically be generated. This is the file you will want to use for your code examples (but DO NOT DELETE the #include "stdafx.h" line, even if your example code does not have it).
Visual Studio compiles both .c and .cpp files as C++ by default. C++ has nearly everything that C has, but may take longer to compile when dealing with huge projects. If you want to use strictly C with no C++, then go to Project (a separate project tab on the same toolbar as the file tab -- it isn't within the file tab)-> ProjectName(Your Project Name) Properties-> Configuration Properties-> C/C++-> Advanced and select "Compile As". You should see a square with a upside-down "^" in it. Click that and select "Compile as C Code (/TC)". The "/TC" is just what you would type in if you were using command-line arguments instead of the convenient window that appears for you to modify everything. Finally, rename main.cpp to main.c.
Since you're learning C, I would also like to mention that I started making a C tutorial on my web site (and if anybody else also happens to see this post and the tutorial, criticize the tutorial as harshly as you can in the comments below).
Click on File, Choose Project --> Visual C++ --> Windows Desktop and under Windows desktop Choose Windows desktop wizard and give project name in the bottom then click on OK. a pop of Windows Desktop Project will come, check empty project and uncheck all options.then click on OK after that in the right side along with your project name more options will come..right lick on source file-> add -> new items -> choose c++ plus file but in bottom give file with extension .c..and you are done .enjoy coding
If you are truly interested in learning to program in C, then leave the VS Code IDE for later and learn to Build C/C++ code on the command line. VS provides a reasonably good compiler (cl.exe) and pre-configured command line (command prompt) windows to build both 32 and 64 bit applications.
The benefit to using the command line is learning what the compiler options are and what they actually do. Simply open a VS command line window and type cl /help. The compiler will list all options along with a short description. There are a great number of resource for command line building that can be accessed through the link above.
A second benefit is you can rapidly compile all your beginning C examples without worrying about projects, etc.. Just cl /nologo /Wall /Ox /Foname.o /Fename.exe /Tc name.c and you are done. (you will want to suppress unneeded warning with individual /wdXXXX options where XXXX is the warning to suppress) 50 Times faster than using the IDE.
Once you are proficient in using the command line, you will have a much easier time transitioning to the IDE -- because you can properly configure the IDE with the appropriate options for your build and you will know what the IDE is doing under the hood (or should be doing under the hood)
For normal cocoa applications it's easy to create an .app file. But what do i have to do to create an .app file from an command line project. I know that it usually doesn't make sense to create an .app from an command line tool, but in this case im using GLFW (an OpenGL lib) to create an Window. Or what would be the correct way to set up an c/c++ project and create an .app file from that project?
I hope you do understand what i mean, if not please ask.
On OS X, there is no difference between command-line programs and application executables--there is only one kind of executable. This is the same way other Unix systems like Linux work, but different from Windows. OS X "application bundles" are just a certain way of packaging up an executable with related resources in a directory tree.
The easiest way to create a application that uses GLFW in Xcode is to create a Cocoa application project, then delete all references to Cocoa from the target. Delete the reference to the Cocoa framework, delete all the source code the template created, delete the MainMenu.xib, et cetera. You will need to leave the Info.plist intact as this is an essential part of OS X application bundles.
This actually is not as unreasonable as you think, .app is just a special kind of "bundle" on OS X.
You can easily package this up yourself, but you need to know the proper file structure. In fact, virtually all the software I write for OS X is actually done this way; I am not a fan of the Xcode IDE.
Here is a general overview. The Info.plist file is the most important thing to focus on.
I am interested in programming for the Game Boy Advance using the Visual HAM IDE in C. However, every time I build a project I get a message stating:
'make.exe' is not recognized as an internal or external command,
operable program or batch file.
I downloaded GnuWin32 and make. Then, inside the ham visual editor I clicked advanced, options and set the directory of the MAKE_MODE (I guess some kind of environment variable) to the directory where the make program is.
Any suggestions on how to get this to work?
I had the same problem. Reinstall the hole vham package to the desired destination from the get-go. You can find it here: www.jharbour.com/gba/ham-280-full-win32.zip
You can't move the folders around. Even if you change the PATH variables this problem will persist.
Find where on your system the make program is in. Probably in cygwin's /usr/bin. Add that path to your system dos path.
Windows with cygwin is a screwed up hybrid system. You probably have three paths going on at once. You have the cygwin one. If you open a cygwin shell and type make I bet it finds the make program. Then if you open a dos shell ( in accessories/command prompts ) I bet it won't find the make program.
You will need to add it. Every version of windows does this differently but it is generally under right click on my computer/properties/advanced/environment variables. You will need to add it there.
And finnally there is the path known to your ide (probably). I don't know HAM, but it looks like you already did whatever they told you.
When you are done you should be able to invoke "make" from the windows/dos command prompt.