Menu

Solaris WS6U2 compiling and linking

Anonymous
2002-08-05
2002-09-15
  • Anonymous

    Anonymous - 2002-08-05

    I had some difficulty getting log4cpp 0.2.7 to compile on the WS6U2 CC compiler, but I've got it working now. The problem I was having was at the linking stage. The operator<<() template wasn't being instantiated and linked in properly when I built a library which used the log4cpp CategoryStream class. This resulted in undefined symbol errors when linking to create an executable.

    I had to make two changes in order to get the CategoryStream working properly. The first was to rename all .hh file to .h, and the second was to remove the operator<<() definition from the class declaration to just below it.

    It seems that the compiler cannot find the operator<<() definition without it being defined in a file either with the .h extension, or one of .C, .c, .cc, .cpp, .cxx, .c++ (Section 7.4 of the online C++ user guide). Another fix would probably be to copy the .cpp file into the include directory, and put the operator<<() definition there.

    I'm happy things are working now, but can anybody out there suggest a more elegant solution to the problem than renaming all the header files? I suspect my source level changes are gcc compatible and could be added to the code, but I have my doubts as to whether I can convince the commiters to rename all the header files, and I'd rather not go through that process myself every time I upgrade.

    Thanks,

    Julian.

     
    • Anonymous

      Anonymous - 2002-09-14

      I used the Sun Forte 6 Update 2 compiler on Solaris 2.6 with the following preparation steps as recommended to compile log4cpp-0.2.7:
      export CC=CC
      export CXX=CC
      export LD="CC -KPIC"
      ./configure --disable-static
      While running (GNU) make the following errors occurred:
      "Clock.cpp", line 47: Error: endl is not defined.
      "testbench.cpp", line 43: Error: endl is not defined.
      "testbench.cpp", line 99: Error: endl is not defined.
      "testbench.cpp", line 145: Error: endl is not defined.
      After prefixing endl with 'std::' to correct the namespace problem everything compiled fine.

      The test binaries worked without problems. So I could not reproduce the problem on our system (sun4u sparc SUNW,Ultra-Enterprise).

      Regards,

      Sven

       
      • Anonymous

        Anonymous - 2002-09-15

        Aside from the problems you mention which as you say are easily fixed, I didn't experience any difficulties building the log4cpp libraries and tests.

        My problems began when I went on to build my company's C++ libraries using the log4cpp libraries. I added a static member function called LOG() to each class I wanted to add logging to which returns a Category, and then I use the following:

        LOG().debugStream() << "Opening connection" << log4cpp::CategoryStream::ENDLINE;

        The tests bundled with log4cpp make some use of the CategoryStream with no problem, but for some reason, when I link our code, I get errors because the compiler or the linker isn't instantiating the operator<<() template in CategoryStream.hh properly, and the linker can't find the operator<<() instantiations it needs.

        Renaming all the headers to .h resolves this problem, and so far I haven't found any other solution.

        Regards,

        Julian.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.