This discussion is archived
2 Replies Latest reply: Feb 22, 2012 10:37 AM by 919271 RSS

multdecl error in algorithm.cc /w SS C++ 5.12

919271 Newbie
Currently Being Moderated
Howdy,

I am running into trouble with multiple declaration errors in the libCstd algorithim.cc file while trying to compile a C++ file. I'm hoping somebody has a clue.

Background - I am trying to port a library that was originally written using GNU C++ on Solaris to Sun Studio C++ on Solaris. To make a long story short, this library needs to be linked with a program that was already written for Sun Studio C++. Since I've been told you can't mix and match GNU and Sun C++ code together, I'm trying to recompile this library using Sun Studio C++. Recompiling the program with GNU C++ is not an option for various technical and political reasons. Recompiling the library is the only option at this time.

Version - CC: Sun C++ 5.12 SunOS_sparc 2011/11/16

~/SolarisStudio12.3-solaris-sparc-bin/solarisstudio12.3/prod/bin/CC -DNDEBUG -KPIC -g -DNO_MEMBER_TEMPLATES -c -I../../include -I../base -I../parser -I../dc -errtags -c DcPeerManager.cpp
"../parser/DiameterAVP.h", line 99: Warning, wvarhidemem: length hides DiameterAVP::length.
"../base/ObjectQueue.h", line 91: Warning, incompletew: The type "DcEvent", used in delete, is incomplete.
"../base/ObjectQueue.h", line 185: Warning, incompletew: The type "DcEvent", used in delete, is incomplete.
"DcEvent.h", line 107: Warning (Anachronism), assumetemp: Using ObjectQueue as a template without a declaration.
"/home/dmd/SolarisStudio12.3-solaris-sparc-bin/solarisstudio12.3/prod/include/CC/Cstd/algorithm.cc", line 908: Error, multdecl: Multiple declaration for __stl_threshold.
"/home/dmd/SolarisStudio12.3-solaris-sparc-bin/solarisstudio12.3/prod/include/CC/Cstd/algorithm.cc", line 1082: Error, multdecl: Multiple declaration for __stl_chunk_size.

I looked at algorithm.cc and could not find these alleged multiple declarations. The problem must lie elsewhere but I really have no clue what is causing it.

Does anybody have any ideas of how to troubleshoot this?

TIA
  • 1. Re: multdecl error in algorithm.cc /w SS C++ 5.12
    Steve_Clamage Pro
    Currently Being Moderated
    There are several things that could be wrong.

    First, check to see if algorithm.cc is explictly included anywhere. If so, change the code so that it only uses a standard include directive:
    #include <algorithm> 
    One possible subtle problem involves the compiler's default behavior in including files having template code. By default, if a template is declared in a header file and is used, the compiler looks for a corresponding .cc (or .cpp, .C, etc) file, and includes it automatically. If the source code was not written with automatic inclusion in mind, you can get duplicate definition errors due to multiple inclusion of the same file.

    You can read more about the "definitions-included" and "definitions-separate" template compilation model in the C++ Users Guide, chapter 5, "Program Organization".

    However, I don't see how this feature could result in multiple declarations from algorithm.cc, unless the project source code tries to be clever about standard headers, such as including a preprocessed standard header. That is, something like this:
    % cat foo.cc
    #include <algorithm>
    % CC -E foo.cc > algo.h  # don't do this!
    % cat myproject.cc
    #include "algo.h" // don't do this
    ...
    First, check for something odd like the above. If that's not the problem, try adding the option
    -template=no%extdef
    to disable the automatic inclusion of source code files.

    If still no joy, please post a small sample program that results in the same error messages.
  • 2. Re: multdecl error in algorithm.cc /w SS C++ 5.12
    919271 Newbie
    Currently Being Moderated
    Thanks for the reply.

    algorithm.cc is not being included anywhere.

    I did a very brief glance of the code and couldn't find any examples of weird things happening with headers like you were suggesting (again, only a brief glance).

    I did try "-template=no%extdef" and that DID fix the problem!

    Much thanks.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points