On Mon, Dec 21, 2009 at 1:26 PM, Luís Oliveira <span dir="ltr"><<a href="mailto:luismbo@gmail.com">luismbo@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Mon, Dec 21, 2009 at 8:55 PM, Elliott Slaughter<br>
<<a href="mailto:elliottslaughter@gmail.com">elliottslaughter@gmail.com</a>> wrote:<br>
> I'm believe I'm seeing this issue again, but none of my previous workarounds<br>
> seem to be working. I am using SBCL 1.0.29 on Windows XP, and when I save<br>
> and run an executable, I keep getting undefined alien errors. I have tried<br>
> both the :dont-save t hack that I initially suggested, and have tried<br>
> calling (close-foreign-library ...) on all of the open libraries before<br>
> saving the executable, and nothing helps.<br>
<br>
</div>Can you come up with a minimal test case? Something using e.g.<br>
libtest.dll would be nice.<br></blockquote></div><br clear="all">I think I managed to reproduce this error, and this time, I have a minimal test case! When I put a dll on *foreign-library-directories* and build a Windows executable with SBCL, the generated executable cannot run unless the dll is present at exactly the same absolute path as it was during compile time. If I instead move the dll into the current working directory, then I don't have any problem with absolute paths being saved in my binary.<div>
<br></div><div>First, the contents of break.lisp:</div><div><br></div><div><div>(asdf:oos 'asdf:load-op :cffi)</div><div>(use-package :cffi)</div><div>(pushnew (truename #p"lib/") *foreign-library-directories* :test #'equal)</div>
<div>(define-foreign-library sdl</div><div> (:windows "SDL.dll"))</div><div>(defun main ()</div><div> (use-foreign-library sdl)</div><div> (format t "It works~%"))</div><div>(main)</div><div>(save-lisp-and-die "main.exe" :toplevel #'main :executable t)</div>
<div>(quit)</div></div><div><div><br></div><div>Second, I create two binaries. I demonstrate that the first executable is broken by moving the original lib directory after compiling, while the second executable works fine.</div>
<div><br></div><div>$ ls *</div><div>break.lisp</div><div><br></div><div>bin:</div><div><br></div><div>lib:</div><div>SDL.dll</div><div><br></div><div>$ sbcl --load break.lisp</div><div>This is SBCL 1.0.29, an implementation of ANSI Common Lisp.</div>
<div>More information about SBCL is available at <<a href="http://www.sbcl.org/">http://www.sbcl.org/</a>>.</div><div><br></div><div>[ ... ]</div><div><br></div><div>It works</div><div>[undoing binding stack and other enclosing state... done]</div>
<div>[saving current Lisp image into main.exe:</div><div>writing 2888 bytes from the read-only space at 0x22000000</div><div>writing 1736 bytes from the static space at 0x22100000</div><div>writing 27582464 bytes from the dynamic space at 0x22300000</div>
<div>done]</div><div><br></div><div>$ mv main.exe bin/</div><div><br></div><div>$ cp lib/SDL.dll bin/</div><div><br></div><div>$ cd bin/</div><div><br></div><div>$ ./main.exe</div><div><br></div><div>This is experimental prerelease support for the Windows platform: use</div>
<div>at your own risk. "Your Kitten of Death awaits!"</div><div>It works</div><div><br></div><div>$ mv ../lib/ ../lib2</div><div><br></div><div>$ ./main.exe</div><div><br></div><div>This is experimental prerelease support for the Windows platform: use</div>
<div>at your own risk. "Your Kitten of Death awaits!"</div><div><br></div><div>debugger invoked on a SIMPLE-ERROR:</div><div> Error opening shared object "c:\\Users\\Elliott\\Programming\\CommonLisp\\brea</div>
<div>k-cffi\\lib\\SDL.dll":</div><div> 126.</div><div><br></div><div>Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.</div><div><br></div><div>restarts (invokable by number or by possibly-abbreviated name):</div>
<div> 0: [CONTINUE ] Skip this shared object and continue.</div><div> 1: [RETRY ] Retry loading this shared object.</div><div> 2: [CHANGE-PATHNAME] Specify a different pathname to load the shared object fr</div>
<div>om.</div><div><br></div><div>(SB-SYS:DLOPEN-OR-LOSE</div><div> #S(SB-ALIEN::SHARED-OBJECT</div><div> :PATHNAME #P"c:\\Users\\Elliott\\Programming\\CommonLisp\\break-cffi\\lib\\S</div><div>DL.dll"</div><div>
:NAMESTRING "c:\\Users\\Elliott\\Programming\\CommonLisp\\break-cffi\\lib\\S</div><div>DL.dll"</div><div> :HANDLE NIL</div><div> :DONT-SAVE NIL))</div><div>0] (quit)</div><div><br></div><div>$ cd ..</div>
<div><br></div><div>$ mv lib2/ lib</div><div><br></div><div>$ cp lib/SDL.dll .</div><div><br></div><div>$ rm bin/main.exe</div><div><br></div><div>$ ls *</div><div>SDL.dll break.lisp</div><div><br></div><div>bin:</div><div>
SDL.dll</div><div><br></div><div>lib:</div><div>SDL.dll</div><div><br></div><div>$ sbcl --load break.lisp</div><div>[ ... ]</div><div>It works</div><div>[undoing binding stack and other enclosing state... done]</div><div>
[saving current Lisp image into main.exe:</div><div>writing 2888 bytes from the read-only space at 0x22000000</div><div>writing 1736 bytes from the static space at 0x22100000</div><div>writing 27578368 bytes from the dynamic space at 0x22300000</div>
<div>done]</div><div><br></div><div>$ mv main.exe bin/</div><div><br></div><div>$ cd bin/</div><div><br></div><div>$ ./main.exe</div><div><br></div><div>This is experimental prerelease support for the Windows platform: use</div>
<div>at your own risk. "Your Kitten of Death awaits!"</div><div>It works</div><div><br></div><div>$ mv ../lib/ ../lib2</div><div><br></div><div>$ ./main.exe</div><div><br></div><div>This is experimental prerelease support for the Windows platform: use</div>
<div>at your own risk. "Your Kitten of Death awaits!"</div><div>It works</div><div><br>-- <br>Elliott Slaughter<br><br>"Don't worry about what anybody else is going to do. The best way to predict the future is to invent it." - Alan Kay<br>
</div></div>