How to use c++ STL along with Rougewave collections?

Posted on 2005-04-19
Last Modified: 2013-12-14
We are using rouge wave library for collections. now we want to use STLs. But we are getting this error.

in any of the header file include this header.
then in any class of the header file
declare std::list<int> ilist;

Error iam Getting :

C:\viewstore\hranja01_Dev_STL/ncp_and/Support/lib/libvistact_NBX100.o C:\viewstore\hranja01_Dev_STL/ncp_and/Support/lib/libEncrypt_d.a C:\viewstore\hranja01_Dev_STL\supporting_files_and\tornado\target/lib/libI80486gnuvx.a
C:\viewstore\hranja01_Dev_STL\supporting_files_and\tornado\target/lib/libI80486gnuvx.a(stlinst.o)(.data+0xa8): multiple definition of `__default_alloc_template<true, 0>::__node_allocator_lock'
C:\viewstore\hranja01_Dev_STL/ncp_and/Support/lib/libDatabaseIL_NBX100_d.a(acdgroup.o)(.data+0x30):C:\viewstore\hranja01_Dev_STL\ncp_and\Support\DatabaseIL\Profiles/acdgroup.cpp: first defined here
collect2: ld returned 1 exit status
cc386: Internal compiler error: program ld got fatal signal 1
make[3]: *** [vxWorks] Error 0x1

Here iam getting error like:multiple definition of `__default_alloc_template<true, 0>::__node_allocator_lock'

Thanx in Adv
Question by:ranganathan_gp
    LVL 39

    Expert Comment

    >>>> declare std::list<int> ilist;

    do you mean 'typedef' instead of 'declare' ???

    >>>> We are using rouge wave library for collections.

    How do you know the error was caused by RogueWave libraries/includes ???

    If you use Roquewave libraries you need to build/use a library version that is compatible to STL. Check your RoqueWave installation guide for that. Furthermore, you have to remove the RW_NO_STL macro from your projects.

    >>>> multiple definition of `__default_alloc_template<true, 0>::__node_allocator_lock'

    That error could be caused by two STL libraries, e. g. Microsoft STL and STL-Port.  Or a clean and rebuild could solve the problem

    Regards, Alex

    LVL 1

    Author Comment

    declare means writing std::list<int> ilist in any of the .h file. in fact this is the definition too.
    clean and build is not working.
    we are using STLs provided by HP. I am unable to find where is the other definition.


    ranga & himanshu
    LVL 39

    Expert Comment

    'declare' isn't a valid C++ keyword. I would like to know whether you have a statement like

       declare std::list<int> ilist;

    in your code or if you simply want to say that you declared a variable

        std::list<int> ilist;

    in a class.

    >>>> we are using STLs provided by HP.

    STL comes with the compiler. From the warnings and errors I see you are using GNU compiler. HP seems to be the hardware supplier but I don't think you got an STL from HP.

    >>>> RogueWave

    Do you want to *change* from RogueWave to STL or do you need *both* ?

    >>>> .../libI80486gnuvx.a(stlinst.o)(.data+0xa8):
    >>>> multiple definition of `__default_alloc_template<true, 0>::__node_allocator_lock'

    From that error I can see that the error occurs when trying to create an object file named 'stlinst.o'. The source of that object is 'stlinst.cpp', 'stlinst.cxx', '' or 'stlinst.C'. From the name I would deduce it has something todo with explicit template instantiation, what isn't necessary when using STL (use implicit instantiation instead). So, try to locate the stlinst source in your makefile/project file and remove it from build (save old file before). After that, clean the project and make a rebuild.

    Good Luck,

    LVL 1

    Author Comment

    we have no sorce code of any of the file stlinst.cpp,stlinst.cxx, or stlinst.c.
    stlinst.o is there in one of the archive C:\viewstore\rparam01_view6\supporting_files_and\tornado\target/lib/libI80486gnuvx.a

    we are writing only this peace of code.

    in the file named acdgroup.h,

    class ACDGroup
       std::list<int> ilist;

    this class also contains other stuffs including rogue wave collections.

    we are fighting day and night to solve this problem but of no avail. please guide us.

    the error we are getting is:

    !> Linking ASysContainer
    make[4]: Leaving directory `C:\viewstore\rparam01_view6\callp_voice_and\Business\CallP\RoseRT\Context_NBX100\build'
    make[3]: Leaving directory `C:\viewstore\rparam01_view6\callp_voice_and\Business\CallP\RoseRT\Context_NBX100'
    make[2]: Leaving directory `C:\viewstore\rparam01_view6\callp_voice_and\Business\CallP\RoseRT'
    make \
            --directory \
    make[2]: Entering directory `C:\viewstore\rparam01_view6\supporting_files_and\tornado\target\config\pc486_NCP_NBX100'
    make -f
    make[3]: Entering directory `C:\viewstore\rparam01_view6\supporting_files_and\tornado\target\config\pc486_NCP_NBX100'
    cc386 -BC:\viewstore\rparam01_view6\supporting_files_and\tornado/host/x86-win32/lib/gcc-lib/ -c -m486 -ansi -nostdinc -O -fvolatile -nostdlib -fno-builtin -fno-defer-pop -Wall -I/h   -I. -IC:\viewstor
    e\rparam01_view6\supporting_files_and\tornado\target\config\all -IC:\viewstore\rparam01_view6\supporting_files_and\tornado\target/h -IC:\viewstore\rparam01_view6\supporting_files_and\tornado\target/sr
    c/config -IC:\viewstore\rparam01_view6\supporting_files_and\tornado\target/src/drv -DCPU=I80486   -DNBX_PRODUCT_NBX100 -DINCLUDE_USER_APPL -DUSER_APPL_INIT="NBX100SystemInit()" -DINCLUDE_NET_SYM_TBL
    -g -o version.o C:\viewstore\rparam01_view6\supporting_files_and\tornado\target\config\all/version.c
    cc386 -BC:\viewstore\rparam01_view6\supporting_files_and\tornado/host/x86-win32/lib/gcc-lib/ -nostdlib -r -Wl,-X \
        -o vxWorks.tmp sysALib.o sysLib.o csend.o ftpdlib.o  usrConfig.o version.o C:\viewstore\rparam01_view6/callp_voice_and/Business/CallP/RoseRT/Context_NBX100/build/ASysContainer C:\viewstore\rparam0
    1_view6/ncp_and/Support/HTTPServer/obj.vxworks.NBX100/tEmWeb_NBX100.o C:\viewstore\rparam01_view6/ncp_and/Support/lib/libRTOS_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libVoiceMail_NB
    X100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libAutoAttendant_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libOffSiteNotification_NBX100_d.a C:\viewstore\rparam01_view6/ncp_a
    nd/Support/lib/libVoiceAppUtils_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libDatabaseIL_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libDeviceIL_NBX100_d.a C:\viewstore\
    rparam01_view6/ncp_and/Support/lib/libDeviceUI_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libDownloader_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libDirectoryServices_
    NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libIMAP_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libLogger_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libMe
    diaServer_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libNetwork_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libRDC_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support
    /lib/libUtils_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libVAppIL_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Support/lib/libi18n_NBX100_d.a C:\viewstore\rparam01_view6/ncp_and/Sup
    port/lib/libvistact_NBX100.o C:\viewstore\rparam01_view6/ncp_and/Support/lib/libEncrypt_d.a C:\viewstore\rparam01_view6\supporting_files_and\tornado\target/lib/libI80486gnuvx.a
    C:\viewstore\rparam01_view6\supporting_files_and\tornado\target/lib/libI80486gnuvx.a(stlinst.o)(.data+0xa8): multiple definition of `__default_alloc_template<true, 0>::__node_allocator_lock'
    C:\viewstore\rparam01_view6/ncp_and/Support/lib/libDatabaseIL_NBX100_d.a(acdgroup.o)(.data+0x30):C:\viewstore\rparam01_view6\ncp_and\Support\DatabaseIL\Profiles/acdgroup.cpp: first defined here
    collect2: ld returned 1 exit status
    cc386: Internal compiler error: program ld got fatal signal 1
    make[3]: *** [vxWorks] Error 0x1
    make[3]: Leaving directory `C:\viewstore\rparam01_view6\supporting_files_and\tornado\target\config\pc486_NCP_NBX100'
    make[2]: *** [exe] Error 0x2
    make[2]: Leaving directory `C:\viewstore\rparam01_view6\supporting_files_and\tornado\target\config\pc486_NCP_NBX100'
    make[1]: *** [link] Error 0x2
    make[1]: Leaving directory `C:\viewstore\rparam01_view6\ncp_and'
    make: *** [build_nbx100] Error 0x2

    Ranga & himanshu
    LVL 39

    Accepted Solution

    I still can't see a conflict between RoqueWave and STL.

    What I see is that some compile and link options were set to not using 'stdinc' and 'stdlib' what could mean 'no STL':


    I couldn't say that by removing these options from your makefile it should work (more likely you'll get other problems instead), but you can make it a trial. Note, you need to clean and rebuild all sources you have when removing these options.

    >>>> multiple definition of `__default_alloc_template<true, 0>::__node_allocator_lock':

    Actually it's a link error. The linker finds the same template function 'default_alloc_template::node_allocator_lock'' - instantiated with template parameters 'true, 0' - twice. The first in 'stlinst.o' that might come from the library 'libencrypt_d.a' and the second in 'acdgroup.o' that was compiled from 'acdgroup.cpp'.  I assume the latter is the source you added and where you are getting the problems. Note, a template instantiation happens when you are defining a concrete variable of a template function, e. g.  std::list<int> ilist;. Here the compiler creates an object module ofthe constructor function std::list<T>::list replacing the template  parameter <T> by 'int'. As the constructor of std::list is based on other templates, e. g. for allocation memory it seems to use template 'default_alloc_template', there are more than on template instantiations when defining an STL template variable.

    What to do?

    I would suggest to try the following alternatives (you may change the order)

    1. Try to remove the -nostdinc option from your makefile and rebuild the project
    2. Try to remove the -nostdlib option from your makefile and rebuild the project
    3. Try to remove both flags
    4. Check the libencrypt_d library:
        - maybe there are more than one version (with and without STL)
        - try to use release lib instead of debug (should be libencrypt_r.a or libencrypt.a)
        - check if there is a separate dll of libencrypt instead of a static object library
          (you wouldn't get object module conflicts when using a dll)
        - you also could change link options so only *missing* object modules and *not all*
          modules were linked from that lib (sorry, I don't know these options but they must exist)
    5. Reinstall your compiler (latest version) and check for 'STL' options when reinstalling.
    6. Reinstall libencrypt - if it is a third party product
    7. If all doesn't help, post a new question here in EE but change the title to 'Linker problems with
        GNU compiler when using STL classes' (as I couldn't see any RoqueWave conflict).

    Still good luck.

    Regards, Alex

    BTW, I still don't know the platform and the compiler version you are using.
    LVL 1

    Author Comment

    the environment is
    vxWorks 5.40
    compiler gnu cc386
    tornado 2.0

    we tried every thing you suggested but its not working.

    ranga & himanshu
    LVL 1

    Author Comment

    thanks for all posting from Alex
    From his answers.I found he is a knowledgeble person in this topic

    Thanks Alex

    LVL 39

    Expert Comment


    I am sorry that it isn't working.

    Regards, Alex

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now