{"id":448,"date":"2016-05-18T13:03:49","date_gmt":"2016-05-18T11:03:49","guid":{"rendered":"http:\/\/paguilar.org\/?p=448"},"modified":"2016-05-18T13:03:49","modified_gmt":"2016-05-18T11:03:49","slug":"skipping-incompatible-liblibc-so-6-when-searching-for-liblibc-so-6","status":"publish","type":"post","link":"https:\/\/paguilar.org\/?p=448","title":{"rendered":"Skipping incompatible \/lib\/libc.so.6 when searching for \/lib\/libc.so.6"},"content":{"rendered":"<p>When cross-building a program (but this could also happen when building natively), it&#8217;s normal that we don&#8217;t have the environment variables and building flags set with the right paths that indicate where the toolchain and the sysroot are.<\/p>\n<p>The wrong paths can lead to many types of building errors at different stages. This one happened to me recently:<\/p>\n<pre lang=\"bash\">\r\narm-linux-gnueabi-gcc -L\/opt\/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabi\/qt5\/arm-buildroot-linux-gnueabi\/sysroot\/lib -L\/opt\/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabi\/qt5\/arm-buildroot-linux-gnueabi\/sysroot\/lib32 -L\/opt\/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabi\/qt5\/arm-buildroot-linux-gnueabi\/sysroot\/usr\/lib -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lz myfile.o -o myfile\r\n\/opt\/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabi\/bin\/..\/lib\/gcc\/arm-linux-gnueabi\/4.9.3\/..\/..\/..\/..\/arm-linux-gnueabi\/bin\/ld: skipping incompatible \/lib\/libc.so.6 when searching for \/lib\/libc.so.6\r\ncollect2: error: ld returned 1 exit status\r\n<\/pre>\n<p>This linking error says that it is skipping an incompatible library that is searching in my host&#8217;s filesystem even though I explicitly indicated in the Makefile the paths to use in the environment variable LDFLAGS with the <strong>-L<\/strong>:<\/p>\n<pre lang=\"bash\">\r\nLDFLAGS = -L$(SYSROOT)\/lib -L$(SYSROOT)\/lib32 -L$(SYSROOT)\/usr\/lib -pthread -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lz \r\n<\/pre>\n<p>The $SYSROOT environment variable was set correctly<\/p>\n<p>To indicate the linker to use the right path you have to add the <strong>-Xlinker -rpath-link=\/your\/sysroot\/path<\/strong> directives.<\/p>\n<p>For adding the <em>\/lib<\/em> and <em>\/usr\/lib<\/em> path that are in my sysroot, the previous setting of LDFLAGS becomes:<\/p>\n<pre lang=\"bash\">\r\nLDFLAGS = -L$(SYSROOT)\/lib -L$(SYSROOT)\/lib32 -L$(SYSROOT)\/usr\/lib -Xlinker -rpath-link=$(SYSROOT)\/lib -Xlinker -rpath-link=$(SYSROOT)\/usr\/lib -pthread -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lz \r\n<\/pre>\n<p>Now the linker does not complain anymore.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When cross-building a program (but this could also happen when building natively), it&#8217;s normal that we don&#8217;t have the environment variables and building flags set with the right paths that indicate where the toolchain and the sysroot are. The wrong paths can lead to many types of building errors at different stages. This one happened\u2026 <span class=\"read-more\"><a href=\"https:\/\/paguilar.org\/?p=448\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61,6,45],"tags":[],"class_list":["post-448","post","type-post","status-publish","format-standard","hentry","category-buildroot","category-compiling","category-linux"],"_links":{"self":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/448","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=448"}],"version-history":[{"count":6,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/448\/revisions"}],"predecessor-version":[{"id":454,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/448\/revisions\/454"}],"wp:attachment":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}