[erlang-questions] open_port returns enoent even when driver init function executes correctly.

Jeffrey Rennie <>
Fri Jan 4 01:02:37 CET 2013

I tried hacking the Makefile to force compiling beam_emu.c with cl.exe, but it appears that beam_emu.c hasn't been ported to work with cl.exe:

C:\Users\jeff\GitHub\otp\erts\emulator>bash c:/Users/jeff/GitHub/otp/erts/etc/wi

n32/cygwin_tools/vc/cc.sh   -O3 -I/cygdrive/c/Users/jeff/GitHub/otp/erts/win32



-Ibeam -Isys/win32 -Isys/common -Iwin32 -Izlib  -Ipcre -Ihipe -I../include -I../

include/win32 -I../include/internal -I../include/internal/win32 -c beam/beam_emu

.c -o obj/win32/opt/smp/beam_emu.o

TAIL: lseeki64() failed 9


Wow, getting the simplest .dll driver to load on Windows is brutally difficult.


Has anyone successfully loaded a .dll driver on Windows?  Could you send me the most primitive skeleton that works?


Alternatively, I've attached my source files for inspection.



Jeffrey Rennie



From: Robert Raschke [mailto:] 
Sent: Thursday, January 03, 2013 12:37 AM
To: SurferJeff
Cc: ; 
Subject: Re: [erlang-questions] open_port returns enoent even when driver init function executes correctly.


You can try running erl.exe with sasl enabled to get better error messages.

The messages you see at the moment are coming out interleaved, like in the old joke "When faced with a problem you decide to use threading, ..."  :-)


On Jan 3, 2013 4:53 AM, "SurferJeff" <> wrote:

I found the recipe to build debug:

$ cd $ERL_TOP
$ rm bin/win32/erlexec.dll
$ cd erts/emulator
$ make debug
$ cd ../etc
$ make debug


And it succeeded.  However, the next command in the recipe fails:

 <mailto:>  /cygdrive/c/Users/jeff/GitHub/otp
$ make local_setup
make[1]: Entering directory `/cygdrive/c/Users/jeff/GitHub/otp/erts'
make[2]: Entering directory `/cygdrive/c/Users/jeff/GitHub/otp/erts/start_script
make[2]: Nothing to be done for `debug'.
make[2]: Leaving directory `/cygdrive/c/Users/jeff/GitHub/otp/erts/start_scripts
ct_run.exe dialyzer.exe erl.ini erl_crash.dump escript.exe run_test.exe typer.ex
e werl.exe win32
make[2]: Entering directory `/cygdrive/c/Users/jeff/GitHub/otp/erts/start_script
/usr/bin/install -c -d /cygdrive/c/users/jeff/github/otp/erts/start_scripts/tmp
( cd /cygdrive/c/users/jeff/github/otp/erts/start_scripts/tmp && \
  erlc -W  -I/cygdrive/c/users/jeff/github/otp/lib/kernel/ebin -I/cygdrive/c/use
rs/jeff/github/otp/lib/stdlib/ebin -I/cygdrive/c/users/jeff/github/otp/lib/sasl/
ebin +no_warn_sasl +otp_build -o /cygdrive/c/users/jeff/github/otp/bin/start.scr
ipt /cygdrive/c/users/jeff/github/otp/erts/start_scripts/start_clean.rel )
File not found: "c:/cygdrive/c/users/jeff/github/otp/erts/start_scripts/start_cl
Makefile:129: recipe for target `/cygdrive/c/users/jeff/github/otp/bin/start.scr
ipt' failed
make[2]: *** [/cygdrive/c/users/jeff/github/otp/bin/start.script] Error 1
make[2]: Leaving directory `/cygdrive/c/Users/jeff/GitHub/otp/erts/start_scripts
Makefile:69: recipe for target `local_setup' failed
make[1]: *** [local_setup] Error 2
make[1]: Leaving directory `/cygdrive/c/Users/jeff/GitHub/otp/erts'
Makefile:883: recipe for target `local_setup' failed
make: *** [local_setup] Error 2



And now my erl.exe is completely hosed:

 <mailto:>  /cygdrive/c/Users/jeff/GitHub/otp/bin/win32
$ ./erl.exe
{(no error logger present"i)n ietr rtoerr: m"iEnrartoirn gi ni np rdooc_ebsoost
"<,0{.b2a.d0a>r wgi,t[h{ eerxli_tp rviaml_uleo:a d{ebra,dcahregc,k[_{feirlle__pr

Crash dump was written to: erl_crash.dump
init terminating in do_boot ()


On Wednesday, January 2, 2013 7:26:09 PM UTC-8, SurferJeff wrote:

I'm working through the example here: 
And I'm trying to get it to run on Windows.  I reordered the code in the C 
source so that it compiles, and added a module.def file so that erlang 
actually finds and executes the driver init function. 

I attached a debugger.  Walking back up the stack, I observe that: 
The driver init function returns correctly. 
erts_sys_ddll_call_init() returns correctly. 
do_load_driver_entry() returns ERL_DE_NO_ERROR. 
load_driver_entry() returns ERL_DE_NO_ERROR. 
erl_ddll_try_load_3 returns t = TUPLE2(hp, am_ok, ok_term); on line 417 of 
But the next higher call on the stack is _process_main(), which was compiled 
with gcc and has no debug symbols so I can't step through and figure out why 
the end result is: 

=ERROR REPORT==== 2-Jan-2013::19:14:22 === 
Error in process <0.31.0> with exit value: 

Has anyone seen this before? 

If not, how do I recompile erl.exe purely with cl.exe (no gcc) so that it 
generates debug symbols?  And while I'm recompiling, how do I turn off all 
optimizations?  I can read basic make files, but I get lost in the configure 
scripts and .in and .mk files.  Please take pity on a Windows programmer ;-) 

erlang-questions mailing list 

erlang-questions mailing list


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130103/34056d5f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: complex5.erl
Type: application/octet-stream
Size: 1175 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130103/34056d5f/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: module.def
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130103/34056d5f/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: port_driver.cpp
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130103/34056d5f/attachment-0001.ksh>

More information about the erlang-questions mailing list