<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Microsoft YaHei";
        panose-1:2 11 5 3 2 2 4 2 2 4;}
@font-face
        {font-family:"\@Microsoft YaHei";
        panose-1:2 11 5 3 2 2 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        mso-believe-normal-left:yes;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Courier New";
        color:#202020;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><![if mso 9]><style>p.MsoNormal
        {margin-left:7.5pt;}
</style><![endif]><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple style='margin-left:7.5pt;margin-top:7.5pt;margin-right:7.5pt;margin-bottom:7.5pt'><div class=WordSection1><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";color:#202020'>Your error message says ‘priv/hello’. Check the path in your erlang:load_nif.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";color:#202020'>Janos<o:p></o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> erlang-questions-bounces@erlang.org [mailto:erlang-questions-bounces@erlang.org] <b>On Behalf Of </b>???<br><b>Sent:</b> Tuesday, May 07, 2013 3:15 PM<br><b>To:</b> Dave Cottlehuber<br><b>Cc:</b> erlang-questions<br><b>Subject:</b> Re: [erlang-questions] nif problem in windows<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>hi, Dave,<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'> <o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>Thanks for you replying, I try your example and it is return the same error I wrote before, here is the output:<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'> <o:p></o:p></span></p></div><div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>E:\firefox_download\hellonif-master>rebar.cmd compile<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>==> hellonif-master (compile)<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>Compiled src/hello.erl<o:p></o:p></span></p></div><div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>Copyright (C) Microsoft Corporation.  All rights reserved.<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'> <o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>hello.c<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>D:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\stdlib.h(215) : warn<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>ing C4255: '_get_purecall_handler' : no function prototype given: converting '()<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>' to '(void)'<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>d:\PROGRA~2\ERL510~1.1\erts-5.10.1\include\erl_nif.h(132) : warning C4820: '<unn<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>amed-tag>' : '4' bytes padding added after data member 'ref_bin'<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>c_src/hello.c(3) : warning C4100: 'argv' : unreferenced formal parameter<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>c_src/hello.c(3) : warning C4100: 'argc' : unreferenced formal parameter<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>c_src/hello.c(13) : warning C4013: 'memcpy' undefined; assuming extern returning<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'> int<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>Microsoft (R) Incremental Linker Version 8.00.50727.42<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>Copyright (C) Microsoft Corporation.  All rights reserved.<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'> <o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>   正在创建库 priv/hello.lib 和对象 priv/hello.exp<o:p></o:p></span></p></div></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'> <o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'> <o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>E:\firefox_download\hellonif-master>erl -pa ebin<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>Eshell V5.10.1  (abort with ^G)<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>1> hello:init().<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>{error,{load_failed,"Failed to load NIF library priv/hello: 'Unspecified error'"<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>}}<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>2> hello:world().<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>"NIF library not loaded"<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>3><o:p></o:p></span></p></div></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'> <o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'> <o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>Notice that, I change the code hello.erl slightly, it catch all the error when erlang:load_nif, I delete it, so it can output the error message<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>I using operating system win7, is it matters?<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'> <o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'> <o:p></o:p></span></p></div><div class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'><hr size=1 width=210 style='width:157.5pt' noshade style='color:#B5C4DF' align=left></span></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'>ckwei<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:navy'> <o:p></o:p></span></p></div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt;background:#EFEFEF'><b><span style='font-size:9.0pt;font-family:"Microsoft YaHei","sans-serif";color:black'>From:</span></b><span style='font-size:9.0pt;font-family:"Microsoft YaHei","sans-serif";color:black'> <a href="mailto:dch@jsonified.com">Dave Cottlehuber</a><o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt;background:#EFEFEF'><b><span style='font-size:9.0pt;font-family:"Microsoft YaHei","sans-serif";color:black'>Date:</span></b><span style='font-size:9.0pt;font-family:"Microsoft YaHei","sans-serif";color:black'> 2013-05-07 19:37<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt;background:#EFEFEF'><b><span style='font-size:9.0pt;font-family:"Microsoft YaHei","sans-serif";color:black'>To:</span></b><span style='font-size:9.0pt;font-family:"Microsoft YaHei","sans-serif";color:black'> <a href="mailto:erlang-questions@erlang.org">erlang-questions</a><o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt;background:#EFEFEF'><b><span style='font-size:9.0pt;font-family:"Microsoft YaHei","sans-serif";color:black'>Subject:</span></b><span style='font-size:9.0pt;font-family:"Microsoft YaHei","sans-serif";color:black'> Re: [erlang-questions] nif problem in windows<o:p></o:p></span></p></div></div></div><div><div><div><div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:black'>On 7 May 2013 12:00, 韦崇焜 <<a href="mailto:wckbluesky@yahoo.com.cn" target="_blank">wckbluesky@yahoo.com.cn</a>> wrote:<o:p></o:p></span></p></div></div><div><div><div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:black'>hi<br><br>I am testing nif in windows right now, the nif c code is very simple and it is copyed directly from <a href="http://www.erlang.org/doc/tutorial/nif.html#id64988" target="_blank">http://www.erlang.org/doc/tutorial/nif.html#id64988</a><br><br>All the code is running well in Linux, and c code is compiled to .so in linux, .dll in windows<br><br>Everything is ok before I running "c(complex6)" in erlang VM, in windows,<br><br>it reports<br><br>=ERROR REPORT==== 7-May-2013::17:36:19 ===<br>Error in process <0.70.0> with exit value: {{badmatch,{error,{load_failed,"Faile<br>d to load NIF library ./complex6_nif: 'Unspecified error'"}}},[{complex6,init,0,<br>[{file,"complex6.erl"},{line,7}]},{code_server,'-handle_on_load/4-fun-0-',1,[{fi<br>le,"code_server.erl"},...<br><br><br>=ERROR REPORT==== 7-May-2013::17:36:19 ===<br>The on_load function for module complex6 returned {{badmatch,<br>                                                    {error,<br>                                                     {load_failed,<br>                                                      "Failed to load NIF library ./complex6_nif: 'Unspecified error'"}}},<br>                                                   [{complex6,init,0,<br>                                                     [{file,...},{...}]},<br>                                                    {code_server,<br>                                                     '-handle_on_load/4-fun-0-',<br>                                                     1,<br>                                                     [{...}|...]}]}<br>{error,on_load_failure}<br><br>It is hard to find some useful information in google.<br>Can anyone tell how to fix it?<o:p></o:p></span></p></blockquote><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:black'><o:p> </o:p></span></p></div></div></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:black'>Hi ckwei,<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:black'>It might be useful to paste some of the source code that isn't working for you. I don't have windows handy, but here's a NIF example that works on both Windows using command shell and SDK 7.1,  and LInux, that Volker & I did last year. The erlang side NIF loader was poached from one of Paul Davis' projects IIRC.<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:black'><a href="https://github.com/vmx/hellonif" target="_blank">https://github.com/vmx/hellonif</a><o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:black'>A+<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:#888888'>Dave<o:p></o:p></span></p></div><div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:#888888'> <o:p></o:p></span></p></div></div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:black'><o:p> </o:p></span></p></div><p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.5pt;font-family:"Microsoft YaHei","sans-serif";color:black'><o:p> </o:p></span></p></div></div></div></body></html>