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

Posted on 2005-04-19
Medium Priority
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
  • 4
  • 4
LVL 39

Expert Comment

ID: 13815396
>>>> 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


Author Comment

ID: 13830914
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

ID: 13831321
'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', 'stlinst.cc' 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,

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 13840337
we have no sorce code of any of the file stlinst.cpp,stlinst.cxx,stlinst.cc 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 release.mk
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

itsmeandnobodyelse earned 750 total points
ID: 13840747
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.

Author Comment

ID: 13843192
the environment is
vxWorks 5.40
compiler gnu cc386
tornado 2.0

we tried every thing you suggested but its not working.

ranga & himanshu

Author Comment

ID: 13983708
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

ID: 13986854

I am sorry that it isn't working.

Regards, Alex

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

749 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