intelxed / xed

The X86 Encoder Decoder (XED), is a software library for encoding and decoding X86 (IA32 and Intel64) instructions
https://intelxed.github.io/
Apache License 2.0
1.38k stars 146 forks source link

LNK2019 unresolved external symbol "void __cdecl xed_tables_init(void)" #285

Open PavelKotov1 opened 2 years ago

PavelKotov1 commented 2 years ago

Hello, dear friends! I am trying to build x32 bit xed.dll to be linked into my standalone Visual Studio 19 projects. (x64bit xed.dll builds and links without any problem) OS is Windows 7 x64bit. Followind instructions, i did: git clone https://github.com/intelxed/xed.git xed git clone https://github.com/intelxed/mbuild.git mbuild mkdir test cd test then using x32 bit python: G:\test>"C:\Program Files (x86)\Python37-32\python.exe" ../xed/mfile.py --shared host_cpu=ia32 After that in G:\test\obj I see xed.dll and xed.lib. The dll is x32 bits, i have doublechecked it, and the import library contains xed_tables_init entry. In the VS project i have set up VC++ directories to point to the location of the .dll and .lib files, copied .dll into the project directory, and still: when i try to link the project i see the following error message: Error LNK2019 unresolved external symbol "void __cdecl xed_tables_init(void)" (?xed_tables_init@@YAXXZ) referenced in function _main xed32_Pavel_test C:\Users\root\source\repos\xed32_Pavel_test\main.obj 1

Can function decoration be the cause?

Also, I noticed this: "Shared libraries and DLLs If you build XED using the --shared object you'll get a libxed.dll on Windows. When you link against these shared objects/DLL you are required to define XED_DLL (/DXED_DLL on Windows )." Which options must be used to create libxed.dll? And how exactly to define XED_DLL? Should /DXED_DLL be added to the linkers command line options?

Could somebody please help me figure it out? Thanks in advance, any help is highly appreciated!

ZealanL commented 2 years ago

Have this issue too with a static library.

Viewing the xed.lib file reveals that sure enough, it is exported, BUT with an underscore: 015 00000000 SECT3 notype () External | _xed_tables_init

However, changing the include name from "xed_tables_init" to "_xed_tables_init" does not fix the issue.

marjevan commented 3 months ago

Hi, The mfile.py script adds XED_DLL.

I don't see any issue with the 32-bit build or linkage, and I can't reproduce the issue.

XED includes example tools that are built and linked with the XED C library. My advice is to use XED build scripts to build the examples and check what is missing in your process.

$ ./mfile.py clean examples --shared host_cpu=ia32 To see the detailed build/link commands, please use the verbosity option: $ ./mfile.py clean examples --shared host_cpu=ia32 -v 9