5 Replies Latest reply: Apr 30, 2012 1:26 PM by Steve.Clamage-Oracle RSS

    Error in compiling RW libs with g++

    843935
      Hi All,

      I am trying to port one project from Solaris (CC) to gcc, which uses RWlibs (of Tools.h++ which comes along with the sunstudio package).

      I am working on RHEL 5.4.

      As a first step i am trying my hand with the following simple program:
       
      #include <iostream>
      #include <rw/cstring.h>
      
      int main(){
        RWCString a("TEST Program compiled successfully with gcc");
      
        std::cout << a << std::endl;
      
        return 0;
      }
      when i tried to compile the above sample program i got the following:
      $ g++ -Wall -g rwstring.cc -I/app/sunstudio12/prod/include/CC/rw7
      /app/sunstudio12/prod/include/CC/rw7/rw/generic.h:80: error: ISO C++ forbids declaration of ‘genericerror’ with no type
      /app/sunstudio12/prod/include/CC/rw7/rw/rstream.h:46: error: expected initializer before ‘&’ token
      /app/sunstudio12/prod/include/CC/rw7/rw/cstring.h:378: error: ISO C++ forbids declaration of ‘istream’ with no type
      /app/sunstudio12/prod/include/CC/rw7/rw/cstring.h:378: error: expected ‘;’ before ‘&’ token
      /app/sunstudio12/prod/include/CC/rw7/rw/cstring.h:379: error: ISO C++ forbids declaration of ‘istream’ with no type
      /app/sunstudio12/prod/include/CC/rw7/rw/cstring.h:379: error: expected ‘;’ before ‘&’ token
      /app/sunstudio12/prod/include/CC/rw7/rw/cstring.h:381: error: ISO C++ forbids declaration of ‘istream’ with no type
      /app/sunstudio12/prod/include/CC/rw7/rw/cstring.h:381: error: expected ‘;’ before ‘&’ token
      /app/sunstudio12/prod/include/CC/rw7/rw/cstring.h:382: error: ISO C++ forbids declaration of ‘istream’ with no type
      /app/sunstudio12/prod/include/CC/rw7/rw/cstring.h:382: error: expected ‘;’ before ‘&’ token
      /app/sunstudio12/prod/include/CC/rw7/rw/cstring.h:383: error: ISO C++ forbids declaration of ‘istream’ with no type
      /app/sunstudio12/prod/include/CC/rw7/rw/cstring.h:383: error: expected ‘;’ before ‘&’ token
      /app/sunstudio12/prod/include/CC/rw7/rw/cstring.h:480: error: expected constructor, destructor, or type conversion before ‘&’ token
      /app/sunstudio12/prod/include/CC/rw7/rw/cstring.h:481: error: expected constructor, destructor, or type conversion before ‘&’ token
      Any help/suggestions is appreciated.

      Thanks in advance,
      14341
        • 1. Re: Error in compiling RW libs with g++
          Steve.Clamage-Oracle
          You cannot use the RW Tools.h++ that comes with Studio with any other compiler, for two reasons:

          1. Legal: It violates the license agreement. For RW Tools.h++ in particular, Oracle's license with Rogue Wave allows distribution only for use with Studio, and your license with Oracle reflects that restriction.

          2. Technical: It won't work. Binary code produced by CC is not compatible with binary code produced by g++. The code won't link, and if you could force it to link, it won't run properly, and probably will just crash. For a detailed discussion of this issue, see my paper "Stability of the C++ ABI"
          http://www.oracle.com/technetwork/articles/servers-storage-dev/stablecplusplusabi-333927.html
          • 2. Re: Error in compiling RW libs with g++
            843935
            Hi Steve,

            Thank you for your time.

            http://www.oracle.com/technetwork/articles/servers-storage-dev/stablecplusplusabi-333927.html

            Above one gives a very good in sight regards the c++ ABI.


            Could you suggest me the best options (library) to replace the usages of Tools.h++ (i.e RWlibs)?

            CPP Boost libraies : http://www.boost.org/
            Apache CPP Standard Library : http://stdcxx.apache.org/
            SGI STL : http://stdcxx.apache.org/


            Thanks in advance,
            14341
            • 3. Re: Error in compiling RW libs with g++
              Steve.Clamage-Oracle
              RW Tools.h++ is a very old product, which has not had significant updates in many years. Most of the functionality in RW Tools.h++ is available in other libraries, although the programming interface is different. (That is, if you have code written for RW Tools.h++, it will need to be re-written.) You can buy the library from Rogue Wave (roguewave.com) if you want to use it with g++ or other compilers.

              Much of the functionality of RW Tools.h++ is in the C++ Standard library. The Boost libraries are a good addition for anything else that you need.

              The SGI STL and the Apache stdcxx libraries are replacements for the C++ standard library that comes with your C++ compiler. If you download one of these libraries, you will have quite an adventure getting it to build and work correctly with the Studio C++ compiler. But we have already done that work for you. The -library=stlport4 option picks up the STLport version of the SGI STL, and it comes with the compiler. The Apache stdcxx library is available with Solaris 11 for use with Studio C++. Install it in the default locations (in /usr/include and /usr/lib), and use the -library=stdcxx4 option for compiling and linking. Refer to the C++ Users Guide for details about using these alternative libraries.

              For g++, using the SGI STL is not a good idea. You can use Apache stdcxx if you want, but the standard library that comes with g++ is a good one, so I would not recommend replacing it unless you have a specific reason.

              Boost works very well with g++, since it is developed with and tested with g++. Be sure to check your g++ version with any notes about compilers in the version of Boost that you get.
              • 4. Re: Error in compiling RW libs with g++
                934122
                Hi,

                I too am trying to port an application from solaris CC to GNU g++ that uses RW lib. I came across this post which in turn was really helpful. However didnt understand very good solution to this problem.

                @840932,

                have you ported your project successfully? How did you go for it? Which library did you use?

                Your help in this regard is really appreciated.

                Thanks!
                • 5. Re: Error in compiling RW libs with g++
                  Steve.Clamage-Oracle
                  You might get a different answer from the original poster, but I see only two approaches.

                  1. Get the Tools library from Rogue Wave. They no longer sell Tools.h++ separately, but you can get it as part of SourcePro C++.
                  http://www.roguewave.com/products/sourcepro.aspx
                  I think Tools.h++ is the part of SourcePro called "Essential Tools", but you would have to check with RW for details.

                  2. Evaluate the functionality you need, and see whether it is part of the C++ Standard Library, or available in other tools sets such as BOOST.
                  http://www.boost.org
                  If so, rewrite your code to use the selected library (or libraries).

                  Which approach is better -- for long term or short term -- only you can decide.