-- kjk
On Tue, Jun 21, 2011 at 6:46 PM, CrossWall <tiantia...@gmail.com> wrote:
> can load or not?
syscall.LoadLibrary("./somedir/hello.dll")
In this case my best guess is that the path is wrong but it could be a
myriad of other issues like the .dll not being a valid dll file or the
file having wrong permissions.
What exactly is the problem? Have you checked errno result? Have you
checked what this error means in Windows to better understand the
exact cause of the problem? Have you tried providing a full (and not
relative) path to the .dll? Have your tried using Windows (and not
Unix) style path (i.e c:\foo\bar.dll and not /foo/bar)? How did you
verify that the dll is valid?
-- kjk
After you fixed the path, your app crashed with C0000005 exception
which is access violation, which means that you're reading or writing
memory that doesn't belong to you
(http://blogs.msdn.com/b/calvin_hsia/archive/2004/06/30/170344.aspx).
It's either a bug in your dll or the way your Go code calls the code
in the dll. Either way, at this point you're on your own.
-- kjk
Either way, the first step is to verify that your hello.dll is a valid
Windows dll. To do that write a test program, using Visual C++, that
uses LoadLibrary() to load hello.dll and call Hello() function.
I don't know the gcc toolchain you're using but by using it you
introduce a lot of uncertainty about what exactly does it generate,
which is why it's important to do the test using native Windows tools
i.e. Visual C++. If that works then the bug is probably in your Go
code that calls the function (and that you haven't shown us).
-- kjk
On Wed, Jun 22, 2011 at 5:05 PM, CrossWall <tiantia...@gmail.com> wrote:
> the dll generated from c file:
> $ cat hello.c
> int Hello() {
> return 999;
> }
> $ cat hello.h
> int Hello();
> --------------------------
> gcc -shared hello.c -o hello.dll
> --------------------------
> use a main.c to test the dll
> $ cat main.c
> #include <stdio.h>
> #include "hello.h"
> int main() {
> printf("%d", Hello());
> return 0;
> }
> ----------------------------
> gcc main.c ./hello.dll
> ---------------------------
> ./a.exe
> works fine.
> ---------------------------
> the problem is happen when calls the code
> in the dll.