{"id":2172,"date":"2022-05-11T07:06:25","date_gmt":"2022-05-11T14:06:25","guid":{"rendered":"https:\/\/cknotes.com\/?p=2172"},"modified":"2022-05-11T07:06:25","modified_gmt":"2022-05-11T14:06:25","slug":"undefined-reference-to-__res_query","status":"publish","type":"post","link":"https:\/\/cknotes.com\/undefined-reference-to-__res_query\/","title":{"rendered":"undefined reference to `__res_query&#8217;"},"content":{"rendered":"<p><strong>Question:<\/strong><\/p>\n<pre>\r\nTrying to link Chilkat (C++) with the following libs:\r\n\r\nLIBS=-lstdc++fs \\\r\n-pthread \\\r\n-L${FMT_LIB} -lfmt \\\r\n-lspdlog \\\r\n\/usr\/local\/lib\/libredis++.a \\\r\n${BOOST_LIB}\/libboost_json.a \\\r\n...\r\n...\r\n${CHILKAT_LIB}\/libchilkat-9.5.0.a \\\r\n-lmongoc-1.0 -lbson-1.0 \\\r\n-lpthread \\\r\n-ldl \\\r\n-lresolv\r\n\r\nAfter we went from ubuntu 21 to 22 LTS, using same compiler, it stopped working.\r\n\r\nNow we get errors:\r\n\r\n\/usr\/bin\/ld: ... libchilkat-9.5.0.a(ChilkatResolve.o): in function `ChilkatResolve::bestMxLookup(char const*, StringBuffer&, LogBase&, bool)':\r\nChilkatResolve.cpp:(.text+0x2c6): undefined reference to `__res_query'\r\n\r\n\/usr\/bin\/ld: ... libchilkat-9.5.0.a(ChilkatResolve.o): in function `ChilkatResolve::dkimLookup(char const*, StringBuffer&, LogBase&, bool)':\r\nChilkatResolve.cpp:(.text+0x47f): undefined reference to `__res_query'\r\n\r\n\/usr\/bin\/ld: ... libchilkat-9.5.0.a(ChilkatResolve.o): in function `ChilkatResolve::mxLookup(char const*, ScoredStrings&, LogBase&, bool)':\r\nChilkatResolve.cpp:(.text+0x64e): undefined reference to `__res_query'\r\n\r\ncollect2: error: ld returned 1 exit status\r\nmake: *** [Makefile:47: debug] Error 1\r\n\r\nWhen we change to dynamic linking, using -L${CHILKAT_LIB} -lchilkat-9.5.0 instead of ${CHILKAT_LIB}\/libchilkat-9.5.0.a  it builds.\r\n\r\n<\/pre>\n<p>res_query is part of the DNS resolver library.   See <a href=\"https:\/\/linux.die.net\/man\/3\/res_query\">https:\/\/linux.die.net\/man\/3\/res_query<\/a><\/p>\n<p>The man page for res_query tells you what must be linked, and it is <strong>&#8220;Link with -lresolv&#8221;<\/strong><\/p>\n<p>I can see you have &#8220;-lresolv&#8221; in  your list of LIBS.  However, you&#8217;re on a new machine, so it&#8217;s probably the case that the -lresolv library is not yet installed on the machine, or somehow it is not found.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Question: Trying to link Chilkat (C++) with the following libs: LIBS=-lstdc++fs \\ -pthread \\ -L${FMT_LIB} -lfmt \\ -lspdlog \\ \/usr\/local\/lib\/libredis++.a \\ ${BOOST_LIB}\/libboost_json.a \\ &#8230; &#8230; ${CHILKAT_LIB}\/libchilkat-9.5.0.a \\ -lmongoc-1.0 -lbson-1.0 \\ -lpthread \\ -ldl \\ -lresolv After we went from ubuntu 21 to 22 LTS, using same compiler, it stopped working. Now we get errors: \/usr\/bin\/ld: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[871],"tags":[872],"class_list":["post-2172","post","type-post","status-publish","format-standard","hentry","category-c-linking","tag-lresolv"],"_links":{"self":[{"href":"https:\/\/cknotes.com\/wp-json\/wp\/v2\/posts\/2172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cknotes.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cknotes.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cknotes.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cknotes.com\/wp-json\/wp\/v2\/comments?post=2172"}],"version-history":[{"count":1,"href":"https:\/\/cknotes.com\/wp-json\/wp\/v2\/posts\/2172\/revisions"}],"predecessor-version":[{"id":2173,"href":"https:\/\/cknotes.com\/wp-json\/wp\/v2\/posts\/2172\/revisions\/2173"}],"wp:attachment":[{"href":"https:\/\/cknotes.com\/wp-json\/wp\/v2\/media?parent=2172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cknotes.com\/wp-json\/wp\/v2\/categories?post=2172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cknotes.com\/wp-json\/wp\/v2\/tags?post=2172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}