Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Include<boost/shared_ptr> doesn't compile with QNX 6.6 QCC and c++11: (9 Items)
   
Include<boost/shared_ptr> doesn't compile with QNX 6.6 QCC and c++11  
Hi QNX folks,

Using the std=c++11, QNX 6.6 QCC threw a compile error when I included boost/shared_ptr.
#include <boost/shared_ptr.hpp>

In file included from /home/test/qnx/ThirdParty/boost_1_55_0/boost/smart_ptr/detail/spinlock_sync.hpp:18:0,
                 from /home/test/qnx/ThirdParty/boost_1_55_0/boost/smart_ptr/detail/spinlock.hpp:41,
                 from /home/test/qnx/ThirdParty/boost_1_55_0/boost/smart_ptr/detail/spinlock_pool.hpp:25,
                 from /home/test/qnx/ThirdParty/boost_1_55_0/boost/smart_ptr/shared_ptr.hpp:38,
                 from /home/test/qnx/ThirdParty/boost_1_55_0/boost/shared_ptr.hpp:17,
                 from /home/test/qnx/TestProgram/math/math.cpp:5:
/home/test/qnx/ThirdParty/boost_1_55_0/boost/smart_ptr/detail/yield_k.hpp: In function 'void boost::detail::
yield(unsigned int)':
/home/test/qnx/ThirdParty/boost_1_55_0/boost/smart_ptr/detail/yield_k.hpp:122:29: error: 'nanosleep' was not declared in
 this scope
cc: /opt/qnx660/host/linux/x86/usr/lib/gcc/arm-unknown-nto-qnx6.6.0eabi/4.7.3/cc1plus error 1
make[2]: *** [TestProgram/math/CMakeFiles/testapp.math.dir/math.cpp.o] Error 1
make[1]: *** [TestProgram/math/CMakeFiles/testapp.math.dir/all] Error 2


Is this a boost issue or the QNX 6.6 toolchain issue?

Best regards,
Anton
Re: Include<boost/shared_ptr> doesn't compile with QNX 6.6 QCC and c++11  
Did you solve this? I've encountered the same problem.

It seems like the toolset is linking to the Dinkum's time.h header:
http://www.qnx.com/developers/docs/660/topic/com.qnx.doc.dinkum/topic/cpp11/time.html

instead of the C Library's time.h:
http://www.qnx.com/developers/docs/660/topic/com.qnx.doc.neutrino.lib_ref/topic/n/nanosleep.html

Is it possible to link correctly without updating #include <time.h> using an absolute path instead.
Re: Include<boost/shared_ptr> doesn't compile with QNX 6.6 QCC and c++11  
When -std=c++11 is used it will enable __STRICT_ANSI__ causing us to disable extensions, like POSIX, in the headers. 
nanosleep() is not part of C++11, so it will not be available when using this option.

You can use -std=gnu++11, or fiddle with the feature macros like _POSIX_C_SOURCE to enable the POSIX extensions and get 
nanosleep() as expected.
Re: Include<boost/shared_ptr> doesn't compile with QNX 6.6 QCC and c++11  
Thanks!

I can now "successfully" build the boost libraries. The reason I put the successfully in quotations is because some of 
the libraries doesn't seems to function as expected. When dynamically linking to for example the unit_test_framework, 
its fine to build, but when I run the app I get a "Library cannot be found".

Checking for dependency on for example /libboost_unit_test_framework.so (using ldd) results in:
  libboost_unit_test_framework.so => /home/alex/qnx/660/bin/boost/libboost_unit_test_framework-qcc-mt-1_60.so.1.60.0 
(0xb8200000)
ldd: Library cannot be found

It doesn't event say which library that couldn't be found... ?

I've cross-compiled boost using qcc 4.7.3. 

Any thoughts? Thanks
Re: Include<boost/shared_ptr> doesn't compile with QNX 6.6 QCC and c++11  
Well that's not ideal.

Try running the unittests or ldd with the environment variable LD_DEBUG=libs. This will print some additional 
information on libraries as they get loaded, and should at least print the name before hitting the failure.
Re: Include<boost/shared_ptr> doesn't compile with QNX 6.6 QCC and c++11  
I actually found the issue but I don't have a good solution (just a very awkward solution):

Doing an objdump on the unit-test-framework resulted in:

Dynamic Section:
   NEEDED               bin.v2\libs\timer\build\qcc\release\target-os-qnx\threadapi-pthread\threading-multi\
libboost_timer-qcc-mt-1_60.so.1.60.0
   NEEDED               bin.v2\libs\system\build\qcc\release\target-os-qnx\threadapi-pthread\threading-multi\
libboost_system-qcc-mt-1_60.so.1.60.0
   NEEDED               libm.so.2
   NEEDED               libc.so.3

As you can see there is a ridiculous path to link to both the timer and the system library. I've manually edited the 
library's binary-file and removed the path (this is the awkward part...) to:

Dynamic Section:
   NEEDED               libboost_timer-qcc-mt-1_60.so.1.60.0
   NEEDED               libboost_system-qcc-mt-1_60.so.1.60.0
   NEEDED               libm.so.2
   NEEDED               libc.so.3

Which works. Is it possible to force Boost to not include the entire path into the library? Is this a boost issue or a 
qcc toolchain issue? I really don't want to edit each library's binary file manually...
Re: Include<boost/shared_ptr> doesn't compile with QNX 6.6 QCC and c++11  
Hi Alexander,

Typically, that entire values can be solved by adding the following option to the linker
"-Wl,-rpath,$ORIGIN,-rpath,$ORIGIN/../lib".

If you use CMake:
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,$ORIGIN,-rpath,$ORIGIN/../lib")

Hope this helps.

Re: Include<boost/shared_ptr> doesn't compile with QNX 6.6 QCC and c++11  
Two possibilities come to mind, the libraries so name is set incorrectly, or the soname is not set at all and the lib 
was passed to the linker with the full path you are seeing.

You can use something like this to check what the soname is:

ntox86-readelf -d libboost_system-qcc-mt-1_60.so.1.60.0 | grep SONAME

Your build logs should show how things were passed to the linker, and whatever build system boost uses will hopefully 
tell you why the options were used.
Re: Include<boost/shared_ptr> doesn't compile with QNX 6.6 QCC and c++11  
Hi,

Some relevant links:

https://github.com/boostorg/build/issues/85
https://github.com/blackberry/Boost/issues/11

I ended up using a slightly simpler solution - simply adding a space 
after $(HAVE_SONAME) seemed to resolve it for me.

-Will

diff --git a/src/tools/qcc.jam b/src/tools/qcc.jam
index 8edd995..d07ec74 100644
--- a/src/tools/qcc.jam
+++ b/src/tools/qcc.jam
@@ -235,5 +235,5 @@ rule link.dll ( targets * : sources * : properties * )
  #
  actions link.dll bind LIBRARIES
  {
-    "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o 
"$(<)" $(HAVE_SONAME)-Wl,-h$(SPACE)-Wl,$(<[1]:D=) -shared "$(>)" 
"$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS)
+    "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o 
"$(<)" $(HAVE_SONAME) -Wl,-h$(SPACE)-Wl,$(<[1]:D=) -shared "$(>)"  
"$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS)
  }



On 2016-05-26 7:40 AM, Alexander Fagrell wrote:
> I actually found the issue but I don't have a good solution (just a very awkward solution):
>
> Doing an objdump on the unit-test-framework resulted in:
>
> Dynamic Section:
>     NEEDED               bin.v2\libs\timer\build\qcc\release\target-os-qnx\threadapi-pthread\threading-multi\
libboost_timer-qcc-mt-1_60.so.1.60.0
>     NEEDED               bin.v2\libs\system\build\qcc\release\target-os-qnx\threadapi-pthread\threading-multi\
libboost_system-qcc-mt-1_60.so.1.60.0
>     NEEDED               libm.so.2
>     NEEDED               libc.so.3
>
> As you can see there is a ridiculous path to link to both the timer and the system library. I've manually edited the 
library's binary-file and removed the path (this is the awkward part...) to:
>
> Dynamic Section:
>     NEEDED               libboost_timer-qcc-mt-1_60.so.1.60.0
>     NEEDED               libboost_system-qcc-mt-1_60.so.1.60.0
>     NEEDED               libm.so.2
>     NEEDED               libc.so.3
>
> Which works. Is it possible to force Boost to not include the entire path into the library? Is this a boost issue or a
 qcc toolchain issue? I really don't want to edit each library's binary file manually...
>
>
>
>
> _______________________________________________
>
> General
> http://community.qnx.com/sf/go/post116343
> To cancel your subscription to this discussion, please e-mail general-toolchain-unsubscribe@community.qnx.com
>