Is it possible to run compiled C and C++ Files on a mac without opening and running it in terminal?
E.G is there a separate GUI i can use for executing compiled c programs?
Have a look at Pashua.
Terminal IS a GUI; it provides you with access to the shell while you're still in the window system. I don't know what you'd want this other GUI to do that Terminal isn't doing for you. You would still need to provide the file path to this other program, which it would then load for execution, and it would still need to open standard input / standard output, etc.
If you have the source code, however, you can use an IDE. Eclipse works well for that, but there are plenty of others.
You can run/develop C/C++ programs in XCode on Mac OS X. From within XCode its cmd-B to build, cmd-enter to run. XCode is the Mac IDE which you can download or its comes as an optional install or your Mac OS install disks.
XCode also supports code completion - hit ESC.
Also see: Working comfortably in C using Eclipse
Related
I am trying to compile C code on a Mac (M2), with as target windows. I have tried this in the past on linux, with success, but there doesn't seem to be a straightforward way on Mac.
On the linux machine I was able to get a whole range of cross compilers from GNU, they had the system headers built in, so it was really really simple, something like
gcc-...-mingw main.c -o main.exe
would create a simple windows executable. From there it was as simple as moving the main.exe file to a usb drive or cloud to and transfer it to a windows machine to run it. Really simple!
For Mac I have found some resources about Clang, but you need to provide the system headers yourself, which I have no idea how to do. And there is more setting up, which I don't want to get into if there is a solution as simple as the one I just showed.
My question: What is the way to compile a C program on a Mac with the target system being windows, or even Linux?
Thanks for the help!
Visual Stdio Code has support for various C compilers native for M2. It isn’t a full IDE, simply a code editor with extensions.
You should be able to download the plugins/extensions you need via the GUI interface and let it manage the environment.
I am learning C at the moment and my university requires me to use a Virtual Maschine running Linux using VirtualBox. If I write a c program in my compiler (Codeblocks) on my Windows operating system, I do not know how I could execute the written C file.
At this website: https://www.howtogeek.com/189974/how-to-share-your-computers-files-with-a-virtual-machine/ I have seen that this can be done by "Insert Guest Additions CD image" and then adjusting "shared folders" in the settings.
Would this be the right approach? Can you give some examples of how I would then execute the code in the VM?
Thank you for your help!
First you need to compile it inside linux using clang or gcc because the windows version of codeblocks will compile it for windows, then the simplest solution is just cooy/paste the source code on linux or doing shared folders it is simple you go to the virtual box setting and install virtualbox guest additions and also install it inside the virtual machine, but what i would do is just do the whole thing in linux :)
The link you give shows how to share files between your native OS and the virtual machine. This is a perfectly acceptable way to transfer a file which is already in Windows. However, it would be much simpler to create the file in the VM in the first place. I suggest you learn how to use vim or emacs to edit your code files in Linux.
I'm studying computer engineering and we have a class called operating systems where they lecture us about how OSes handle stuff etc. This week we were given a homework which requests us to code a shell that works on Linux. The problem is, they tought us literally nothing on how to code a shell so we are supposed to do some research and figure it out.
I found this guide online and it seemed perfect to me: link
Code, with explanations, what else could I ask for.
Now, I'm using a Windows PC and I use Dev-C++ IDE with GCC compiler. Can I code a shell that works on Linux with my current setup or do I have to install Linux? Are there any major differences between how shells run on these OSes?
If you want to write a shell for Linux, you want to target GNU/Linux which is basically POSIX with some extensions.
Dev-C++ by default uses MinGW GCC as its compiler, providing a Win32 API.
Win32 and POSIX are completely and fundamentally different. A shell written for one will not even slightly resemble the other.
Instead, you have several options:
Dev-C++ can optionally use Cygwin GCC, providing a more GNU/Linux-like experience on Windows. You need to take great care not to rely on any Cygwin-specific functionality like how it automatically translates pathnames and line terminators. You'll still need access to a Linux install to verify that it works.
Windows 10 lets you install WSL, a more modern Linux compatibility layer for Windows. Dev-C++ doesn't explicitly states it support it, so you may need to edit and compile separately, and may lose debugging functionality. You'll still need access to a Linux install to verify that it works.
Just run Linux in a VM. The only thing to care about is getting your shell working.
I would suggest saving yourself a ton of trouble right now and just download/install an Ubuntu image in VirtualBox.
I'd like to provide a program, for example a Python script, that can be run on platforms including Linux, Mac, and Windows. I want the program to read the content of a few files in the directory, and create a new file in that directory based on the content. Specifically, I want the program to find file1.txt and file2.txt, and create a new file file3.txt which is a concatenation of the first two files.
I might provide a Python script to a Linux user, and the user can run
python script.py
However, Windows does not have Python. What other choices of programs do I have that will allow it to be run on these platforms, without the user having to install anything extra?
You could use C++, but then you'd have to compile for each platform, which is sometimes more work than you'd like.
Most systems have some form of Java installed already, which could work.
Python runs on Windows, Mac and Linux, the user would just need to install it.
I am not aware of anything that will run on all OSes without any extra work. However, Java may be a good choice as it is commonly installed. You could use C++ but you would have to compile it on each machine you would like it to work on (Windows, Mac, Linux) you would also have to make sure you don't use any library that does not transfer to the other OSes.
I have been using Textmate for writing my C source but want to do everything via the terminal.
How does one program via the terminal? Is anything else needed, installed?
In order to write source code on the Terminal, you will of course need an editor that works on the Terminal. In OS X, you have a lot of options to choose from. If you want simple and easy to use editors, you may want to try nano and pico that are available on OS X. If you start to want a little or more functionality out of the text editor, then you may want to try editors like vim and emacs, which are also available under OS X.
In order to compile your C source, you will require a C compiler. While OS X does not, by default, come pre-installed with a C compiler, you can quickly install a slew of development tools that are available in the OS X installation discs that you may have got when you bought your Mac. Those tools will provide you with gcc -- which is the GNU C compiler that you can use on the Terminal to compile your C sources --, gdb -- which is the GNU Debugger that you can further use to debug your compiled C source --, make -- which is GNU make, a program that, when you start to have to manage a number of C source files, can help you by creating make files and automating build operations -- and a number of other tools that you may want to explore as you spend more time with the system and become familiar with it.
You can use emacs or vi. vi is included in osx by default.
You can use a terminal text editor such as vim or emacs. You may also need to install gcc.
All these programs are available through any ports system.