PDA

View Full Version : Library Compilation issue



anurag.cs
10th September 2012, 18:02
Hello There,

I am compiling gloox library in QT Creator. This library using "windns.h" header file. When i compile same library code in MSVC it compiled successfuly while in QT it always gives below error:

..\glooxlib\dns.cpp:176: error: no match for 'operator[]' in 'servers[pRec->_DnsRecord::Data._DnsRecord::<anonymous union>::SRV.DNS_SRV_DATA::pNameTarget]'
c:\qt\2010.04\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/stl_map.h:442: note: candidates are: _Tp& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const _Key&) [with _Key = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _Tp = int, _Compare = std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, _Alloc = std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int> >]

In code there is a function DnsQuery_UTF8 which comes from windns.h.
windns.h is available in mingw. windns needs dnsapi.lib library, so i addedd it to .pro file.

win32:LIBS += "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\DnsAPI.lib"

But i am still getting same error message.

ChrisW67
12th September 2012, 00:21
In short, you have a problem compiling (this is a compiler not linker error) a 3rd-party library using Windows API code with MingW. Nothing to do with Qt.

The std::map has std::string keys and pNameTarget (LPTSTR) is is not std::string or something implicitly convertible. This may be a UNICODE/non-UNICODE issue, especially in light of the comments a few lines earlier in the source file.