8

I get massive output with the following message (differentiated only by hex address):

ld.exe: DWARF error: could not find variable specification at offset 101cee

What is the meaning of this error in general?

This does not happen when compile release build. Only debug build.

Chameleon
  • 1,804
  • 2
  • 15
  • 21

1 Answers1

4

Basically I just found the solution. I place it here, because I didn't found such question in StackOverflow. Please answer if something of my positions are wrong.

I compile a library as a static library, but without correct #define directive, all exported functions get a __declspec(dllexport) prefix. So names of function function became __imp_function.

So, it was just an undefined reference to __imp_function.

But why it is so encrypted? And why release build compiled correctly?

I believe that this happen because of -flto option which does link time optimization and keep all the code of library inside .a file, so, no references needed (no fail).

Chameleon
  • 1,804
  • 2
  • 15
  • 21
  • 1
    It seems that there is no specific solution for the problem. It seems that the problem is hidden in another place. For me, it was that libraries and program's binary did not compiled with the same preprocessor directives. This lead to different name for symbols in libraries and different in program's binary. E.g. You compile libpng as a static library with modified libpngconf.h and pngconf.h and then you use a vanilla libpngconf.h and pngconf.h for your program which implies that you use a libpng.dll or you add a #define PNG_* in your program before #include which modifies behavior – Chameleon Apr 30 '21 at 08:05