I'm jus following the tutorial. It demonstrates the use of Graphics. It says
[Windows users: For this example to work interactively on Windows, you
will need to create a custom toplevel. Issue the command ocamlmktop -o
ocaml-graphics graphics.cma from the command line.]
I don't exactly what it means.
I have corresponding source code in "D:\MySourceCode\OCaml\2.Graphics.ml". My cmd has entered OCaml environment. Now what should I do?
On my machine OCaml is installed in C:\OCaml and its libraries to C:\OCaml\lib. If I change directory to C:\OCaml\lib and execute C:\OCaml\bin\ocamlmktop.exe -o graphics-toplevel.exe graphics.cma I get graphics-toplevel executable with built-in Graphics module. I can use Graphics.open_graph "640x480" directly without loading OCaml Graphics library.
Related
I want to run a Lua file on Mac through the Terminal. Python and Java have their own respective commands, but how can I run a script file for Lua on a Mac OSx through a Terminal command? I'm fairly new to the Terminal but have some experience in Lua, and can anybody help me? It would be greatly appreciated, thanks! 😃
From the terminal:
brew install lua (This installs the lua interpreter)
lua yourfile.lua (This runs yourfile.lua in the interpreter)
Disclaimers:
There are installation alternatives to brew. Google lua installation macos and use what feels most comfortable to your flow.
You could also use a shebang on the first line and make the file executable. There is more than 1 option available here. The one listed above is the best to get going fast and easy.
From https://www.lua.org/start.html
To run Lua programs on your computer, you'll need a standalone Lua
interpreter and perhaps some additional Lua libraries. Use your
favorite text editor to write your Lua programs. Make sure to save
your programs as plain text. If you want an IDE, try ZeroBrane Studio.
If you use Linux or Mac OS X, Lua is either already installed on your
system or there is a Lua package for it. Make sure you get the latest
release of Lua (currently 5.4.1).
Lua is also quite easy to build from source, as explained below....
From the Lua FAQ
... Chapter 1 of the book Beginning Lua Programming contains detailed
instructions for downloading, building, and installing Lua. Here are
simple instructions for Linux and Mac OS X:
curl -R -O http://www.lua.org/ftp/lua-5.4.1.tar.gz
tar zxf lua-5.4.1.tar.gz
cd lua-5.4.1
make all test
I suggest you also read that Chapter 1 or ideally the entire book and of course the Lua reference manual.
Once you have the Lua standalone interpreter installed you simply run it like any other command line executable
Once you have Lua installed, such as through the brew command mentioned before, you can make your script run in terminal with these few steps:
#! /usr/bin/env lua -- add hashbang header to script
chmod +x *.lua -- make your script executable
./scriptname.lua -- run it
Upon finishing a COBOL program, how do I compile it into an executable file that may be run on other PCs? I'm using OpenCOBOL via cygwin.
Check out this getting started page from the user manual for OpenCOBOL:
But in case the link is broken, just do this:
$ cobc -x hello.cob
$ ./hello
cobc is the compiler. hello.cob is the source file. The output is simply the file hello which can be run by calling ./hello. The -x option is necessary to build an executable.
However, with all compiled programs, it is compiled for the machine is was built on. It will work on machine with similar architectures, but you don't true cross-platform ability unless you're using an interpreted language like Python or Java.
If you compile with Cygwin, the target computers also need Cygwin, or in particular the cygwin dynamic libraries along with the OpenCOBOL runtimes.
Many times, you can also compile under MinGW, which lessens the dependencies, but also lessens the available POSIX features.
Easiest path, install OpenCOBOL and Cygwin on the target machines, and you'll be good to go, otherwise you'll need to produce release packages with all the dependencies and instructions for PATH settings.
I need to use the objdump and readelf commands in my application that runs on windows. I know I can install cygwin in order to use them. The reason why I don't want to use cygwin is because I want to make it essay to deploy. Plus I don't know how to make a silent install of cygwin. As a result I believe that what I need is GNU Utilities For Win32 as the link states those libraries are serverless. "executables do only depend on the Microsoft C-runtime (msvcrt.dll) and not an emulation layer like that provided by Cygwin tools"
Anyways once I go to that link I don't know how to install it. Specifically I will like to use >this tool<
I will appreciate if someone can point me on the right direction of how I will be able to use objdump and readelf (binutils in cygwin) on my application.
they are already compiled and they can be downloaded from here!
Once downloaded they will be located in the bin directory:
and then you will use it the same way you use it on linux by passing the same args.
I've read http://dinosaur.compilertools.net/bison/bison_5.html#SEC25. But following those instruction i can not compile my yacc file using bison
How do i compile my file in windows 7 ... ?
Please help me to do this.
There is a common reason why bison will not operate properly on Windows and is mentioned in the install instructions but often overlooked. It is important that the name of the location of the directory that bison (and flex) is installed in (the path) does not contain a space. in particular this means that it cannot be placed under C:\Program Files\. The problem is that this directory might be suggest as the default install location. It is sometimes necessary to manually change the default to somethings else (like C:\GnuWin\ or similar). It is also usually necessary to manually add the appropriate directory to the PATH environment variable. Once this has been done there should be no problems in running bison and flex from the command prompt. It would normally be used in the following way:
flex lang.l
bison lang.y
gcc -o lang.exe lang.tab.c -lfl
It is not necessary to install MinGW, Cygwin or use Powershell or a VM or use linux as indicated by #DavidHefferman
If you still can't get it right, I even have an instructional video!
Using those Unix commands in Windows PowerShell might work, but I'm not sure and I'm currently not on Windows, so I can't check it.
If that fails you could try installing Cygwin (a basic Linux environment in Windows). You'd have to select the bison package during installation. It comes with its own shell that you can use.
Actually my personal favorite when programming under Windows is setting up a virtual machine with VirtualBox. That way you could use a real Linux environment without actually leaving Windows.
Good luck!
I am using Cygwin and have GCC (version 4.3.4 20090804 (release) 1 ) installed as Cygwin package.
When I built C code using GCC under Cygwin shell, the generated executable output file is a executable of type (PE32 executable for MS Windows (console) Intel 80386 32-bit) and it can only be executed/run under Cygwin shell, not as standalone .exe on Windows shell/command prompt. If I try to run it standalone on Windows command prompt it gives an error window saying "The program can't run because cygwin.dll is missing from your computer".
How can one make this .exe standalone, which can be executed on a command prompt of any other system or even in my own system?
I thought GCC under Cygwin would build a Linux executable (ELF 32-bit LSB executable), but it's not so. How can I use the gcc-cygwin combination to generate a *.out kind of Linux executable file?
Also, I cannot run a Linux executable generated on a Linux-gcc combination to execute under Cygwin.
Any pointers would be helpful.
Despite widespread rumours, Cygwin is not a Linux emulator, i.e. it doesn't produce or run Linux executables. For that you'll need a virtual machine or coLinux.
Instead, Cygwin is a compatibility layer, which aims to implement as much as possible of the POSIX and Linux APIs within Windows. This means that programs have to be compiled specifically for Cygwin, but it also means that it's better integrated with Windows, e.g. it lets you mix POSIX and Windows APIs in the same program.
It's the cygwin1.dll that provides that compatibility layer. If you build non-Cygwin executables using gcc-3's -mno-cygwin switch or one of the MinGW compilers, then of course you can't use any POSIX/Linux-specific APIs, and any such calls will need to be replaced with Windows equivalents.
Cygwin is an emulation layer. It allows UNIX code to run on Windows, if you compile it to use the emulation layer. To Windows it looks like any normal DLL and makes OS calls as normal. But when you compile against it, it shows the same functions as UNIX (well, POSIX technically, but UNIX it is)
1) When you build with cygwin, it automatically brings in this cygwin1.dll. This is the code that you need to make it look like UNIX. There are flags to make it not use this cygwin dll, meaning ignore the UNIX stuff and use native Windows calls. the -mno-cygwin flag will make the binary a native Windows binary, not using cygwin emulation. As others have said, you also need the -mwindows to make actual GUI apps using cygwin gcc.
2) To compile on one platform to run on another platform, you need what's called a cross compiler. You also need the libraries and headers for the other system. For what you want you'd need a cygwin-Linux cross compiler, Linux headers and libraries. It would probably be much easier to run Linux in a virtual machine than to set this up.
3) Remember that Cygwin just looks like UNIX to UNIX source code, not to Linux binaries. Once you compile things, the function calls are windows DLL calls. A cygwin program is still a Windows program (which is why you need a Windows style DLL to run it). Cygwin provides code for UNIX functions/system calls such as fork(), but even the method of calling them is now different. fork() now calls into a Windows DLL, not into a Linux kernel. It's still a very different system.
Not a complete answer, but I think I am able to give some pointers.
1) http://www.cygwin.com/cygwin-ug-net/programming.html says you should use -mswindows parameter. Take a look of MinGW.
2) You need a cross gcc to do this. By default cygwin gcc produces binaries linked against cygwin.dll.
3) That it because it is a linux binary. Easiest way is to recompile software in cygwin.
ad 1) There are currently three different mingw cross-compilers available for cygwin:
The old gcc3 -mno-cygwin is deprecated.
There are new mingw64 cross-compilers for 32 bit (mingw64-i686-gcc) and 64 bit windows targets (mingw64-x86_64-gcc).
There's no mingw-i686-gcc matching the official cygwin gcc4 compiler yet.
ad 2) There's no linux cross-compiler as cygwin package yet available. But people report success building such a cross-compiler by themselves.
ad 3) There's no cygwin cross-compiler as linux package available, but many mingw cross-compilers. Those mingw executables can also be executed under cygwin, though they cannot use cygwin features, just the simple windows runtime.
Correcting errors in others people posts:
-mswindows is not valid, -mwindows tells the linker to generate a GUI app without console.
-mno-cygwin is only valid for the old deprecated gcc3 compiler and is not supported anymore. Don't use it. With cygwin you should use ordinary host and target triples as with every other cross-compiler.
You need to have cygwin.dll in your path.
Or just use MinGW to compile native windows code without dependencies.