Compiling Erlang code on Windows - windows

I installed Erlang 13B and tried to follow the tutorials.
Every time I get to c(tut), I get an error instead of (ok, tut), so it seems like there are no modules installed. Can anyone point me in the right direction?
I've tried Emacs but I don't really know how to use it and haven't even got close to getting the Erlang mode working. For instance, where do I type:
(setq load-path (cons "C:/Program Files/erl5.6.2/lib/tools-<ToolsVer>/emacs"
load-path))
(setq erlang-root-dir "C:/Program Files/erl5.6.2")
(setq exec-path (cons "C:/Program Files/erl5.6.2/bin" exec-path))
(require 'erlang-start)

For c(tut) to work, there has to be a tut.erl file in the current directory.
This is easy to accomplish if you start the Erlang interpreter from the command line, as is common on systems like Linux and OS X, but this isn't the usual pattern on Windows. When you start Erlang on Windows from the icon in the Start menu, the current working directory defaults to the location of werl.exe, which isn't where your tut.erl file is.
To make your command work as expected, you have to change your working directory to be the location of tut.erl after starting the Erlang shell. If tut.erl is on the Desktop, the command will be something like this on Vista or Windows 7:
cd("c:/Users/myname/Desktop").
(Yes, you have to use forward slashes. Backslashes are special in Erlang strings.)
On Windows XP and older, your Desktop folder is buried much deeper. It might be simpler to put werl.exe in the system PATH and use the command line on such systems.
It isn't necessary, but you might want to consider installing Cygwin. Its Bash shell will give you a more Linux or OS X like environment, which will help you work with other tutorials that are structured for those OSes.

After you install Erlang open the shell and do:
1> pwd().
C:/Program Files/erl5.7.1/usr
ok
2>
Assume you have a file; "tut.erl" on your desktop. Content might look like this:
-module(tut).
-compile(export_all).
hello_world() ->
hello.
You must change the path of the current working directory to the desktop first (or where ever you want to do the compile). Like this perhaps:
2> cd("F:/Desktop").
F:/Desktop
ok
3>
Then you can perform the compile.
3> c(tut).
{ok,tut}
4>
Then test the module
4> tut:hello_world().
hello
5>
More info refer to the documentation here: Erlang official documentation
More info on the shell, look here: Shell module
Hope this gets your started.

You can also create an initialization file named .erlang under YourErlangInstallationPath\usr\
the content of the file should look something like this;
io:format("consulting .erlang in ~p~n" ,
[element(2,file:get_cwd())]).
%% Edit to the directory where you store your code
c:cd("O:/Erlang.Umut").
io:format("Now in:~p~n" , [element(2,file:get_cwd())]).
it will automatically change the path to your working folder. (Obviously, my path is O:/Erlang.Umut, you need to replace it with yours.)
No need to change folders every time you launch console. Console will be able to reach your erl files directly.

I recently tried Erlang on windows.
use the console window to make sure the text editor you are using is giving your files the correct extension ie. filename.erl and not filename.erl.txt like mine was!
when I saved my files in notepad it added .txt so I saved in unicode. fixed

If you are still getting "tut:erl:none: no such file or directory", the file name is wrong. If you open a Windows command prompt and move to your desktop and type "dir" you will see that tut.erl is really named tut.erl.txt. type "ren tut.erl.txt tut.erl" and now your compile will work.

When werl's current working directory is same as the file to be compiled, the filename is given as an argument without the whole path.
Otherwise, for eg. Assuming tut.erl is placed at C:\ErLang tutorials, one may try compiling as,
c("C:\\ErLang tutorials\\tut").
Note:
Without double quotes the : causes syntax error
The backslash is given using escape sequence

Related

Makefile.mak giving error [duplicate]

I have Windows 7 and tried to use the 'make' command but 'make' is not recognized as an internal or external command.
I did Start -> cmd -> run -> make, which outputs:
'make' is not recognized as an internal or external command,operable program or batch file.
Then I typed 'mingw32-make' instead of 'make' (Start -> cmd -> run -> mingw32-make) and I get the same output:
'mingw32-make' is not recognized as an internal or external command,operable program or batch file.
What shall I do next in order to fix this problem?
In Windows10, I solved this issue by adding C:\MinGW\bin to Path and then called it using MinGW32-make not make.
Your problem is most likely that the shell does not know where to find your make program. If you want to use it from "anywhere", then you must do this, or else you will need to add the full path each time you want to call it, which is quite cumbersome. For instance:
"c:\program files\gnuwin32\bin\make.exe" option1=thisvalue option2=thatvalue
This is to be taken as an example, it used to look like something like this on XP, I can't say on W7. But gnuwin32 used to provide useful "linux-world" packages for Windows. Check details on your provider for make.
So to avoid entering the path, you can add the path to your PATH environment variable. You will find this easily.
To make sure it is registered by the OS, open a console (run cmd.exe) and entering $PATH should give you a list of default pathes. Check that the location of your make program is there.
This is an old question, but none of the answers here provide enough context for a beginner to choose which one to pick.
What is make?
make is a traditional Unix utility which reads a Makefile to decide what programs to run to reach a particular goal. Typically, that goal is to build a piece of software from a set of source files and libraries; but make is general enough to be used for various other tasks, too, like assembling a PDF from a collection of TeX source files, or retrieving the newest versions of each of a list of web pages.
Besides encapsulating the steps to reach an individual target, make reduces processing time by avoiding to re-execute steps which are already complete. It does this by comparing time stamps between dependencies; if A depends on B but A already exists and is newer than B, there is no need to make A. Of course, in order for this to work properly, the Makefile needs to document all such dependencies.
A: B
commands to produce A from B
Notice that the indentation needs to consist of a literal tab character. This is a common beginner mistake.
Common Versions of make
The original make was rather pedestrian. Its lineage continues to this day into BSD make, from which nmake is derived. Roughly speaking, this version provides the make functionality defined by POSIX, with a few minor enhancements and variations.
GNU make, by contrast, significantly extends the formalism, to the point where a GNU Makefile is unlikely to work with other versions (or occasionally even older versions of GNU make). There is a convention to call such files GNUmakefile instead of Makefile, but this convention is widely ignored, especially on platforms like Linux where GNU make is the de facto standard make.
Telltale signs that a Makefile uses GNU make conventions are the use of := instead of = for variable assignments (though this is not exclusively a GNU feature) and a plethora of functions like $(shell ...), $(foreach ...), $(patsubst ...) etc.
So Which Do I Need?
Well, it really depends on what you are hoping to accomplish.
If the software you are hoping to build has a vcproj file or similar, you probably want to use that instead, and not try to use make at all.
In the general case, MinGW make is a Windows port of GNU make for Windows, It should generally cope with any Makefile you throw at it.
If you know the software was written to use nmake and you already have it installed, or it is easy for you to obtain, maybe go with that.
You should understand that if the software was not written for, or explicitly ported to, Windows, it is unlikely to compile without significant modifications. In this scenario, getting make to run is the least of your problems, and you will need a good understanding of the differences between the original platform and Windows to have a chance of pulling it off yourself.
In some more detail, if the Makefile contains Unix commands like grep or curl or yacc then your system needs to have those commands installed, too. But quite apart from that, C or C++ (or more generally, source code in any language) which was written for a different platform might simply not work - at all, or as expected (which is often worse) - on Windows.
First make sure you have MinGW installed.
From MinGW installation manager check if you have the mingw32-make package installed.
Check if you have added the MinGW bin folder to your PATH. type PATH in your command line and look for the folder. Or on windows 10 go to Control Panel\System and Security\System --> Advanced system settings --> Environment Variables --> System Variables find Path variable, select, Edit and check if it is there. If not just add it!
As explained here, create a new file in any of your PATH folders. For example create mingwstartup.bat in the MinGW bin folder. write the line doskey make=mingw32-make.exe inside, save and close it.
open Registry Editor by running regedit. As explained here in HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER go to \Software\Microsoft\Command Processor right click on the right panel New --> Expandable String Value and name it AutoRun. double click and enter the path to your .bat file as the Value data (e.g. "C:\MinGW\bin\mingwstartup.bat") the result should look like this:
now every time you open a new terminal make command will run the mingw32-make.exe. I hope it helps.
P.S. If you don't want to see the commands of the .bat file to be printed out to the terminal put #echo off at the top of the batch file.
If you already have MinGW installed in Windows 7, just simply do the following:
Make another copy of C:\MinGW\bin\mingw32-make.exe file in the same folder.
Rename the file name from mingw32-make.exe to make.exe.
Run make command again.
Tested working in my laptop for above steps.
For window-10 resolved error- make' is not recognized as an internal or external command.
Download MinGW - Minimalist GNU for Windows from here https://sourceforge.net/projects/mingw/
install it
While installation mark all basic setup packages like shown in image
Apply changes
After completion of installation
copy C:\MinGW\bin
paste in system variable
Open MyComputer properties and follow as shown in image
You may also need to install this
https://sourceforge.net/projects/gnuwin32/
As other answers already suggested, you must have MinGW installed. The additional part is to add the following two folders to the PATH environment variable.
C:\MinGW\bin
C:\MinGW\msys\1.0\bin
Obviously, adjust the path based on where you installed MinGW. Also, dont forget to open a new command line terminal.
'make' is a command for UNIX/Linux. Instead of it, use 'nmake' command in MS Windows. Or you'd better use an emulator like CYGWIN.
Search for make.exe using the search feature, when found, note down the absolute path to the file. You can do that by right-clicking on the filename in the search result and then properties, or open location folder (not sure of the exact wording, I'm not using an English locale).
When you open the command line console (cmd) instead of typing make, type the whole path and name, e.g. C:\Windows\System32\java (this is for java...).
Alternatively, if you don't want to provide the full path each time, then you have to possibilities:
make C:\Windows\System32\ the current working directory, using cd at cmd level.
add C:\Windows\System32\ to you PATH environment variable.
Refs:
use full path: http://technet.microsoft.com/en-us/magazine/ff678296.aspx
cd: http://technet.microsoft.com/en-us/library/cc731237.aspx
PATH: http://technet.microsoft.com/en-us/library/bb490963.aspx
I am using windows 8. I had the same problem. I added the path "C:\MinGW\bin" to system environment variable named 'path' then it worked. May be, you can try the same. Hope it'll help!
try download & run my bat code
======run 'cmd' as admin 2 use 'setx'=====
setx scoop "C:\Users%username%\scoop" /M
echo %scoop%
setx scoopApps "%scoop%\apps" /M
echo %scoopApps%
scoop install make
=======Phase 3: Create the makePath environment variable===
setx makePath "%scoopApps%/make" /M
echo %makePath%
setx makeBin "%makePath%/Bin" /M
echo %makeBin%
setx Path "%Path%;%makeBin%" /M
echo %Path%
use mingw32-make instead of cmake in windows

emacs' org-cdlatex-mode, where do you put the cdlatex.el script?

Does anyone know where to put the cdlatex.el script written by C. Dominik to allow swift LaTeX math insertion within an *.org file? CDLatex is a minor mode that can work with Org-mode, at least that's what I gather.
I've followed the instructions given [in this link] but when I type M-x org-cdlatex-mode RET I get "Cannot open load file: no such file or directory, cdlatex" in the Emacs' echo buffer. What does it mean? I've also tried looking for a package named "cdlatex" in the list of packages (M-x list-packages) but there wasn't any. How do I get this minor mode activated in Org?
I'm running Windows 7, Emacs 24.1, Org-mode 8.2.10, AUCTEX 11.88, TexLive 2015. At least another user has this same problem, please check this address.
My emacs working path file is C:\home\.emacs.d\. Do I put the script in C:\home\.emacs.d\elpa\? Inside the ~\.emacs.d\elpa\ I also have yasnippets and auctex directories, among others. Here's a snapshot:
Put the cdlatex.el script in one of the Load paths. To find all the load paths type C-h v RET load-path RET, then pick one and place the script in there. Restart emacs (or the machine if you prefer) and try out the CDLaTeX mode in one of the *.org files by enabling it either through menu or keyboard command:M-x org-cdlatex-mode RET.
Unfortunately for me there's some configuration problem because every time I type backquote or backtick (`), Org doesn't seem to recognize it when in CDLaTeX mode. It says: "Wrong type argument: characterp, 134217782"

Emacs init file won't load at start up

I'm trying to run Emacs v22.2 on a Windows 7 computer. However, the init file isn't loaded at start up (loading it manually with M-x load-file works fine).
I've tried using both:
~\.emacs, ~\_emacs
~\.emacs.d.init.el
but the problem persists.
Evaluating (insert (getenv "HOME")) returns the expected value.
Depending on how you open emacs in Windows 7, it will look in different places for the .emacs file. If call it from within a shell (in cygwin, Msys, etc) it will look in the $HOME (~) location, if you run it form the installation directory by clicking on the icon, it looks for this file in the %APPDATA% location ( usually C:\Users\your user name\AppData\Roaming ). This can lead you in a merry chase all over the place. I found that it is best to determine where you want the file to be stored, and the create symbolic links ( using windows mklink utility ) to all other possible locations.
I faced a similar issue(on windows 10). The problem was that Emacs was reading ~\.emacs instead of ~\.emacs.d\init.el on startup. Shifting the contents of ~\.emacs to ~\.emacs.d\init.el and deleting ~\.emacs solved the issue.
I just installed the patched version of Emacs on Windows 7, specified the environment variable HOME=c:\klang, checked out my decade old configuration files from github and added
(and (= emacs-major-version 23)
(defun server-ensure-safe-dir (dir) "Noop" t))
to ~/.emacs.d/init.el and was up and running.
What you are missing is some component from mule.el, just install the new version of emacs to fix it.
If HOME is not set in the genereal environment, (getenv "APPDATA") will probably take over and emacs will try to read your init file somewhere under that directory.
I've just managed to solve the same problem (lcollado and klang's answer gave me a small hint on how to fix it).
I had set up a configuration file at C:\Users\Edwin\.emacs.d\init.el and when I tried to get Emacs to load it, it didn't. My initial thought was to make an init.el file at C:\Users\Edwin\AppData\Roaming\.emacs.d\init.el which would load my original configuration file. However, I wanted a simpler solution.
Then I remembered that Symbolic Links exist. So I did a few searches on how to make a symbolic link in Windows and the difference between Hard Links and Soft Links.
My first attempt was to make a soft link that pointed to my init.el. But Emacs ignored the link and started without the init.el.
The next attempt that did work was a hard link. The steps that I did was as follows:
Open Command Prompt with Administrative Privileges.
a. Press Windows + R.
b. Type "cmd.exe" and press Shift + Enter.
c. Tap "Yes" when Windows asks for Administrative Privileges.
Go to your home directory.
a. Type cd C:\Users\<your name>.
Run the following command to make a hard link in C:\Users\<your name>\AppData\Roaming\.emacs.d\init.el:
:: mklink /h Destination Source
:: Destination - Where do you want the hard link to be and what will be it's name?
:: Source - What file do you want to link?
mklink /h AppData\Roaming\.emacs.d\init.el .emacs.d\init.el

What's the difference between "./" and "open" in Terminal and how could run a Unix executable from XCode?

I'm new in all these and I would like to excuse me for my ignorance..
I have a unix executable file. I run through terminal with command: open programname --args argument and it responds that can't find the resource file(which is the argument that I'v passed.)
I tried by writing: ./programname argument and it works.
Firstly, I would like to know the difference between these two methods and why the first one doesn't work, while the second works.
The problem that I have now is that I can't do it in XCode. When a executable is running, it says that it can't find the resourse file. I passed an argument in executable by cmd+i to executable and adding the resource file as an argument.
Thank you for your potential answer..
open is the exact equivalent of double clicking on a thing in the Finder. So if you use it on a UNIX executable then the executable will launch but the current working directory won't be where the executable is located and won't necessarily be anything useful. However, you could also use it to open a .doc file or any other file type, to open a directory in the Finder, to open a URL in the finder, etc.
Launching an executable with ./name is a normal UNIX way to run the thing. The current working directory will be wherever you are when you type it. So that'll be the same directory as the executable is located in (unless you launch from elsewhere on the disk, e.g. by going down a directory and using ../name to launch the executable).
What you probably want to do is write code to get the path to the executable, and seek the specified file relative to that? You don't say what language you're working in, and annoyingly that's not something that's in the POSIX spec so it varies from OS to OS.
If you're in C or anything that can call C (so, C++, Objective-C, etc) then NSGetExecutablePath (ignore Google's desire to put an underscore before it, see e.g. this site) is quite probably what you want. If you're in Objective-C then NSString has some methods for automatically appending paths.
"open" is a command that works exactly as if you had navigated to a specific application via Finder and then double-clicked it.
./ is a way of running a particular file that's marked executable via chmod.
For example, you can run a Mac OS X application from the command line by entering "open /Applications/MyApp.app/". But it won't work if you do ./MyApp.app/ (assuming you're in the /Applications directory).
If you type "man open" into your terminal, you can read more details there.

Where can I find my .emacs file for Emacs running on Windows?

I tried looking for the .emacs file for my Windows installation for Emacs, but I could not find it. Does it have the same filename under Windows as in Unix?
Do I have to create it myself? If so, under what specific directory does it go?
Copy and pasted from the Emacs FAQ, http://www.gnu.org/software/emacs/windows/:
Where do I put my init file?
On Windows, the .emacs file may be called _emacs for backward compatibility with DOS and FAT filesystems where filenames could not start with a dot. Some users prefer to continue using such a name, because Windows Explorer cannot create a file with a name starting with a dot, even though the filesystem and most other programs can handle it. In Emacs 22 and later, the init file may also be called .emacs.d/init.el. Many of the other files that are created by Lisp packages are now stored in the .emacs.d directory too, so this keeps all your Emacs related files in one place.
All the files mentioned above should go in your HOME directory. The HOME directory is determined by following the steps below:
If the environment variable HOME is set, use the directory it indicates.
If the registry entry HKCU\SOFTWARE\GNU\Emacs\HOME is set, use the directory it indicates.
If the registry entry HKLM\SOFTWARE\GNU\Emacs\HOME is set, use the directory it indicates. Not recommended, as it results in users sharing the same HOME directory.
If C:\.emacs exists, then use C:/. This is for backward compatibility, as previous versions defaulted to C:/ if HOME was not set.
Use the user's AppData directory, usually a directory called Application Data under the user's profile directory, the location of which varies according to Windows version and whether the computer is part of a domain.
Within Emacs, ~ at the beginning of a file name is expanded to your HOME directory, so you can always find your .emacs file with C-x C-f ~/.emacs.
There's further information at HOME and Startup Directories on MS-Windows.
It should be stored in the variable user-init-file. Use C-H v user-init-file RET to check. You can also open it directly by using M-x eval-expression RET (find-file user-init-file) RET
Open the file like this in Emacs for Windows:
C-x C-f ~/.emacs
More information in the Emacs Wiki
On my Vista box it's in C:\Users\<USER>\AppData\Roaming\
Note that it may NOT be enough to just type Ctrl-x Ctrl-f ~/.emacs and create the file.
It may be that your Emacs application uses a different place to store your init file, and if so, then creating the file ~/.emacs simply creates a useless file which your Emacs application ignores.
Also, you may want to do more than just access the .emacs init file, but you may want to know where it is, i.e., its pathname.
To get at this there are two methods:
Easy way: type Ctrl + H V user-init-file Return
Slightly trickier way:
You can find out where your system is storing its own .emacs file by:
Click options and scroll down to "Set Default Font..."
Change the font setting and click okay
On the options menu, go down to "Save Options"
When the options are saved, the system saves its .emacs file,
and you can read the file path in the minibuffer at the bottom of the Emacs screen
In Windows 7 put your init.el file in C:\Users\user-name\AppData\Roaming\.emacs.d\, where user-name is your user/login folder.
Take care so your init.el file won't be named init.el.txt. This is something Windows does if you create your file with some editor like Notepad.
On versions of Emacs on Windows above 22, it seems to have moved to
~/.emacs.d/init.el
, ~ being the value of your environment variable HOME (see Control Panel → System → Advanced → Environment variables).
The file itself might not exist. In that case just create it.
You must create an emacs initialization file. One is not automatically created.
I had a similar issue and this answer tracks down what I did.
My issue was my ~/.emacs.el file was not loading. Strange because this has always worked for me.
This question/answer helped me but I had to put my init file in the %USERPROFILE%\AppData\Roaming\.emacs.d\init.el because this is apparently the default behavior on Windows.
To troubleshoot this, I ran the following in the emacs *scratch* buffer.
user-emacs-directory
"~/.emacs.d/"
When I saw user-emacs-directory was ~/.emacs.d, I simply moved my .emacs.el file to %USERPROFILE%\.emacs.d\init.el. But this still didn't work.
I continued with expand-file-name as shown below:
(expand-file-name user-emacs-directory)
"c:/Users/pats/AppData/Roaming/.emacs.d/"
Got to love how Windows works. (not) So I moved my emacs.el file to the %USERPROFILE%\AppData\Roaming\.emacs.d\init.el and this worked. The file was now being read. But I got other errors because my initialization file loaded other (personal emacs) files (in ~/myenv/emacs/*.el.
Warning (initialization): An error occurred while loading ‘c:/Users/pats/AppData/Roaming/.emacs.d/init.el’:
Hum... Seems like all my files ~/myenv/emacs/*.el would need to be moved in order for this to work but I didn't want to do that. Then I realized that because the HOME environment variable was not set, emacs was performing its default behavior.
SOLUTION
Once I set my windows HOME environment variable to %USERPROFILE% everything began to work like it has for the past 25 years. :-)
To set the HOME environment variable, I typed WindowsKey+"edit environment variables for your account" to open the Environment Variables dialog box, and entered HOME=%USERPROFILE%.
Now my emacs initialization file .emacs.el is is back to its rightful place $HOME/.emacs.el and not in %USERPROFILE%\AppData\Roaming\.emacs.d\init.el
To be fair, if Windows had just one place to put files for user installed packages the solution of making HOME=%USERPROFILE\AppData\Roaming might be acceptable, but because some applications use %USERPROFILE%, some use %USERPROFILE\AppData\Roaming and others use %USERPROFILE\AppData\Local it just makes it difficult to know where to find your configuration files.
I prefer having everything in my %USERPROFILE% or $HOME directory.
Another similar question was here:
Emacs init.el file doesn't load
As kanja answered, the path to this file is stored in the user-init-file variable (or if no init file exists, the variable contains the default value for where to create it).
So regardless of which of the possible init file names you are using, and which directory it is in, you should be able to visit your init file with:
M-: (find-file user-init-file) RET
Or display its full path in the echo area with:
M-: (expand-file-name user-init-file) RET
On Emacs 23 and Windows 7 it only works if you set:
HKCU\SOFTWARE\GNU\Emacs\HOME
After Emacs 27.1, emacs has started respecting the $XDG_CONFIG_HOME. The init file or the init directory can now be found in $XDG_CONFIG_HOME/emacs/init.el.
In Windows $XDG_CONFIG_HOME could translate to %LOCALAPPDATA%.
In any case you can use the following emacs variables to find out the location of the your initialization file by M-x eval-expression
user-init-file
or the emacs configuration directory
user-emacs-directory
I've found that Emacs 22 will occasionally open either "C:\Documents and Settings\username\Application Data\.emacs", or just "C:\Documents and Settings\username\.emacs" on my XP machine. I haven't found an explanation for why it occasionally changes it's mind.
~ will always point to whatever the current instance of emacs thinks is HOME, but kanja's tip (C-h v user-init-file) will always tell you what ~/.emacs actually maps to.
On Windows 8.1, if Emacs is started from Windows Explorer, a shortcut or from cmd console it uses C:\Users\<USER>\AppData\Roaming.emacs init file. When I start Emacs from PowerShell, Emacs looks for its init file in C:\Users\<USER> folder. The fix to this issue was to set the HOME user environment variable (Control Panel\System and Security\System->Advanced system settings->Advanced->Environment variables) to C:\Users\<USER>. After this change, no matter how I start Emacs, it uses the same init file (see the accepted answer of this question)
On Windows XP it's:
C:\Documents and Settings\yourusernamehere\Application Data\
There is a list of directories based on your Windows version and extra information:
http://www.gnu.org/software/emacs/manual/html_node/emacs/Windows-HOME.html
For WIndows7& Emacs26.3:
if HOME environment is set, then the .emacs file should be in that folder.
otherwise, it should be in c:\.
In both cases, if .emacs is not there, _emacs should be used.
This is because we cannot create .emacs file according to the windows file naming rules.(but we can download or copy it from somewhere else).

Resources