Sign in to follow this  
Instigator

C++ and Boost

Recommended Posts

I started a thread about 2 weeks ago about wanting to find a portable c++ socket library. Someone pointed me towards "Boost Asio" (a networking lib) I really wanted to learn more about other Boost features so I continued to read and read. Now I'm wondering if those of you (windows users) used boost with the Microsft C++ compiler or did you go with gcc? Please help me understand why you would go with the Microsoft compiler in windows when the entire aim for Boost its cross platform ability. Anyways, I decided to go with gcc + MinGW and Code Blocks (and ditch the VS 2008 I've got).. just for the cross platform compatibility. On this journey I found problems with compiling boost in windows with MinGW. Apparently the gcc I've got does not support some wide char support. Is there a fix to this? Here is some info. I've got Windows XP 32 Bit. After setting my PATH variable I ran the following.
Quote:
bjam --toolset=gcc "--prefix=C:\Program Files\CodeBlocks" install
But I received (below) upon completion.
Quote:
...failed updating 16 targets... ...skipped 9 targets... ...updated 12 targets...
This was an error I found within the cmd window
Quote:
...failed gcc.compile.c++ bin.v2\libs\serialization\build\gcc-mingw-3.4.5\releas e\link-static\threading-multi\xml_woarchive.o... . . wide char i/o not supported on this platform
So serialization is failing and its due to some Wide Char Support missing. Do you guys have any ideas? I searched google... I searched everywhere and I'm out of luck.

Share this post


Link to post
Share on other sites
Quote:

Please help me understand why you would go with the Microsoft compiler in windows when the entire aim for Boost its cross platform ability.

Because if the code is cross-platform, I can use it with any (serious) compiler. And on Windows, I find the Visual Studio IDE to be vastly superior to all other options, and the GCC compiler to be equivalent enough in functionality to cl.exe that it's not work hooking up GCC to VS unless I have to (i.e., PSP programming). The point of cross-platform code is that it can be used (compiled) on multiple platforms with multiple tools -- that has no bearing on whether or not the tool ultimately used to compile it is cross-platform or not.

I have not compiled Boost on GCC so I cannot help you with your errors.

Share this post


Link to post
Share on other sites
I am using MingW 4.4.0 (you should really upgrade) and Boost 1.39, and I had an issue with wide characters that I could not find a solution to anywhere on the internet.

What worked for me was to comment out the lines 159 and 166 in the file mingw\lib\gcc\mingw32\4.4.0\include\c++\cwchar. Here is how my modified file looks, starting from line 157 to give some context:

using ::putwc;
using ::putwchar;
// using ::swprintf; // DOES NOT COMPILE FOR WHATEVER REASON
using ::swscanf;
using ::ungetwc;
using ::vfwprintf;
#if _GLIBCXX_HAVE_VFWSCANF
using ::vfwscanf;
#endif
// using ::vswprintf; // DOES NOT COMPILE FOR WHATEVER REASON
#if _GLIBCXX_HAVE_VSWSCANF
using ::vswscanf;
#endif
using ::vwprintf;
#if _GLIBCXX_HAVE_VWSCANF
using ::vwscanf;
#endif

Of course I'd prefer a real solution, but it works for me.

Oh, I may have misunderstood. You are compiling Boost? I was merely using the templates.

Share this post


Link to post
Share on other sites
Quote:
Original post by DevFred
I am using MingW 4.4.0 (you should really upgrade) and Boost 1.39, and I had an issue with wide characters that I could not find a solution to anywhere on the internet.

What worked for me was to comment out the lines 159 and 166 in the file mingw\lib\gcc\mingw32\4.4.0\include\c++\cwchar. Here is how my modified file looks, starting from line 157 to give some context:

using ::putwc;
using ::putwchar;
// using ::swprintf; // DOES NOT COMPILE FOR WHATEVER REASON
using ::swscanf;
using ::ungetwc;
using ::vfwprintf;
#if _GLIBCXX_HAVE_VFWSCANF
using ::vfwscanf;
#endif
// using ::vswprintf; // DOES NOT COMPILE FOR WHATEVER REASON
#if _GLIBCXX_HAVE_VSWSCANF
using ::vswscanf;
#endif
using ::vwprintf;
#if _GLIBCXX_HAVE_VWSCANF
using ::vwscanf;
#endif

Of course I'd prefer a real solution, but it works for me.

Oh, I may have misunderstood. You are compiling Boost? I was merely using the templates.


I'm compiling the Boost libraries ('bjam' command I used above).. and apparently there's 37 library files which it places in the "...\CodeBlocks\lib\" folder but a few of them failed. But now you're confusing me because you're saying that I can simply skip installing the libraries? After I got some of these libraries installed, I just pointed my Code Blocks IDE's Global Variables to the libraries which successfully installed. Problem is that not all Boost tutorials are compiling in here... :(

Anyways, I'll try your fix.

Share this post


Link to post
Share on other sites
I have never compiled boost, because 95% of it are templates anyway, and you can't compile those in the sense that you compile other libraries. I just moved the boost folder in my include directory and everything was fine.

Share this post


Link to post
Share on other sites
Quote:
Original post by jpetrie
Quote:

Please help me understand why you would go with the Microsoft compiler in windows when the entire aim for Boost its cross platform ability.

Because if the code is cross-platform, I can use it with any (serious) compiler. And on Windows, I find the Visual Studio IDE to be vastly superior to all other options, and the GCC compiler to be equivalent enough in functionality to cl.exe


This. When I write code, I use visual studio when I can. When I compile for *nix, I use gcc. Using Microsoft's IDE doesn't make you any less cross platform.

Share this post


Link to post
Share on other sites
Quote:
Original post by Telastyn
Using Microsoft's IDE doesn't make you any less cross platform.

Okay done, installation for VS 2008 was way too easy. They have the binaries already made for you. I'm just hoping you're right about that statament when I go to compile my code within Linux, 3 months from now.

Share this post


Link to post
Share on other sites
Remember you don't need to compile the whole boost stuff. Creating a library project and throwing the required (specific) files for a boost library into it should compile just fine, and ultimately, that's all that you need.

Most commonly used Linux distros come with the boost libraries already compiled and installed.

Share this post


Link to post
Share on other sites
Quote:
I'm just hoping you're right about that statament when I go to compile my code within Linux, 3 months from now.

You should test your code on all target platforms on a regular basis. This helps getting things correct, since sometimes GCC refuses some code and sometimes MSVC does.
If you use CMake or Boost.Build this is fairly easy to do.

Share this post


Link to post
Share on other sites
Quote:
Original post by Instigator
So serialization is failing and its due to some Wide Char Support missing. Do you guys have any ideas? I searched google... I searched everywhere and I'm out of luck.


MinGW doesn't have support for Windows' wide characters in many cases.

In practice this hasn't been a problem. I obviously don't use the serialization library, though :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this