c++ Application crashes at map :: insert function

Hi All,

My cpp application runs fine on solaris & hp-ux but crashes on Linux.The application is crashing at insert() function of a map. The map variable is the static member variable of a class. But when i write the sample pgm with the same scenario it works fine.
I use following flags while compiling application.
CFLAGS_STATIC_LINKING = -Wall
LD_FLAGS_STATIC_LINKING = -O3 -nostdlib

Please give your suggestions.

sample program having the same logic:

File TMap.h
============================================
#include<map>

using namespace std;

class TMap
{
public:
typedef map<string, string> TestMap;
static void func();
private:
static TestMap m_TestMap;
};
=============================================
File TMap.cpp
=============================================
#include<iostream>
#include"TMap.h"

using namespace std;

//typedef map<string, string> TestMap;
TMap::TestMap TMap::m_TestMap;

int main()
{
TMap::func();
return 0;
}

void TMap::func()
{
cout << "Start ::" <<endl;
m_TestMap.insert(TMap::TestMap::value_type("HI","Hello"));
cout << "End :: %u" << &m_TestMap <<endl;
}
What is your exact compilation line and link line?

With the above code verbatim,

g++ -Wall -O3 -nostdlib TMap.cpp

generates a whole bunch of unresolved externals on the link phase since the C++ runtime isn't linked in.
TMap.cpp is the sample pgm which gives the same logic used in my cpp application. I use the specified flags while compilation of application and not the above sample pgms.

I wont be able to provide the exact compile & link lines but they are like as below:

compile line for the file where application core dumps:
g++ -DLINUX -D_DEBUG -g -D_USE_STLQ_ -Wall -I../include/ -I/usr/local/include/ -I/usr/include/ -I../include/<lib1> -I../include/<lib2>/include -c ../src/<file>.cpp

Link line is like:

g++ -D_DEBUG -g -o Final -O3 -nostdlib /usr/lib/gcc/i386-redhat-linux/3.4.5/crt1.o /usr/lib/gcc/i386-redhat-linux/3.4.5/crti.o /usr/lib/gcc/i386-redhat-linux/3.4.5/crtn.o /usr/lib/gcc/i386-redhat-linux/3.4.5/crtbegin.o /usr/lib/gcc/i386-redhat-linux/3.4.5/crtend.o <list of object files> -L/usr/lib -L/lib -L/usr/local/lib -L../lib_linux/<lib1> -L../lib_linux/<lib2> -L/usr/lib/gcc/i386-redhat-linux/4.0.2/ -Wl,-lpthread -lposix4 -l<lib1> -levent -lovsnmp -lov -lnsl -lm -lc -ldl -Wl,-static -lstdc++ -lgcc_eh -lgcc
Topic archived. No new replies allowed.