<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1495793773512_8217">Dear all,</div><div id="yui_3_16_0_ym19_1_1495793773512_8218"><br id="yui_3_16_0_ym19_1_1495793773512_8219"></div><div id="yui_3_16_0_ym19_1_1495793773512_8220">  I'm trying to write a module in Lua in order to use it in LuaTeX.</div><div id="yui_3_16_0_ym19_1_1495793773512_8221">  </div><div id="yui_3_16_0_ym19_1_1495793773512_8222">I use TexLive 2016 with LuaTeX Version 0.95.0 (which has Lua version 5.2.*) and mingw with gcc 5.3.0 as C compiler.</div><div id="yui_3_16_0_ym19_1_1495793773512_8223">On my computer there is Lua version 5.2.4.</div><div id="yui_3_16_0_ym19_1_1495793773512_8224"><br id="yui_3_16_0_ym19_1_1495793773512_8225"></div><div id="yui_3_16_0_ym19_1_1495793773512_8226">I compile the module (see attachment called LuaBasic.c) in the following way</div><div id="yui_3_16_0_ym19_1_1495793773512_8227"><br id="yui_3_16_0_ym19_1_1495793773512_8228"></div><div id="yui_3_16_0_ym19_1_1495793773512_8229">  1) Compile the .c file enabling some Lua definitions in order to have the possibility to create the dll x windows.</div><div id="yui_3_16_0_ym19_1_1495793773512_8230">     </div><div id="yui_3_16_0_ym19_1_1495793773512_8231"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1495793773512_8232">   </span> <b id="yui_3_16_0_ym19_1_1495793773512_8324">gcc -O2 -c -DLUA_CORE -DLUA_BUILD_AS_DLL -o LuaBasic.o LuaBasic.c -I"C:\Users\Michele\Desktop\LuaSketch\LuaSketch_C\lua_src"</b></div><div id="yui_3_16_0_ym19_1_1495793773512_8233"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1495793773512_8234">  </span> </div><div id="yui_3_16_0_ym19_1_1495793773512_8235">  2) Link the .o file to the dynamic library present in the TexLive folder (as you can see in the -L and -l options)</div><div id="yui_3_16_0_ym19_1_1495793773512_8236">     </div><div id="yui_3_16_0_ym19_1_1495793773512_8237"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1495793773512_8238">       </span> <b id="yui_3_16_0_ym19_1_1495793773512_8348">gcc -O -shared -o LuaBasic.dll LuaBasic.o -L"C:\texlive\2016\bin\win32" -l "lua52"</b></div><div id="yui_3_16_0_ym19_1_1495793773512_8239"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1495793773512_8240">  </span> </div><div id="yui_3_16_0_ym19_1_1495793773512_8241">  3) Delete the .o file</div><div id="yui_3_16_0_ym19_1_1495793773512_8242">     </div><div id="yui_3_16_0_ym19_1_1495793773512_8243"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1495793773512_8244">    </span> <b id="yui_3_16_0_ym19_1_1495793773512_15089">del LuaBasic.o</b></div><div id="yui_3_16_0_ym19_1_1495793773512_8245"><br id="yui_3_16_0_ym19_1_1495793773512_8246"></div><div id="yui_3_16_0_ym19_1_1495793773512_8247">The problem is: I have two different behaviour, the first when I use the module LuaBasic into Lua 5.2.4  and the second when used into LuaTeX.</div><div id="yui_3_16_0_ym19_1_1495793773512_8248"><br id="yui_3_16_0_ym19_1_1495793773512_8249"></div><div id="yui_3_16_0_ym19_1_1495793773512_8250">In the first case I have no problems as you can see from theh attached pictured called  LuaBasic_used_by_Lua5.2_NO_PROBLEM.png.</div><div id="yui_3_16_0_ym19_1_1495793773512_8251"><br id="yui_3_16_0_ym19_1_1495793773512_8252"></div><div id="yui_3_16_0_ym19_1_1495793773512_8253">In the second case when I compile LuaLaTeX file called LuaBasic_test.tex, it crashes as you can see from the attached picture called LuaBasic_crashed.png. After several times compiling the tex file, a correct pdf is made.</div><div id="yui_3_16_0_ym19_1_1495793773512_8254"><br id="yui_3_16_0_ym19_1_1495793773512_8255"></div><div id="yui_3_16_0_ym19_1_1495793773512_8256">In your opinion, where is the problem? Is the C source or something in the LuaTex?</div><div id="yui_3_16_0_ym19_1_1495793773512_8257"><br id="yui_3_16_0_ym19_1_1495793773512_8258"></div><div id="yui_3_16_0_ym19_1_1495793773512_8259">Many thanks in advance for any suggestions.</div><div id="yui_3_16_0_ym19_1_1495793773512_8260"><br id="yui_3_16_0_ym19_1_1495793773512_8261"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1495793773512_8262">Michele</div></div></body></html>