1752822 Members
4619 Online
108789 Solutions
New Discussion юеВ

C++ program

 
Xiaowen Wu_1
New Member

C++ program

I used g++ (version 3.1) to compile a simple helloworld.cpp program. I used -static for the link flags.

#include
#include

int main(int argc, char *argv[])
{
std::string str1 = "hello world";
printf("Hello World \n");
std::cout << "Hello World" << std::endl;
std::cout << str1 << std::endl;
return(0);
}

The program works fine on the machine which have gcc installed, but when I copied the program to another HP-UX machine, which don't have g++ installed, it got a memory falut

# ./he
Hello World
Memory fault(coredump)

and ldd show not missing dynmaic lib.
# ldd he
/usr/lib/libdld.2 => /usr/lib/libdld.2
/usr/lib/libc.2 => /usr/lib/libc.2
/usr/lib/libdld.2 => /usr/lib/libdld.2

Does anybody know how to resolve this problem ?

Thank you very much
2 REPLIES 2
Vibhor Kumar Agarwal
Esteemed Contributor

Re: C++ program

These are some system libraries.

Check in your new system whether you have those files in /usr/lib.

It also looks like library incompatibility problem.
You might be having a different version of libs in your new machine, something like
libc.1
Vibhor Kumar Agarwal
Xiaowen Wu_1
New Member

Re: C++ program

Both machine have the same version of OS, and seems to both have libc.2 and libdld.2

Which system library need to be verified ?