How to fix multiplayer_msg_general_failure

In Heroes of Might and Magic IV (aka Heroes of Might and Magic 4, HOMM 4, HOMM IV) this error occurs when the name of the executable used to launch the program differs:

multiplayer_msg_general_failure

The content of the executable does not matter, it is the name. So both must use for example h4tour351.exe, even though in Equilibris 3.51 it has the same content as h4mod.exe.

Thursday, November 6th, 2008 Computers No Comments

Chess puzzle: The two pawns (medium)

The moves following here look like a harmless, automated trade of the minor pieces. But actually I (white) missed a chance to win material here. What should I have done in move 14?

The actual game is below. Find the moves for white that win material.


Hint 1: show

Hint 2: show

Sunday, October 19th, 2008 Chess No Comments

JNI (Java Native Interface): Exception in thread “main” java.lang.UnsatisfiedLinkError: Can’t find dependent libraries

How to fix UnsatisfiedLinkError in JNI

I have never had problems with JNI. In the few situations when I needed it, it just worked. But last week someone asked me for help with his problem. When I tried to reproduce it, I found out that it had spread even to my old JNI programs which worked until 2006!

When running a program that uses a native function the following error occured:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Test.dll: Can't find dependent libraries

It’s obviously a linker problem related to the generation of the .dll file. I have no idea why it occurs now and didn’t occur in the past. Different OS, compiler version, something like that? For some reason both the linker of Visual Studio and the linker of GCC started to think that is was a good idea to replace all method names by some arbitrary name which then cannot be found at runtime.

Fix for GCC

To fix that with GCC, the linker opion --add-stdcall-alias can be used.

gcc -Wl,--add-stdcall-alias -mno-cygwin -shared -I/cygdrive/c/Program\ Files/Java/jdk1.6.0_05/include -I/cygdrive/c/Program\ Files/Java/jdk1.6.0_05/include/win32 -o HelloWorld.dll HelloWorld.c

Fix for Visual C

For Microsoft Visual C Compiler it should theoretically be possible with a linker option as well.

Find out the correct linker option

First compile and link in the usual way that didn’t work. This will create the .dll file which results in the error we are talking about. Then use the dumpbin tool to list the procedure names:

dumpbin HelloWorld.dll /EXPORTS

You will find your procedure name, something like _Java_HelloWorld_print@8. Now try to guess what the name should be. My guess in this case would be Java_HelloWorld_print. This would result in the linker option /EXPORT:Java_HelloWorld_print=_Java_HelloWorld_print@8

Supply the linker option
  1. Use a #pragma comment in the source file:
    #pragma comment(linker, "/EXPORT:Java_HelloWorld_print=_Java_HelloWorld_print@8")

    OR

  2. Split into linking and compiling and provide the option to the linker in the command line, OR
  3. Supply it to the compiler at the end using /link:
    cl -I"C:\Program Files\Java\jdk1.6.0_05\include" -I"c:\Program Files\java\jdk1.6.0_05\include\win32" -MD -LD HelloWorld.c -FeHelloWorld.dll /link /EXPORT:Java_HelloWorld_print=_Java_HelloWorld_print@8

Option 3 is probably the easiest. After that dumpbin will show that now there is an additional procedure with the correct name:

dumpbin HelloWorld.dll /EXPORTS

I even compared it with the working .dll I created with GCC (see above), and it looks the same! But it doesn’t work, still getting the same error!

50 USD through PayPal for a solution and an explanation why the current way doesn’t work even though the procedure name is the same as in the working .dll created with GCC. (Only the first solution gets the price; only valid as long as this text is here.)

Monday, September 22nd, 2008 Computers No Comments

Chess puzzle #24 (medium)

White to move and win a pawn.

White to move and win a pawn.

Saturday, August 30th, 2008 Chess No Comments

Chess puzzle #23 (easy)

Black to move and win material.

Black to move and win material.

Wednesday, August 27th, 2008 Chess No Comments

Chess puzzle #22 (medium)

My opponent (white) made a huge mistake with Bh6:

Black to move and win material

Black to move and win material

Hint: show

Solution: show

Sunday, August 24th, 2008 Chess No Comments

Chess puzzle #21 (medium)

I (black) blundered here by taking that pawn on f3:

White to move and win material

White to move and win material

Hint 1: show

Hint 2: show

Fortunately my opponent (white) didn’t see the solution and tried Rf1:

Black to move and retain some of the material advantage

Black to move and retain some of the material advantage

Hint 1: show

Hint 2: show

Solution: show

Saturday, August 23rd, 2008 Chess No Comments

Chess puzzle #21 (easy)

Blunder by white (me)! I just took a black pawn with my rook.

black to move and win material

black to move and win material

Black to move and win material.

Thursday, August 21st, 2008 Chess No Comments

Chess puzzle: The missed chances (medium)

Today both me and my opponent missed a chance to turn the game around.


1. Find a better move 15 for white which wins material.

2. Find a better move 29 for black that wins material.

Thursday, August 7th, 2008 Chess No Comments

Chess puzzle: Who is the one in trouble? (tough)

Once again I (black) got in trouble after my opponent engaged multiple threads at once with 20. f4:

Who is the one in trouble?

Who is the one in trouble?

I used up almost all my time to think of a way out. Usually there is one in such a situation. But I didn’t see that actually there was not only a way to get out with minor material disadvantage, but even with a significant advantage!

Black to move and win material.

Hint: show

Solution: show

My own “solution” was a bit puny. If you look at how I won, please consider that after that situation I had only two minutes left :-)
show

Tuesday, August 5th, 2008 Chess No Comments