Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

gcc

mingw-w64

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.

like image 641
Chameleon Avatar asked Aug 20 '20 18:08

Chameleon


1 Answers

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).

like image 57
Chameleon Avatar answered Oct 19 '22 14:10

Chameleon