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

2

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.

Goya answered 20/8, 2020 at 18:24 Comment(1)
In my case a similar issue fixed by specifying compiler option -pthreadKraus
G
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).

Goya answered 20/8, 2020 at 18:24 Comment(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 <pngconf.h> which modifies behaviorGoya
V
1

In case it helps someone, I got this error while compiling a C++ program against a C static library. The root cause was that I missed to add

#ifdef __cplusplus
extern "C" {
#endif

/*...*/

#ifdef __cplusplus
}
#endif

to the header file in my static library. If you can't modify the library, you can also use

extern "C" {
#include "myclibrary.h"
}

in the main app.

Vala answered 21/8, 2024 at 14:24 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.