Results 1 to 11 of 11

Thread: lib("dnsapi")

  1. #1

    Default lib("dnsapi")

    Hi,

    Im currently making an new DNS Server, But QT does give the follow error's while compiling:

    dnsserv\dnssrv_win.cpp(10) : error C2059: syntax error : '('
    dnsserv\dnssrv_win.cpp(12) : error C2059: syntax error : '('
    dnsserv\dnssrv_win.cpp(19) : error C2065: 'DNS_QUERY' : undeclared identifier
    dnsserv\dnssrv_win.cpp(19) : error C2146: syntax error : missing ';' before identifier 'dnsQuery'
    dnsserv\dnssrv_win.cpp(19) : error C2065: 'dnsQuery' : undeclared identifier
    dnsserv\dnssrv_win.cpp(19) : error C2146: syntax error : missing ';' before identifier 'lib'
    dnsserv\dnssrv_win.cpp(20) : error C2065: 'DNS_FREE' : undeclared identifier
    dnsserv\dnssrv_win.cpp(20) : error C2146: syntax error : missing ';' before identifier 'dnsFree'
    dnsserv\dnssrv_win.cpp(20) : error C2065: 'dnsFree' : undeclared identifier
    dnsserv\dnssrv_win.cpp(20) : error C2146: syntax error : missing ';' before identifier 'lib'
    dnsserv\dnssrv_win.cpp(27) : error C3861: 'dnsQuery': identifier not found
    dnsserv\dnssrv_win.cpp(47) : error C3861: 'dnsFree': identifier not found
    Generating Code...

    NMAKE : fatal error U1077: 'cl' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\nmake.exe"' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: 'cd' : return code '0x2'
    Stop.
    The source file is currently:

    Qt Code:
    1. #include "dnssrv.h"
    2. #include <QLibrary>
    3. #include <windows.h>
    4. #include <windns.h>
    5.  
    6. #ifndef DNS_QUERY_SRV
    7. #define DNS_QUERY_SRV 0x0021
    8. #endif
    9.  
    10. typedef DNS_STATUS WINAPI (*DNS_QUERY)(PCSTR, WORD, DWORD, PIP4_ARRAY, PDNS_RECORD *, PVOID *);
    11. typedef void WINAPI (*DNS_FREE)(PVOID, DNS_FREE_TYPE);
    12.  
    13. QList<DnsSrv::Server> DnsSrv::resolve(const QString &name)
    14. {
    15. QList<DnsSrv::Server> servers;
    16.  
    17. QLibrary lib("dnsapi");
    18. DNS_QUERY dnsQuery = (DNS_QUERY) lib.resolve("DnsQuery_UTF8");
    19. DNS_FREE dnsFree = (DNS_FREE) lib.resolve("DnsFree");
    20. if (dnsQuery == NULL || dnsFree == NULL) {
    21. qDebug("Windows does not support DnsQuery");
    22. goto failed;
    23. }
    24.  
    25. PDNS_RECORD rr;
    26. if (dnsQuery(name.toUtf8(), DNS_QUERY_SRV,
    27. DNS_QUERY_STANDARD, NULL, &rr, NULL) != 0)
    28. goto failed;
    29.  
    30. name.toLower();
    31. for (PDNS_RECORD p = rr; p != NULL; p = p->pNext) {
    32. if (p->wType != DNS_QUERY_SRV ||
    33. QString((char *) p->pName).toLower() != name)
    34. continue;
    35.  
    36. DNS_SRV_DATA *srv = &p->Data.Srv;
    37.  
    38. DnsSrv::Server res;
    39. res.ttl = p->dwTtl;
    40. res.priority = srv->wPriority;
    41. res.weight = srv->wWeight;
    42. res.port = srv->wPort;
    43. res.target = (char *) srv->pNameTarget;
    44. servers.append(res);
    45. }
    46. dnsFree(rr, DnsFreeRecordList);
    47.  
    48. failed:
    49. lib.unload();
    50. return servers;
    51. }
    To copy to clipboard, switch view to plain text mode 

    How do I fix those error's? Im with my hands in my hair. Thank you.
    Last edited by CHeader; 15th February 2008 at 19:42.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: lib("dnsapi")

    Does windns.h define DNS_QUERY and DNS_FREE?
    J-P Nurmi

  3. #3

    Default Re: lib("dnsapi")

    This is really dump, I get confused. Stupid heh?

    This is my header file:

    Qt Code:
    1. #ifndef DNSSRV_H
    2. #define DNSSRV_H
    3.  
    4. #include <QThread>
    5. #include <QList>
    6.  
    7. class DnsSrv : public QThread {
    8. Q_OBJECT
    9. public:
    10. class Server {
    11. public:
    12. Server();
    13. bool operator <(const Server &rr) const;
    14. bool operator ==(const Server &rr) const;
    15.  
    16. QString target;
    17. int ttl;
    18. int port;
    19. int priority;
    20. int weight;
    21. };
    22.  
    23. DnsSrv(QObject *parent = 0);
    24. virtual ~DnsSrv();
    25.  
    26. void query(const QString &name);
    27. QList<Server> getResults() { return servers; }
    28.  
    29. signals:
    30. void resultsReady();
    31.  
    32. private:
    33. virtual void run();
    34. QList<Server> resolve(const QString &name);
    35.  
    36. QString targetName;
    37. QList<Server> servers;
    38. };
    39.  
    40. #endif
    To copy to clipboard, switch view to plain text mode 

    The compile gives now:

    1>dnssrv.obj : error LNK2019: unresolved external symbol "private: class QList<class DnsSrv::Server> __thiscall DnsSrv::resolve(class QString const &)" (?resolve@DnsSrv@@AAE?AV?$QList@VServer@DnsSrv@@@@ ABVQString@@@Z) referenced in function "private: virtual void __thiscall DnsSrv::run(void)" (?run@DnsSrv@@EAEXXZ)
    Last edited by jpn; 16th February 2008 at 10:46. Reason: changed [quote] to [code] tags

  4. #4

    Default Re: lib("dnsapi")

    Im stupid, I've posted another header file that was included in dnssrv_win.cpp.

    Anyway, this is the windns.h file you asked for, Its zipped because the file was too large to post here. I cannot find directly the define's of DNS_FREE and DNS_QUERY.

    The follow error appears when compiling now:
    QList<DnsSrv::Server> DnsSrv::resolve(const QString &name)
    Attached Files Attached Files
    Last edited by CHeader; 16th February 2008 at 12:14.

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: lib("dnsapi")

    I'm not really a WinAPI expert so I don't know about possible side effects it causes but this at least compiles for me as soon as I comment out the WINAPI part:
    Qt Code:
    1. // main.cpp
    2. #include <windows.h>
    3. #include <windns.h>
    4.  
    5. typedef DNS_STATUS /*WINAPI*/ (*DNS_QUERY)(PCSTR, WORD, DWORD, PIP4_ARRAY, PDNS_RECORD *, PVOID *);
    6. typedef void /*WINAPI*/ (*DNS_FREE)(PVOID, DNS_FREE_TYPE);
    7.  
    8. int main()
    9. {
    10. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  6. #6

    Default Re: lib("dnsapi")

    Well, I've did what you've tested right now, Seems to be not working now.

    There's in dnssrv_win.cpp a couple of compile errors:

    1>------ Build started: Project: dnsserv, Configuration: Release Win32 ------
    1>Compiling...
    1>dnssrv_win.cpp
    1>.\dnsserv\dnssrv_win.cpp(10) : error C2143: syntax error : missing ';' before '__stdcall'
    1>.\dnsserv\dnssrv_win.cpp(10) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>.\dnsserv\dnssrv_win.cpp(10) : error C2059: syntax error : '('
    1>.\dnsserv\dnssrv_win.cpp(11) : error C2059: syntax error : '('
    1>.\dnsserv\dnssrv_win.cpp(18) : error C2065: 'DNS_QUERY' : undeclared identifier
    1>.\dnsserv\dnssrv_win.cpp(18) : error C2146: syntax error : missing ';' before identifier 'dnsQuery'
    1>.\dnsserv\dnssrv_win.cpp(18) : error C2065: 'dnsQuery' : undeclared identifier
    1>.\dnsserv\dnssrv_win.cpp(18) : error C2146: syntax error : missing ';' before identifier 'lib'
    1>.\dnsserv\dnssrv_win.cpp(19) : error C2065: 'DNS_FREE' : undeclared identifier
    1>.\dnsserv\dnssrv_win.cpp(19) : error C2146: syntax error : missing ';' before identifier 'dnsFree'
    1>.\dnsserv\dnssrv_win.cpp(19) : error C2065: 'dnsFree' : undeclared identifier
    1>.\dnsserv\dnssrv_win.cpp(19) : error C2146: syntax error : missing ';' before identifier 'lib'
    1>.\dnsserv\dnssrv_win.cpp(25) : error C2065: 'PDNS_RECORD' : undeclared identifier
    1>.\dnsserv\dnssrv_win.cpp(25) : error C2146: syntax error : missing ';' before identifier 'rr'
    1>.\dnsserv\dnssrv_win.cpp(25) : error C2065: 'rr' : undeclared identifier
    1>.\dnsserv\dnssrv_win.cpp(27) : error C2065: 'DNS_QUERY_STANDARD' : undeclared identifier
    1>.\dnsserv\dnssrv_win.cpp(26) : error C3861: 'dnsQuery': identifier not found
    1>.\dnsserv\dnssrv_win.cpp(31) : error C2146: syntax error : missing ';' before identifier 'p'
    1>.\dnsserv\dnssrv_win.cpp(31) : error C2065: 'p' : undeclared identifier
    1>.\dnsserv\dnssrv_win.cpp(31) : error C2146: syntax error : missing ')' before identifier 'p'
    1>.\dnsserv\dnssrv_win.cpp(31) : error C2059: syntax error : ';'
    1>.\dnsserv\dnssrv_win.cpp(31) : error C2227: left of '->pNext' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\dnsserv\dnssrv_win.cpp(31) : error C2059: syntax error : ')'
    1>.\dnsserv\dnssrv_win.cpp(31) : error C2143: syntax error : missing ';' before '{'
    1>.\dnsserv\dnssrv_win.cpp(32) : error C2227: left of '->wType' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\dnsserv\dnssrv_win.cpp(33) : error C2227: left of '->pName' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\dnsserv\dnssrv_win.cpp(33) : error C2228: left of '.toLower' must have class/struct/union
    1>.\dnsserv\dnssrv_win.cpp(34) : error C2044: illegal continue
    1>.\dnsserv\dnssrv_win.cpp(36) : error C2065: 'DNS_SRV_DATA' : undeclared identifier
    1>.\dnsserv\dnssrv_win.cpp(36) : error C2065: 'srv' : undeclared identifier
    1>.\dnsserv\dnssrv_win.cpp(36) : error C2227: left of '->Data' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\dnsserv\dnssrv_win.cpp(36) : error C2228: left of '.Srv' must have class/struct/union
    1>.\dnsserv\dnssrv_win.cpp(39) : error C2227: left of '->dwTtl' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\dnsserv\dnssrv_win.cpp(40) : error C2227: left of '->wPriority' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\dnsserv\dnssrv_win.cpp(41) : error C2227: left of '->wWeight' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\dnsserv\dnssrv_win.cpp(42) : error C2227: left of '->wPort' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\dnsserv\dnssrv_win.cpp(43) : error C2227: left of '->pNameTarget' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\dnsserv\dnssrv_win.cpp(46) : error C2065: 'DnsFreeRecordList' : undeclared identifier
    1>.\dnsserv\dnssrv_win.cpp(46) : error C3861: 'dnsFree': identifier not found
    1>dnsserv - 39 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Agian olso the modified source file:

    Qt Code:
    1. #include "dnssrv.h"
    2. #include <QLibrary>
    3. #include <windows.h>
    4.  
    5.  
    6. #ifndef DNS_QUERY_SRV
    7. #define DNS_QUERY_SRV 0x0021
    8. #endif
    9.  
    10. typedef DNS_STATUS WINAPI (*DNS_QUERY)(PCSTR, WORD, DWORD, PIP4_ARRAY, PDNS_RECORD *, PVOID *);
    11. typedef void WINAPI (*DNS_FREE)(PVOID, DNS_FREE_TYPE);
    12.  
    13. QList<DnsSrv::Server> DnsSrv::resolve(const QString &name)
    14. {
    15. QList<DnsSrv::Server> servers;
    16.  
    17. QLibrary lib("dnsapi");
    18. DNS_QUERY dnsQuery = (DNS_QUERY) lib.resolve("DnsQuery_UTF8");
    19. DNS_FREE dnsFree = (DNS_FREE) lib.resolve("DnsFree");
    20. if (dnsQuery == NULL || dnsFree == NULL) {
    21. qDebug("Windows does not support DnsQuery");
    22. goto failed;
    23. }
    24.  
    25. PDNS_RECORD rr;
    26. if (dnsQuery(name.toUtf8(), DNS_QUERY_SRV,
    27. DNS_QUERY_STANDARD, NULL, &rr, NULL) != 0)
    28. goto failed;
    29.  
    30. name.toLower();
    31. for (PDNS_RECORD p = rr; p != NULL; p = p->pNext) {
    32. if (p->wType != DNS_QUERY_SRV ||
    33. QString((char *) p->pName).toLower() != name)
    34. continue;
    35.  
    36. DNS_SRV_DATA *srv = &p->Data.Srv;
    37.  
    38. DnsSrv::Server res;
    39. res.ttl = p->dwTtl;
    40. res.priority = srv->wPriority;
    41. res.weight = srv->wWeight;
    42. res.port = srv->wPort;
    43. res.target = (char *) srv->pNameTarget;
    44. servers.append(res);
    45. }
    46. dnsFree(rr, DnsFreeRecordList);
    47.  
    48. failed:
    49. lib.unload();
    50. return servers;
    51. }
    To copy to clipboard, switch view to plain text mode 

    Maybe this oucld help solving you something?
    Last edited by jpn; 16th February 2008 at 12:52. Reason: changed [quote] to [code] tags

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: lib("dnsapi")

    Huh? I don't see anything else changed but you left the required <windns.h> header out?
    J-P Nurmi

  8. #8

    Default Re: lib("dnsapi")

    My mistake haha, When I include <windns.h> there are 4 error's (Mainly define's maybe?) and when I remove the include. I get 39 error's.

    I've included the <windns.h> file and now this is the result:

    1>------ Build started: Project: dnsserv, Configuration: Release Win32 ------
    1>Compiling...
    1>dnssrv_win.cpp
    1>.\dnsserv\dnssrv_win.cpp(24) : error C2143: syntax error : missing ';' before '='
    1>.\dnsserv\dnssrv_win.cpp(25) : error C2143: syntax error : missing ';' before '='
    1>.\dnsserv\dnssrv_win.cpp(26) : error C2059: syntax error : '=='
    1>.\dnsserv\dnssrv_win.cpp(26) : error C2143: syntax error : missing ';' before '{'
    1>dnsserv - 4 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    The file looks like this:

    Qt Code:
    1. #include <QLibrary>
    2. #include "dnssrv.h"
    3. #include <windows.h>
    4. #include <windns.h>
    5.  
    6. #define DNS_QUERY
    7. #define DNS_FREE
    8.  
    9. #define dnsFree
    10. #define dnsQuery
    11.  
    12. #ifndef DNS_QUERY_SRV
    13. #define DNS_QUERY_SRV 0x0021
    14. #endif
    15.  
    16. //typedef DNS_STATUS WINAPI (*DNS_QUERY)(PCSTR, WORD, DWORD, PIP4_ARRAY, PDNS_RECORD *, PVOID *);
    17. //typedef void WINAPI (*DNS_FREE)(PVOID, DNS_FREE_TYPE);
    18.  
    19. QList<DnsSrv::Server> DnsSrv::resolve(const QString &name)
    20. {
    21. QList<DnsSrv::Server> servers;
    22.  
    23. QLibrary lib("dnsapi");
    24. DNS_QUERY dnsQuery = (DNS_QUERY) lib.resolve("DnsQuery_UTF8");
    25. DNS_FREE dnsFree = (DNS_FREE) lib.resolve("DnsFree");
    26. if (dnsQuery == NULL || dnsFree == NULL) {
    27. qDebug("Windows does not support DnsQuery");
    28. goto failed;
    29. }
    30.  
    31. PDNS_RECORD rr;
    32. if (dnsQuery(name.toUtf8(), DNS_QUERY_SRV,
    33. DNS_QUERY_STANDARD, NULL, &rr, NULL) != 0)
    34. goto failed;
    35.  
    36. name.toLower();
    37. for (PDNS_RECORD p = rr; p != NULL; p = p->pNext) {
    38. if (p->wType != DNS_QUERY_SRV ||
    39. QString((char *) p->pName).toLower() != name)
    40. continue;
    41.  
    42. DNS_SRV_DATA *srv = &p->Data.Srv;
    43.  
    44. DnsSrv::Server res;
    45. res.ttl = p->dwTtl;
    46. res.priority = srv->wPriority;
    47. res.weight = srv->wWeight;
    48. res.port = srv->wPort;
    49. res.target = (char *) srv->pNameTarget;
    50. servers.append(res);
    51. }
    52. dnsFree(rr, DnsFreeRecordList);
    53.  
    54. failed:
    55. lib.unload();
    56. return servers;
    57. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by CHeader; 16th February 2008 at 13:24. Reason: Re-inform people about the progress

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: lib("dnsapi")

    Take a new look at post #5. They're used as function pointers so you can't replace them with empty defines.
    J-P Nurmi

  10. #10

    Default Re: lib("dnsapi")

    Mhh. That would return me 6 errors.
    Last edited by CHeader; 16th February 2008 at 19:21. Reason: Updated contents

  11. #11

    Default Re: lib("dnsapi")

    Okay. After some hours of testing and headers and stuff the follow situation is here:

    My source file is as follow right now:
    Qt Code:
    1. #include <QLibrary>
    2. #include "dnssrv.h"
    3. #include <windows.h>
    4. #include <windns.h>
    5.  
    6. #ifdef DNS_QUERY
    7. #define dnsQuery
    8. #warning DNS_QUERY is already defined.
    9. #endif
    10.  
    11. #ifdef DNS_FREE
    12. #define dnsFree
    13. #warning DNS_FREE is already defined.
    14. #endif
    15.  
    16. #ifndef DNS_QUERY_SRV
    17. #define DNS_QUERY_SRV 0x0021
    18. #endif
    19.  
    20. // typedef DNS_STATUS WINAPI (*DNS_QUERY)(PCSTR, WORD, DWORD, PIP4_ARRAY, PDNS_RECORD *, PVOID *);
    21. // typedef void WINAPI (*DNS_FREE)(PVOID, DNS_FREE_TYPE);
    22. typedef DNS_STATUS WINAPI (*)(PCSTR, WORD, DWORD, PIP4_ARRAY, PDNS_RECORD *, PVOID *)
    23.  
    24. QList<DnsSrv::Server> DnsSrv::resolve(const QString &name)
    25. {
    26. QList<DnsSrv::Server> servers;
    27.  
    28. QLibrary lib("dnsapi");
    29. DNS_QUERY dnsQuery = (DNS_QUERY) lib.resolve("DnsQuery_UTF8");
    30. DNS_FREE dnsFree = (DNS_FREE) lib.resolve("DnsFree");
    31. if (dnsQuery == NULL || dnsFree == NULL) {
    32. qDebug("Windows does not support DnsQuery");
    33. goto failed;
    34. }
    35.  
    36. PDNS_RECORD rr;
    37. if (dnsQuery(name.toUtf8(), DNS_QUERY_SRV,
    38. DNS_QUERY_STANDARD, NULL, &rr, NULL) != 0)
    39. goto failed;
    40.  
    41. name.toLower();
    42. for (PDNS_RECORD p = rr; p != NULL; p = p->pNext) {
    43. if (p->wType != DNS_QUERY_SRV ||
    44. QString((char *) p->pName).toLower() != name)
    45. continue;
    46.  
    47. DNS_SRV_DATA *srv = &p->Data.Srv;
    48.  
    49. DnsSrv::Server res;
    50. res.ttl = p->dwTtl;
    51. res.priority = srv->wPriority;
    52. res.weight = srv->wWeight;
    53. res.port = srv->wPort;
    54. res.target = (char *) srv->pNameTarget;
    55. servers.append(res);
    56. }
    57. dnsFree(rr, DnsFreeRecordList);
    58.  
    59. failed:
    60. lib.unload();
    61. return servers;
    62. }
    To copy to clipboard, switch view to plain text mode 

    Compiling log:
    Qt Code:
    1. 1>------ Build started: Project: dnssrv, Configuration: Release Win32 ------
    2. 1>Compiling...
    3. 1>dnssrv_win.cpp
    4. 1>.\dnssrv\dnssrv_win.cpp(22) : error C2059: syntax error : '('
    5. 1>.\dnssrv\dnssrv_win.cpp(25) : error C2143: syntax error : missing ';' before '{'
    6. 1>.\dnssrv\dnssrv_win.cpp(25) : error C2447: '{' : missing function header (old-style formal list?)
    7. 1>dnssrv - 3 error(s), 0 warning(s)
    8. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    To copy to clipboard, switch view to plain text mode 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.