M-HT / SR

A project to statically recompile following games to create Windows or Linux (x86 or arm) versions of the games - Albion, X-Com: UFO Defense (UFO: Enemy Unknown), X-Com: Terror from the Deep, Warcraft: Orcs & Humans, Septerra Core: Legacy of the Creator, Battle Isle 3: Shadow of the Emperor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to compile - Judy unresolved external symbols

enderdrag64 opened this issue · comments

I've spent most of my day today trying to compile this and failing. I'm using windows 10, visual studio 2022. It doesn't matter whether I use scons or not, the end result is the same - it compiles fine, but the visual studio linker is unable to find any of the symbols in judy.lib

I've attached the errors, as well as the output of running dumpbin on the lib file. Clearly the symbols are there, I'm really not sure what the problem is.

unresolved_symbols
symbols.txt

commented

I'm guessing that you compiled judy yourself (using build.bat). Try this:
Put judy.def from judy.zip into judy-1.0.5\src (where build.bat is located).
Edit file build.bat and add parameter /DEF:judy.def to the link commands at the end of the file.
Compile it again.

I'm guessing that you compiled judy yourself (using build.bat). Try this: Put judy.def from judy.zip into judy-1.0.5\src (where build.bat is located). Edit file build.bat and add parameter /DEF:judy.def to the link commands at the end of the file. Compile it again.

Okay I tried doing this, if I link with the DEF added then it generates a much smaller lib file (11kb instead of 293kb) that has no export symbols at all except for judy_NULL_THUNK_DATA

It's worth noting that adding the /DEF:judy.def part wasn't enough, that gave a bunch of errors about "unrecognized option /LIB", I had to change the last "link" into a "lib" and then remove the /LIB option.

commented

I don't have visual studio 2022, I'm testing it on older version where link still supports option /LIB, but that's just a minor issue.
My generated .lib file is also small (11 kB), but has the exported symbols:

dumpbin /exports judy.lib
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file judy.lib

File Type: LIBRARY

     Exports

       ordinal    name

                  _Judy1ByCount
                  _Judy1Count
                  _Judy1First
                  _Judy1FirstEmpty
                  _Judy1FreeArray
                  _Judy1Last
                  _Judy1LastEmpty
                  _Judy1MallocSizes
                  _Judy1MemActive
                  _Judy1MemUsed
                  _Judy1Next
                  _Judy1NextEmpty
                  _Judy1Prev
                  _Judy1PrevEmpty
                  _Judy1Set
                  _Judy1SetArray
                  _Judy1Test
                  _Judy1Unset
                  _JudyFree
                  _JudyHSDel
                  _JudyHSFreeArray
                  _JudyHSGet
                  _JudyHSIns
                  _JudyLByCount
                  _JudyLCount
                  _JudyLDel
                  _JudyLFirst
                  _JudyLFirstEmpty
                  _JudyLFreeArray
                  _JudyLGet
                  _JudyLIns
                  _JudyLInsArray
                  _JudyLLast
                  _JudyLLastEmpty
                  _JudyLMallocSizes
                  _JudyLMemActive
                  _JudyLMemUsed
                  _JudyLNext
                  _JudyLNextEmpty
                  _JudyLPrev
                  _JudyLPrevEmpty
                  _JudyMalloc
                  _JudyMallocVirtual
                  _JudySLDel
                  _JudySLFirst
                  _JudySLFreeArray
                  _JudySLGet
                  _JudySLIns
                  _JudySLLast
                  _JudySLNext
                  _JudySLPrev

  Summary

          BA .debug$S
          14 .idata$2
          14 .idata$3
           4 .idata$4
           4 .idata$5
           A .idata$6

What's your output of dumpbin /exports judy.lib ?

It looks like this:

Microsoft (R) COFF/PE Dumper Version 14.39.33523.0
Copyright (C) Microsoft Corporation. All rights reserved.

Dump of file Judy.lib

File Type: LIBRARY

COFF SYMBOL TABLE
000 010175CA ABS notype Static | @comp.id
001 00000000 SECT2 notype External | __IMPORT_DESCRIPTOR_judy
002 C0000040 SECT2 notype Section | .idata$2
003 00000000 SECT3 notype Static | .idata$6
004 C0000040 UNDEF notype Section | .idata$4
005 C0000040 UNDEF notype Section | .idata$5
006 00000000 UNDEF notype External | __NULL_IMPORT_DESCRIPTOR
007 00000000 UNDEF notype External | �judy_NULL_THUNK_DATA

String Table Size = 0x4C bytes

COFF SYMBOL TABLE
000 010175CA ABS notype Static | @comp.id
001 00000000 SECT2 notype External | __NULL_IMPORT_DESCRIPTOR

String Table Size = 0x1D bytes

COFF SYMBOL TABLE
000 010175CA ABS notype Static | @comp.id
001 00000000 SECT2 notype External | �judy_NULL_THUNK_DATA

String Table Size = 0x1A bytes

Summary

      BA .debug$S
      14 .idata$2
      14 .idata$3
       4 .idata$4
       4 .idata$5
       A .idata$6
commented

That looks like the output of dumpbin /symbols judy.lib. Can you check the output of dumpbin /exports judy.lib ?

Ahh good catch. With /exports it looks the same as yours. I still get unresolved external symbols when trying to link with it though

commented

I'm not sure I can help you any further. I made a test program and it linked with judy.lib without any problems.

I'm not sure I can help you any further. I made a test program and it linked with judy.lib without any problems.

May I ask what version of Visual Studio you're using? I may just restart with that

commented

May I ask what you are trying to achieve ?
I'm not sure this project works with compilers other than gcc/clang.
And if you can't compile it, are you sure you have the skills/knowledge to do something with it ?

I'm not sure this project works with compilers other than gcc/clang.

Then why is your SConstruct script built to use Visual Studio?

commented

That's how scons works. I didn't do anything specific for Visual Studio.
I'm not stopping you from using Visual studio, but i don't use it so don't expect much help.

Okay so I switched to gcc inside msys2 and I tried building (gcc *.c -lJudy -ludis86) and I'm still getting undefined references involving Judy, even after rebuilding it from scratch with gcc too.

image

commented

I tried compiling it in msys2 and I fixed some compilation warnings. With 32-bit version there were no problems with building. With 64-bit version there were a lot of compiler warning when compiling Judy, but when I fixed those, there were no problems with building.

I finally managed to build SR successfully!

Using the official judy 1.05 release from SourceForge like I had been was a lost cause, but I found this fork over at https://github.com/dlmiles/libjudy that has fixes specifically to fix compatibility with msys. After building and installing that version I was able to link against it successfully.

I'd recommend updating your documentation to clarify that you should compile with msys/gcc instead of scons/visual studio, and perhaps link to the working judy fork