9 Replies Latest reply: Feb 22, 2013 11:17 AM by Steve.Clamage-Oracle RSS

    Linking issues while Migrating code from SUN CC 4.3 to SUN CC 5.8

    978744
      Hello,

      I am migrating code written in SUN CC 4.3 to SUN CC 5.8
      I have compiled entire code with SUN CC 5.8 with -compact=4 option ,on machine with OS SunOS 5.8 Generic_Virtual sun4v sparc sun4v.

      during linking phase i am facing issues like

      (cd msggen; make CG="-fast -O3 -compat=4 -lC -features=extensions -i" all)
      /opt/SUNWspro/bin/CC -o msggen msggen.o licensemessage.o ../../../../libs/lib/libgeneral.a
      Undefined first referenced
      symbol in file
      cerr ../../../../libs/lib/libgeneral.a(string.o)
      unsafe_ostream::operator<<(long) ../../../../libs/lib/libgeneral.a(string.o)
      operator delete(void*) msggen.o
      operator new(unsigned int) licensemessage.o
      Iostream_init::Iostream_init(void) msggen.o
      Iostream_init::~Iostream_init(void) msggen.o
      istream::operator>>(char*) ../../../../libs/lib/libgeneral.a(string.o)
      setw(int) ../../../../libs/lib/libgeneral.a(string.o)
      unsafe_ostream::outstr(const char*, const char*) ../../../../libs/lib/libgeneral.a(string.o)
      exrethrow_q msggen.o
      ld: fatal: Symbol referencing errors. No output written to msggen

      I felt like these issues are due to the standard header files. I am including the headers which comes with SUN CC 5.8 and I am using Rogue Wave rwav/ver09.1.

      I am not getting any pointers to solve this issue,any pointer will be highly appriciated.

      Thanks in advance,
      Revathi R
        • 1. Re: Linking issues while Migrating code from SUN CC 4.3 to SUN CC 5.8
          Steve.Clamage-Oracle
          If you use the -compat=4 option anywhere, you must use it everywhere, on every CC command line.
          You have -compat=4 in the "CG" macro, but not on the CC command line that does the linking.

          After you have your code working with -compat=4, I strongly recommend moving to standard C++, the -compat=5 option. Your code will be more portable and more maintainable. Refer to the C++ Migration Guide for a complete list of every issue, with code examples, that you might encounter.
          • 2. Re: Linking issues while Migrating code from SUN CC 4.3 to SUN CC 5.8
            978744
            I have compiled entire SUN CC 4.3 code with SUN CC 5.8 with /opt/SUNWspro/bin/CC -c -fast -O3 -compat=4 -lC -features=extensions -i -DSYSTEMV -DCGM options
            I have done all the code changes required my following the Migration guide.
            while linking i am facing issues due to the standard libraries (as i am linking libraries which comes with the SUN CC 5.8).

            My code is using
            1.cerr
            2.new
            3.delete
            etc functions

            so i haven't got any prototype errors during the compilation phase. and i could see the prototypes in the libraries.

            while i am linking i am getting the following Symbol reference errors.

            (cd msggen; make CG="-fast -O3 -compat=4 -lC -features=extensions -i" all)
            /opt/SUNWspro/bin/CC -o msggen msggen.o licensemessage.o ../../../../libs/lib/libgeneral.a
            Undefined first referenced
            symbol in file
            cerr ../../../../libs/lib/libgeneral.a(string.o)
            unsafe_ostream::operator<<(long) ../../../../libs/lib/libgeneral.a(string.o)
            operator delete(void*) msggen.o
            operator new(unsigned int) licensemessage.o
            Iostream_init::Iostream_init(void) msggen.o
            Iostream_init::~Iostream_init(void) msggen.o
            istream::operator>>(char*) ../../../../libs/lib/libgeneral.a(string.o)
            setw(int) ../../../../libs/lib/libgeneral.a(string.o)
            unsafe_ostream::outstr(const char*, const char*) ../../../../libs/lib/libgeneral.a(string.o)
            exrethrow_q msggen.o

            As the symbol reference errors are due to function call is not finding function body,so for the function call(library function) i need to have the run-time environment.

            I am suspecting like ,the run-time environment is not providing the Proper function bodies. but I am not getting any solution to this problem.Correct me if my analysis is wrong

            Looking forward for Pointers to solve this issue.

            Regards,
            Revathi R
            • 3. Re: Linking issues while Migrating code from SUN CC 4.3 to SUN CC 5.8
              marc1842fr
              /opt/SUNWspro/bin/CC -o msggen msggen.o licensemessage.o ../../../../libs/lib/libgeneral.a
              Steve suggested adding -compat=4 to this line.
              (depending on your makefile, the easiest way is often to set CXX="/opt/SUNWspro/bin/CC -compat=4")
              • 4. Re: Linking issues while Migrating code from SUN CC 4.3 to SUN CC 5.8
                978744
                Hello,

                I could able to compile and link the code... :) , with -compat=4, as you suggested to move to compat=5, does the same code (code migrated from 4.3 to 5.8) works with compact=5.. with out any changes or do we need to do additional changes?

                Thanks in advance,
                Revathi R
                • 5. Re: Linking issues while Migrating code from SUN CC 4.3 to SUN CC 5.8
                  Steve.Clamage-Oracle
                  Most code that works with -compat=4 is also valid -compat=5 code. There are a few issues, changes to the language in the 1998 C++ Standard. The C++ Migration Guide
                  http://docs.oracle.com/cd/E19422-01/819-3689-10/819-3689-10.pdf
                  lists every issue you could run into, with code examples showing ways (sometimes multiple ways) you can fix your code.

                  I usually recommend this sequence:

                  1. Remove all binaries, including the template cache, and build your application with the options "-compat=4 +w" (to turn on additional warnings). Fix the code so that no warnings are emitted. Some warnings in -compat=4 mode become errors in -compat=5 mode, and it's better to fix problems before introducing more variables into the build process.

                  2. Remove all binaries, including the template cache, and build the application with "-compat=5".
                  NOTE: If you use iostreams, add the option "-library=iostream". This will let your existing iostream code work unchanged.
                  With the Migration Guide as a reference, fix all errors and warnings (that is, warnings you get without using "+w").

                  Now you should have a working application.

                  Since the old-style iostreams are obsolete and unsupported by modern compilers, you should at your earliest convenience change the code to work with standard iostreams. In most cases, only trivial changes are needed. The Migration Guide has all the information.
                  • 6. Re: Linking issues while Migrating code from SUN CC 4.3 to SUN CC 5.8
                    Cross-posted:
                    http://www.computerhope.com/forum/index.php?topic=135850.0
                    • 7. Re: Linking issues while Migrating code from SUN CC 4.3 to SUN CC 5.8
                      Steve.Clamage-Oracle
                      In the question in the other forum, it would be a good idea to add a reference to this thread.
                      • 8. Re: Linking issues while Migrating code from SUN CC 4.3 to SUN CC 5.8
                        978744
                        Yes i did migration by following the Migration Guide, while Migration i ve come across situations where a class method is invisible at many situations like...

                        C.h

                        class C
                        {
                        f1();
                        }

                        B.h
                        #include<C.h>
                        class B
                        {
                        f2();
                        }

                        A.C
                        #include<B.h>
                        class A:B
                        {
                        f1();-----> Error Not accessible so I changed to C::f1() then worked like this I ve came across many will it be a Problem, in migration Guide i haven't seen any of such.

                        }

                        Like this for operator overloading also , I haven't got any way to make function body available to function call, so i ve changed those functions to normal functions...

                        How to solve these scope issues if my approach is wrong??

                        what is a template cache?? How to delete it??




                        Another task of mine is, i am compiling a code written in SUN CC 5.5 to 5.8, would you suggest me the migration guide, I could get from 4 to 5 and 3 to 5 but

                        not from 5.5 to 5.8, I am not sure about in which compiler code is written but, I could able to compile the code with out compact option with SUN CC 5.5, but while trying to compile with 5.8 i am facing issues like
                        1. typecasting
                        2.virtual vector<int> getProcedureArgs() { return 0; } -----> Error: Cannot use int to initialize std::vector<int>


                        Thanks and Regards,
                        Revathi R
                        • 9. Re: Linking issues while Migrating code from SUN CC 4.3 to SUN CC 5.8
                          Steve.Clamage-Oracle
                          975741 wrote:
                          Yes i did migration by following the Migration Guide, while Migration i ve come across situations where a class method is invisible at many situations like...

                          C.h

                          class C
                          {
                          f1();
                          }

                          B.h
                          #include<C.h>
                          class B
                          {
                          f2();
                          }

                          A.C
                          #include<B.h>
                          class A:B
                          {
                          f1();-----> Error Not accessible so I changed to C::f1() then worked like this I ve came across many will it be a Problem, in migration Guide i haven't seen any of such.

                          }
                          When you post a code example, it is best to copy/paste from actual code that you verified shows the problem. This example is nowhere near valid for any compiler, even with your suggested change.
                          - The class declarations are not terminated by a semicolon
                          - You can't call C::f1() using that syntax outside of class C or a class derived from class C because it is not a static function, and requires an object. You could call it as c.f1() if you had a c object of type C, except that f1() would still not be accessible.

                          The rules about accessibility have never changed. Please post an example that actually works with C++ 4.x or with C++ 5.x in -compat=4 mode, but that fails with -compat=5 mode.

                          >
                          Like this for operator overloading also , I haven't got any way to make function body available to function call, so i ve changed those functions to normal functions...
                          I don't understand what you mean. An example would help.

                          >
                          what is a template cache?? How to delete it??
                          The template cache is also known as the template repository. See section 3.3.5 Template Repository in the Migration Guide. To delete the cache (repository) just remove the entire cache directory.

                          >
                          >
                          Another task of mine is, i am compiling a code written in SUN CC 5.5 to 5.8, would you suggest me the migration guide, I could get from 4 to 5 and 3 to 5 but
                          not from 5.5 to 5.8, I am not sure about in which compiler code is written but, I could able to compile the code with out compact option with SUN CC 5.5,
                          CC 5.5 and 5.8 are fully compatible. There should be no migration issues. The exceptions would be invalid code that compiled due to a bug in the earlier compiler but is correctly diagnosed as an error with the later compiler. In rare cases, the later compiler has a bug not present in the earlier compiler (a regression). When found, regressions are fixed in patches. If you have an Oracle service contract, you can download patches from My Oracle Support. Otherwise, get the most recent compiler, which should not have those regressions.

                          but while trying to compile with 5.8 i am facing issues like
                          1. typecasting
                          I would have to see an example.
                          2.virtual vector<int> getProcedureArgs() { return 0; } -----> Error: Cannot use int to initialize std::vector<int>
                          The compiler error message is correct. The function returns a vector<int>, but you can't create a vector<int> from an integer 0. That is, the vector template has several constructors, but none that accept a single integer argument.

                          At this point we have moved away from the original topic. If you have further questions, please start a new thread.