Note that there are some explanatory texts on larger screens.

plurals
  1. POWeird posix message queue linking issue - sometimes it doesn't link correctly
    text
    copied!<p>When I build the following code, it builds fine. If I change the code to comment out the "while", using the same command line, it does not build (see below)</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;mqueue.h&gt; int main(int argc, char *argv[]) { while (1) { } mq_open("/YouSUCK", O_RDWR | O_CREAT | O_EXCL, S_IRWXU | S_IRWXG, NULL); return 0; } </code></pre> <p>dada@thud:~/RaspberryPI$ gcc -g -Wall -lrt -o mqtest mqtest.c</p> <p>dada@thud:~/RaspberryPI$ </p> <pre><code>#include &lt;stdio.h&gt; #include &lt;mqueue.h&gt; int main(int argc, char *argv[]) { // while (1) { } mq_open("/YouSUCK", O_RDWR | O_CREAT | O_EXCL, S_IRWXU | S_IRWXG, NULL); return 0; } </code></pre> <p>dada@thud:~/RaspberryPI$ gcc -g -Wall -lrt -o mqtest mqtest.c</p> <p>/tmp/cccw376u.o: In function `main':</p> <p>/home/dada/RaspberryPI/mqtest.c:7: undefined reference to `mq_open'</p> <p>collect2: ld returned 1 exit status</p> <p>dada@thud:~/RaspberryPI$</p> <p>Any ideas ?</p> <p>dada@thud:~/RaspberryPI$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)</p> <p>Thanks ! Joe</p> <p>Update: Looks like a compiler verion issue, I built the same code on a different box, and it builds properly with either of the above files. So I guess I need a different compiler. </p> <p>dada@JoesPi ~ $ gcc -v</p> <p>Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.6/lto-wrapper Target: arm-linux-gnueabihf Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-14+rpi1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf Thread model: posix gcc version 4.6.3 (Debian 4.6.3-14+rpi1)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload