{"id":6188,"date":"2014-04-13T04:43:31","date_gmt":"2014-04-13T04:43:31","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/13\/problem-about-gcc4-7-collection-of-common-programming-errors\/"},"modified":"2014-04-13T04:43:31","modified_gmt":"2014-04-13T04:43:31","slug":"problem-about-gcc4-7-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/13\/problem-about-gcc4-7-collection-of-common-programming-errors\/","title":{"rendered":"problem about gcc4.7-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d73f203f59a6758f6ce70605d2c8b34a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nEvan Rolfe<br \/>\nc++ openni gcc4.7<br \/>\nI&#8217;m trying to compile an run a very basic program given below (test.cpp) which calls the OpenNI class. You can see the files and dirs they&#8217;re in here. Sorry that some characters screws up a little bit in the browser&#8217;s encoding. I&#8217;m using the linux command: tree, if you know a better command tell me and I will update it.File StructureI&#8217;m following the guide here, see &#8220;GCC \/ GNU Make&#8221;.#include &lt; stdio.h &gt; #include &lt; OpenNI.h &gt; using namespace openni; int main ( void ) { Status rc =<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3c1de37781df53a2997ed8dd85582564?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nbryan sammon<br \/>\nc++ c++11 noexcept gcc4.7<br \/>\nI am having some trouble wrapping my head around noexcept.template &lt;int SIZE&gt; int pop(int idx) noexcept(noexcept(SIZE &gt; 0)) \/\/ this is what I dont understand {if (idx &lt;= 0)throw std::out_of_range(&#8220;My array doesnt go that high&#8221;);return idx; }This is just a simple function, but you see how it only throws an exception when idx &lt;= 0, I dont understand. So in my specification, noexcept(idx &gt; 0), I am trying to tell the compilier this function ONLY throws no exceptions if idx &gt; 0. Am I<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/298b581e7243e197f7abf678c23e59f5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\n????<br \/>\nc++ c++11 gcc4.7<br \/>\nI&#8217;ve been playing with user defined constants in gcc 4.7.2 and ran into some sort of size limiting factors which I do not quite understand.The idea was to define a constexpr operator &#8220;&#8221; for fixed point decimal type. I want to avoid casting from double but rather parse mantissa and exponent at compilation time using variadic templates. The mantissa parsing proved a bit tricky.When I enable any of the 3 disabled lines at the bottom of the code below, gcc falls into infinite loop and hangs there. I<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3705bc45340e2c1fb2fef29977cb827a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsema<br \/>\ngcc ubuntu compilation ubuntu-12.04 gcc4.7<br \/>\nSince several versions of GCC and Ubuntu I am experiencing annoying issues with paths and naming of several header and object files that are necessary for the installation of GCC.Description: After installing ubuntu (e.g. in my case 12.04) and installing all prerequisites of the gcc, I run the following commands:sudo mkdir \/usr\/local\/stow\/gcc-4.8.0 .\/configure &#8211;prefix \/usr\/local\/stow\/gcc-4.8.0 make sudo make installFor the sake of completeness, the rest of the installation procedure:cd \/usr\/loc<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/815ee86e14bbedd4f353cad0680c7be5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMat<br \/>\nc++ g++ openmp opensuse gcc4.7<br \/>\nUsing the sample code at http:\/\/openmp.org\/wp\/openmp-compilers\/, I tried to run the simple program on my Linux machine (running OpenSUSE 12.2) but failed to get it to compile.Here is the sample code.#include &lt;omp.h&gt; #include &lt;stdio.h&gt; int main() { #pragma omp parallel printf(&#8220;Hello from thread %d, nthreads %d\\n&#8221;,omp_get_thread_num(), omp_get_num_threads()); }Snippet from the Terminal.Go Trojans &gt;g++ -fopenmp try_openmp.cpp \/usr\/lib64\/gcc\/x86_64-suse-linux\/4.7\/..\/..\/..\/..\/x86_64-su<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/38ba39c7ba510ac2951c010c26afb6a6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nildjarn<br \/>\nc++ c++11 opencl gcc4.7<br \/>\nI need to run several C++11 threads (GCC 4.7.1) parallely in host. Each of them needs to use a device, say a GPU. As per OpenCL 1.2 spec (p. 357):All OpenCL API calls are thread-safe75 except clSetKernelArg. clSetKernelArg is safe to call from any host thread, and is safe to call re-entrantly so long as concurrent calls operate on different cl_kernel objects. However, the behavior of the cl_kernel object is undefined if clSetKernelArg is called from multiple host threads on the same cl_kernel o<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fc3def070075447ea19e1ea70afcec1b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJ.N.<br \/>\nc++ c++11 gcc4.7<br \/>\nI have the following function defined in a header file (the library it is part of aims at being header-only):typedef bool (*FieldComparer)(const std::string&amp;, const std::string&amp;);inline FieldComparer GetComparer(const std::string&amp; query, string&amp; separator) {if (query.find(&#8216;=&#8217;) != std::string::npos) {separator = &#8220;=&#8221;;return [](const string&amp; s1, const string&amp; s2) { return s1 == s2; };}else if (query.find(&#8216;^&#8217;) != string::npos) {separator = &#8220;^&#8221;;return [](const string&amp; s1,<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8854a441d1fd8518cd87c2429fed15ef?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPotatoswatter<br \/>\nc++ osx dyld gcc4.7<br \/>\nI&#8217;ve compiled a command-line tool against some C++ dynamic libraries using GCC 4.7 on Mac OS X 10.8. On the development system, the compiler was installed by MacPorts into \/opt\/local and the libraries reside in \/usr\/local\/lib. The dynamic libraries are compiled from source alongside the program. (But they&#8217;re built by cmake and I don&#8217;t want to mess with that system.)When I try to run it on another machine by putting the necessary dylibs into the executable&#8217;s directory and DYLD_LIBRARY_PATH, it co<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f9341836ce1cf04cd7e128e4c8b1db99?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nThinkingStiff<br \/>\nandroid c++ shared gcc4.7<br \/>\nThis is a weird setup here. I compiled a custom NDK with GCC 4.7 (for Debian armhf chroot host). In testing, it compiles and runs regular c and c++ binaries on Android perfectly. When trying to compile a test shared library with C++ using:arm-linux-androideabi-g++ -fPIC -shared test.cpp -lstdc++ -o test.soI get numerous linker errors to _staticinitialization_destruction and _dso_handle being unreferenced.I have both libstdc++.a and libstdc++.so available in the lib folder under arm-linux-android<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fbc0a27049271cadb696ad956decbc79?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBo Persson<br \/>\ngcc include atomic gcc4.7<br \/>\nI&#8217;ve just compiled GCC 4.7 to work with stdatomic.h, but I can&#8217;t seem to -I it. stdatomic.h seems to live in \/usr\/include\/c++\/4.4.3, but then the linker tells me it needs a bunch of other files in dirs nearby. If I -I all of them, I still get the error undefined reference to atomic_flag_clear_explicit. Any ideas how I&#8217;m supposed to link this right?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b9acc359caf1d0bc7ebe3a294802b446?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser1594322<br \/>\nc++ gcc c++11 gcc4.7<br \/>\nHere&#8217;s what I am trying. MinGW g++ 4.7.0.#include &lt;iostream&gt; #include &lt;string&gt;class Fruit { public:enum Value { APPLE, ORANGE, BANANA, NONE };static const Value VALUES[4] = { APPLE, ORANGE, BANANA, NONE };Fruit (Value v = NONE) : v_(v) { };std::string to_string () const {switch (v_) {case APPLE: return &#8220;apple&#8221;;case ORANGE: return &#8220;orange&#8221;;case BANANA: return &#8220;banana&#8221;;default: return &#8220;none&#8221;;}} private:Value v_; };int main (int argc, char * argv[]) {for (Fruit f : Fruit::VALUES)std::co<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/ju9c8.jpg?s=32&amp;g=1\" \/><br \/>\nYu Hao<br \/>\nc++ gcc standard-library gcc4.7<br \/>\nI am a bit of a newbie as far as dealing with compilation\/linking errors. I&#8217;m working with a large C++ code (there are a few C files as well). I have successfully been running it on a Mac, compiled with g++. Now I need to run it on a Linux-based cluster because it is too slow on my Mac. The code consists of several libraries that I have to compile, plus my own code that uses the libraries. I can compile all of the code on the cluster using the default g++ compiler. However, unfortunately,<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0e82f80e9425499224de5ac2039771d3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ndidymos<br \/>\ngcc compilation gcc-warning gcc4.7<br \/>\nI am trying to compile local version of gcc 4.7.3 on the cluster. For configuration:.\/configure &#8211;prefix=$HOME\/opt\/gcc-4.7.3 &#8211;with-gmp=$HOME\/opt\/gmp &#8211;with-mpfr=$HOME\/opt\/mpfr &#8211;with-mpc=$HOME\/opt\/mpc &#8211;with-libelf=$HOME\/opt\/libelfwhile compiling I got:\/home\/users\/didymos\/opt\/gmp\/lib\/libgmp.a(pprime_p.o):(.text+0x448):undefined reference to `__multi3&#8217;\/home\/users\/didymos\/opt\/gmp\/lib\/libgmp.a(mod_1.o):(.text+0x158):undefined reference to `__multi3&#8217;\/home\/users\/didymos\/opt\/gmp\/lib\/libgmp.a(mod_1.o)<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/07123541fba3343f9ddb5876595b99a7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAlex<br \/>\nlinker-error static-linking icu unicode-string gcc4.7<br \/>\nI am trying to compile my project where I&#8217;ve declared as class members some:icu::UnicodeString label; icu::UnicodeString tags; icu::UnicodeString domain; icu::UnicodeString data;After having included (yes it is found)#include &lt;unicode\/unistr.h&gt;In my CMakeLists.txt it searches, finds and links with: icuuc icudata (libicuuc, libicudata) as the output suggests prior to throwing the errors:-o icarus -rdynamic -lPocoNet -lPocoUtil -lPocoXML -licuuc -licudataI have built and installed from sourc<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/57e19e92a761fe6dc5cd055afbc1d941?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsegfault<br \/>\nc++ qt gcc4.7<br \/>\nI&#8217;ve been developing with CentOS, Qt 4.7, and GCC 4.4I&#8217;ve just installed Red Hat Developer Toolset 1.1 which includes GCC 4.7.2, and at the end of make, I get an error \/usr\/bin\/ld: ..\/..\/bin\/Solo: undefined reference to symbol &#8216;pthread_rwlock_trywrlock@@GLIBC_2.2.5&#8217; \/usr\/bin\/ld: note: &#8216;pthread_rwlock_trywrlock@@GLIBC_2.2.5&#8217; is defined in DSO \/lib64\/libpthread.so.0 so try adding it to the linker command line \/lib64\/libpthread.so.0: could not read symbols: Invalid operation collect2: error: ld ret<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d3c16875cb7591dd6fee7fab692c0459?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPrakash<br \/>\ngcc gcc4.7<br \/>\nI was trying to write a plugin based upon following link : http:\/\/www.codesynthesis.com\/~boris\/blog\/2010\/05\/03\/parsing-cxx-with-gcc-plugin-part-1\/.Below is my code:#include &lt;stdlib.h&gt; #include &lt;gmp.h&gt;\/\/#include &lt;boost\/cstdlib.hpp&gt; \/\/ Include before GCC poisons\/\/ some declarations. #include &lt;gcc-plugin.h&gt;#include &lt;config.h&gt; #include &lt;system.h&gt; #include &lt;coretypes.h&gt; #include &lt;tree.h&gt; #include &lt;intl.h&gt;#include &lt;tm.h&gt;#include &lt;cp\/cp-tre<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3ae9214026b108bde85483362285f5af?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ndevnull<br \/>\ngcc dynamic-linking gfortran gcc4.7<br \/>\nMy distro (CentOS 6.3) comes with gcc 4.4.6. Since I wanted to try out the Fortran2003 features I decided to compile gcc 4.7.I followed the steps I found online: compiled separately first gmp, mpc, mpfr, ppl and cloog and the compiled gcc.I run the configured script as:configure &#8211;prefix=&#8230; &#8211;with-gmp=&#8230; &#8211;with-mpfr=&#8230; &#8211;with-mpc=&#8230; &#8211;program-suffix=-4.7 &#8211;enable-cloog-backend=isl &#8211;with-ppl=&#8230; &#8211;with-cloog=&#8230; &#8211;disable-multilibThis worked all right and I was able to compile with make &amp;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/522cfe0f3f3c90854067a62da3b6982c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSubramanian Ganapathy<br \/>\nboost macports gcc4.7 cpp-netlib<br \/>\nI&#8217;ve run into a very very hairy issue. My end goal is to build the cpp-netlib. cpp-netlib uses C++-11, it was throwing linker errors with original boost build in my machine. The reason I&#8217;d built boost using the default gcc installed in my machine, which works just fine. However, following the steps given in http:\/\/www.boost.org\/doc\/libs\/1_53_0\/more\/getting_started\/unix-variants.html {section 5.2 onwards} does not seem to help me. I&#8217;m getting errors like this..failed gcc.link.dll stage\/lib\/libboo<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Evan Rolfe c++ openni gcc4.7 I&#8217;m trying to compile an run a very basic program given below (test.cpp) which calls the OpenNI class. You can see the files and dirs they&#8217;re in here. Sorry that some characters screws up a little bit in the browser&#8217;s encoding. I&#8217;m using the linux command: tree, if you know [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6188","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6188"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6188\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}