A Little Example of ELLCC Under Windows

As I mentioned previously, it is easy to use ELLCC to compile C and C++ programs under Windows. Now that the latest releases of ELLCC come with the MinGW-w64 header files and libraries, all you have to do is download and install a Windows binary release and you have a full C/C++ development environment including the clang/LLVM based ecc compiler, binutils, and GDB. The tool chain can target Windows as well as various Linux systems as a cross compiler. You can also run ELLCC under Linux to target Windows. In fact, the Windows release has been compiled under Linux.

Here is a simple example of compiling and debugging a simple “hello world” program using the Windows cmd shell:

                                                                            
Microsoft Windows [Version 6.3.9600]                                             
(c) 2013 Microsoft Corporation. All rights reserved.                             
                                                                                 
C:\Users\rich>cd \                                                               
                                                                                 
C:\>cd ellcc                                                                     
                                                                                 
C:\ellcc>bin/ecc examples\hello\main.c -g                                        
'bin' is not recognized as an internal or external command,                      
operable program or batch file.                                                  
                                                                                 
C:\ellcc>bin\ecc examples\hello\main.c -g                                        
                                                                                 
C:\ellcc>bin/ecc-gdb a.exe                                                       
'bin' is not recognized as an internal or external command,                      
operable program or batch file.                                                  
                                                                                 
C:\ellcc>bin\ecc-gdb a.exe                                                       
GNU gdb (GDB) 7.7                                                                
Copyright (C) 2014 Free Software Foundation, Inc.                                
License GPLv3+: GNU GPL version 3 or later     
This is free software: you are free to change and redistribute it.               
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"       
and "show warranty" for details.                                                 
This GDB was configured as "i386-mingw32".                                       
Type "show configuration" for configuration details.                             
For bug reporting instructions, please see:                                      
.                                         
Find the GDB manual and other documentation resources online at:                 
.                                
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.exe...done.
(gdb) break main
Breakpoint 1 at 0x401571: file examples\hello\main.c, line 5.
(gdb) run
Starting program: C:\ellcc\a.exe
[New Thread 2432.0xc38]
warning: Can not parse XML library list; XML support was disabled at compile tim
e

Breakpoint 1, main () at examples\hello\main.c:5
5           printf("hello world\n");
(gdb) list
1       #include <stdio.h>
2
3       int main()
4       {
5           printf("hello world\n");
6       }
(gdb) c
Continuing.
hello world
[Inferior 1 (process 2432) exited normally]
(gdb)

Since I’m a *nix guy I’m more comfortable with a shell, as you can see by my ‘/’ vs. ‘\’ fumbling above. Here is the same thing done using the MSYS command shell:


rich@VirtualWin8-64 MSYS ~
$ cd /c/ellcc

rich@VirtualWin8-64 MSYS /c/ellcc
$ bin/ecc examples/hello/main.c -g

rich@VirtualWin8-64 MSYS /c/ellcc
$ bin/ecc-gdb a.exe
GNU gdb (GDB) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.exe...done.
(gdb) break main
Breakpoint 1 at 0x401571: file examples/hello\main.c, line 5.
(gdb) run
Starting program: C:\ellcc\a.exe
[New Thread 1936.0x538]
warning: Can not parse XML library list; XML support was disabled at compile time

Breakpoint 1, main () at examples/hello\main.c:5
5           printf("hello world\n");
(gdb) c
Continuing.
hello world
[Inferior 1 (process 1936) exited normally]
(gdb)

Cool stuff.

Leave a Reply

Your email address will not be published.