When I was trying to run a barcode reader app compiled by MinGW GCC on Windows 10, I got an error message “The procedure entry point _ZNSt18condition_variable10notify_oneEv could not be located in the dynamic link library”. In this article, I will share my experience of how to solve the issue on Windows 10.
A Barcode Reader App Built with MinGW GCC
After setting up my MinGW environment, I wondered whether it is possible to link MSVC DLLs straightforward. The answer from StackOverflow is NO. MSVC cannot use the MinGW library and vice versa.
Because Dynamsoft R&D team has internally built a libDynamsoftBarcodeReader.dll file and a libDynamsoftBarcodeReader.dll.a file using MinGW GCC, I can use the libraries to build my app with MinGW GCC:
gcc -o demo ReadBarcode.cpp -L . -lDynamsoftBarcodeReader -lstdc++
Unfortunately, the app failed to run in my environment:
I Googled the error message and found it is related to libstdc++. How can I tackle the issue?
The Process of Finding the Answer
First, I need a tool to view the Windows DLL dependencies and relevant function symbols. There is a powerful tool “dumpbin” located in Visual Studio. If we type in dumpbin in cmd.exe, it cannot be recognized. A simple way is to run the tool in the Visual Studio command-line tool.
dumpbin /dependents D:\dbr-linux-7.4\Dynamsoft\BarcodeReader\samples\c++\ReadBarcode\demo.exe
The dependent libstdc++-6.dll could be found under the MinGW directory. The next step is to export function symbols from libstdc++-6.dll:
dumpbin /exports C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\libstdc++-6.dll
I saved dumps to a text file and found the so-called missing function _ZNSt18condition_variable10notify_oneEv.
Since the function symbol is out there, probably another libstdc++ lib which does not contain the function was loaded when running my app.
The library finding paths are stored in System Properties > Advanced > Environment Variables > System Variables > Paths.
By using a binary search, I locked QEMU which is above the MinGW path.
I exported the symbols of the QEMU libstdc++-6.dll and found there is no _ZNSt18condition_variable10notify_oneEv inside.
I made a simple test: remove the libstdc++ file from the QEMU directory and run my app again. The app built with MinGW GCC finally worked.