Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
Posts: 23
Registered: ‎06-06-2012
My Device: Simulator

Boost headers won't compile?

I've searched all over for a solution for this but haven't found anything...

 

All I'm attempting to do is use select Boost library headers. (Mainly: smart_ptr, utility, function, bind, intrusive, some mpl, etc.) I don't need to build the libraries or anything like that.


I've tried both the latest (1.49) and the version of 1.48 on github known as Boost for Blackberry that someone was pointed to in a different thread. Both versions give me the same errors:

 

In file included from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/intrusive/detail/utilities.hpp:24,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/intrusive/list_hook.hpp:19,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/intrusive/list.hpp:20,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../GameEngine/Engine/process.h:14,
                 from /Developer/SDKs/bbndk-2.0.1/target/qnx6/usr/include/unistd.h:88,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/config/posix_features.hpp:18,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/config/platform/qnxnto.hpp:13,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/config.hpp:53,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/smart_ptr.hpp:17,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../GameEngine/Engine/GameEngine_PCH.h:28,
                 from <command-line>:0:
/Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/cstdint.hpp:275: error: 'long_long_type' in namespace 'boost' does not name a type
/Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/cstdint.hpp:276: error: 'ulong_long_type' in namespace 'boost' does not name a type
/Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/cstdint.hpp:277: error: 'long_long_type' in namespace 'boost' does not name a type
/Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/cstdint.hpp:278: error: 'long_long_type' in namespace 'boost' does not name a type
/Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/cstdint.hpp:279: error: 'long_long_type' in namespace 'boost' does not name a type
/Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/cstdint.hpp:280: error: 'ulong_long_type' in namespace 'boost' does not name a type
/Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/cstdint.hpp:281: error: 'ulong_long_type' in namespace 'boost' does not name a type
/Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/cstdint.hpp:282: error: 'ulong_long_type' in namespace 'boost' does not name a type
In file included from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/intrusive/list_hook.hpp:19,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/intrusive/list.hpp:20,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../GameEngine/Engine/process.h:14,
                 from /Developer/SDKs/bbndk-2.0.1/target/qnx6/usr/include/unistd.h:88,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/config/posix_features.hpp:18,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/config/platform/qnxnto.hpp:13,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/config.hpp:53,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/smart_ptr.hpp:17,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../GameEngine/Engine/GameEngine_PCH.h:28,
                 from <command-line>:0:
/Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/intrusive/detail/utilities.hpp: In function 'std::size_t boost::intrusive::detail::floor_log2(std::size_t)':
/Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/intrusive/detail/utilities.hpp:477: error: typedef 'BOOST_JOIN' is initialized (use decltype instead)
/Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/intrusive/detail/utilities.hpp:477: error: 'boost_static_assert_typedef_' was not declared in this scope
/Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/intrusive/detail/utilities.hpp: At global scope:
/Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/intrusive/detail/utilities.hpp:535: error: 'uint64_t' in namespace 'boost' does not name a type
In file included from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/intrusive/list_hook.hpp:23,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/intrusive/list.hpp:20,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../GameEngine/Engine/process.h:14,
                 from /Developer/SDKs/bbndk-2.0.1/target/qnx6/usr/include/unistd.h:88,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/config/posix_features.hpp:18,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/config/platform/qnxnto.hpp:13,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/config.hpp:53,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../boost/boost/smart_ptr.hpp:17,
                 from /Users/dposluns/Documents/dev/test_proj/qnx/test_proj/../../GameEngine/Engine/GameEngine_PCH.h:28,
                 from <command-line>:0:

 ... followed by a litany of other errors, but that's where it begins.

 

The problem seems to stem from cstdint.hpp, but I'm unable to make much sense of it.

 

Anyone know what I'm doing wrong...?

Thanks,


Dan.

BlackBerry Development Advisor (Retired)
Posts: 499
Registered: ‎05-07-2012
My Device: developer

Re: Boost headers won't compile?

[ Edited ]

I'm assuming the issue is:

error: 'long_long_type' in namespace 'boost' does not name a type

although I don't see why you would get this error on that line.

 

Can we simplify the file you are trying to compile?

A guess is that one of your files has an open namespace (missing closing brace) and as a result long_long_type is not defined in ::boost but in <your_namespace>::boost.

This can also happen if the include file you include this from does:

  namespace MyStuff

  {

  #include <system or 3rd party file>

  }

 

So first try including cstdint.hpp earlier: explicitly include this in your .cpp file rather than in your .hpp file .   In general, I include system files then 3rd party files then my own files.  Partly so I know errors in my include files aren't disrupting the fixed files I'm using.

 

If that doesn't help, make a trivial file that includes and uses the boost file.  It should compile.   Either add to this or comment-out pieces of your full file until you find what has caused the error.

 

-- did you play around with setting BOOST_HAS_LONG_LONG or other things?   AFAIK that shouldn't be needed and could cause your error.

Contributor
Posts: 23
Registered: ‎06-06-2012
My Device: Simulator

Re: Boost headers won't compile?

Hi there,

 

I did as you suggested and reduced the project down to compiling a single C++ file:

 

#include <boost/cstdint.hpp>

int main(int argc, char *argv[])
{
	return 0;
} 

... and the same errors occur as before.

 

I am using a vanilla empty C++ project created by the IDE, with the only change to common.mk being to add the Boost root directory to EXTRA_INCVPATH.

 

I don't really have the option to not use cstdint.hpp, as it is being included by other Boost libraries that my project uses.

 

It's also not a problem that I can kludge with playing around with macros specific to the long long type; if you go look through the error log you'll see it's not just long_long_type but a whole bunch of types that suffer from this.

 

Dan.

Contributor
Posts: 23
Registered: ‎06-06-2012
My Device: Simulator

Re: Boost headers won't compile?

Bumping this... can anyone get a program that includes the boost header cstdint.hpp (such as smart_ptr.hpp) to compile?

Thanks,

Dan.
BlackBerry Development Advisor (Retired)
Posts: 499
Registered: ‎05-07-2012
My Device: developer

Re: Boost headers won't compile?

I was having issues getting the -I onto my compile line.   I'm looking at this now.  I think it's compiled but I'm double-checking

 

Stuart

BlackBerry Development Advisor (Retired)
Posts: 499
Registered: ‎05-07-2012
My Device: developer

Re: Boost headers won't compile?

What I did is slightly different from what you did.

I created a project and edited it to have:

 

#include <iostream>
#include <sstream>
#include "boost/smart_ptr.hpp"

class Boo
{
public:
    Boo() {std::cout << "Boo!\n";}
    ~Boo() {std::cout << "Wah!\n";}
};

int main(int argc, char *argv[]) {

    Boo* boo = new Boo();
    boost::shared_ptr<Boo> p(boo);
    std::cout << "This doesn't work\n";
    return 0;
}

 

I added the directory to the include path -- I actually added it through the gui but had to modify .cproject to have <listOptionValue builtIn="false" value="C:/projects/boost_1_49_0"/>

This is where what I was doing differs from you: you had common.mk

 

The output:

Boo!
This doesn't work
Wah!

 

Does this help?

If not, can you give a recipe for reproducing your issue?

 

Stuart

Contributor
Posts: 23
Registered: ‎06-06-2012
My Device: Simulator

Re: Boost headers won't compile?

Ok, I think I've found my problem, but I'm not sure what the solution is.

 

I was including my project directories in EXTRA_INCVPATH. One of those directories contained a file called Process.h. This was apparently taking precedence over process.hpp in boost/detail/win, so it was getting included by the Boost libraries instead of the correct file (boost/detail/win/process.hpp), thereby breaking the Boost libraries. (When I experimentally change the file name to "Process2.h" everything compiles.)

 

I have no idea why the QNX version of boost is including a Windows-specific header. I've never compiled my project for Windows (which is why I suppose I've never run into this problem before). I can change the name of the file and name of the class to something else, but this is a fairly major change for something that shouldn't be an issue (as far as I can tell) and I am reluctant to embark upon it if unnecessary. I tried reordering the boost directory and my include directory in EXTRA_INCVPATH but this had no effect on the outcome.

 

Any ideas?

Thanks,


Dan.

BlackBerry Development Advisor (Retired)
Posts: 499
Registered: ‎05-07-2012
My Device: developer

Re: Boost headers won't compile?

[ Edited ]

I haven't looked at the order of include file handling with this compiler and environment, but perhaps you can be careful about the order of your include paths -- check the -I order actually used on the command line.   Perhaps also if you include your boost libraries first in your .cpp file?

 

Boost seems self-contained, always including boost/whatever.hpp.

I was using a pure boost download, on Windows7, two differences.  If you are still stuck I could set up a linux VM: from where did you download the boost you are using (the exact link so there's no confusion).  Depending on a windows include file seems unexpected.

 

However, I do know that on some systems gcc builds into a single flat directory, so can have issues with files of the same name.  I would expect that to be an issue with .cpp files but there may be a corresponding issue with .hpp files. If you can rename the offending file and its uses, that would be easiest. Otherwise, perhaps extracting the offending subsystem into its own project and building into a library may be your best approach.

 

Hope this helps.

Let me know if you need me to try something.

 

Stuart

Contributor
Posts: 23
Registered: ‎06-06-2012
My Device: Simulator

Re: Boost headers won't compile?

Okay, I think I've tracked down the root cause.


It isn't to do with boost/win/detail/process.hpp. It's actually the NDK's version of<unistd.h>, which is included directly by several boost files (including <unistd.hpp>, <posix_features.hpp>, and others.

 

This version of <unistd.h> includes <process.h>, which is a non-ANSI, non-POSIX system file in the NDK's usr/include directory. This is the file that GCC is instead overriding with my project's version from my EXTRA_INCVPATH.

 

Unfortunately, I can't just simply add $(QNX_TARGET)/usr/include to my EXTRA_INCVPATH ahead of my own directories (I tried!) because GCC ignores it when you specify search directories that already exist in its standard include path.

 

I can get around it by ditching EXTRA_INCVPATH altogether, and instead adding -Wc,-iquote<dir> for each of my project directories to the CCFLAGS variable. Using -iquote causes GCC to ignore those directories when searching for system headers, so when <unistd.h> includes <process.h> it finds the correct file. I don't know if this method will have other negative side-effects with the QNX build-system, though (such as breaking dependency management).

 

I'm a little surprised I'm the first person to encounter this problem; I guess the intersection of people who have a file in their project named "process.h" and the people who need to include <unistd.h> (or use libraries that do) is pretty small.

 

Let me know if you have any other suggestions as to how I approach this issue.

 

Dan.

Contributor
Posts: 23
Registered: ‎06-06-2012
My Device: Simulator

Re: Boost headers won't compile?

Argh, ok, it turns out my workaround had to be even MORE complicated, because adding source directories to EXTRA_SRCVPATH has the side-effect of having those directories added to the command line as header-search directories in the traditional -I format.

 

I had to manually add my source files to SRCS, then after the inclusion of qmacros.mk, manually add a vpath directive so the additional source files would be processed.

 

This is all getting extremely complicated!


Dan.