Results 1 to 4 of 4
The error is:
error while loading shared libraries: libncurses.so.5: cannot open shared object file: Error 24
This occurs after a good time of running, after I added some file stuff ...
- 10-06-2010 #1Just Joined!
- Join Date
- Oct 2010
- Posts
- 5
Program stops working after a time with "libncurses.so.5 Error 24"
The error is:
error while loading shared libraries: libncurses.so.5: cannot open shared object file: Error 24
This occurs after a good time of running, after I added some file stuff to my code. I can't see why this is happening.
Code:
Code:// Get CPU Temperature char sensorsRaw[128]; system("sensors >& .sensors"); std::ifstream fileIn; fileIn.open(".sensors"); if( !fileIn.is_open() ) { printf("ERROR: .sensors file read failed.\n"); } else { while( !fileIn.eof() ) { fileIn.getline(sensorsRaw, 128); std::string sensorsStr(sensorsRaw); std::string tempStr = sensorsStr.substr(0, 5); if( tempStr.compare("temp1") == 0 ) { std::string value = sensorsStr.substr(14, 7); int pointIndex = value.find_first_of("."); int degIndex = value.find_first_of("°"); int index = 2; if( degIndex != -1 && degIndex < pointIndex ) index = degIndex; else index = pointIndex; std::string roundedVal = value.substr(0, index); int valInt = atoi( roundedVal.c_str() ); std::cout << "CPU Temp: " << value << std::endl; break; } // end: if( tempStr.compare() == 0 ) } // end: while( !file.eof() ) } // end: else( file.is_open() ) fileIn.close(); system("rm .sensors"); //Get CPU clocked speed char cpuinfoRaw[128]; system("cat /proc/cpuinfo >& .cpuinfo"); std::ifstream cpuinfoIn; cpuinfoIn.open(".cpuinfo"); if( !cpuinfoIn.is_open() ) { printf("ERROR: .cpuinfo file read failed.\n"); } else { while( !cpuinfoIn.eof() ) { cpuinfoIn.getline(cpuinfoRaw, 128); std::string cpuinfoStr(cpuinfoRaw); std::string cpuStr = cpuinfoStr.substr(0, 7); if( cpuStr.compare("cpu MHz") == 0 ) { std::string value = cpuinfoStr.substr(11, 8); int index = value.find_first_of("."); std::string roundedVal = value.substr(0, index); std::cout << "CPU Throttled speed: " << value << std::endl; break; } } // end: while( !cpuinfoIn.eof() ) cpuinfoIn.close(); } // end: else( cpuinfoIn.is_open() ) system("rm .cpuinfo"); sleep(CYCLETIME);
- 10-06-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Where are you using ncurses functions in your application?
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 10-07-2010 #3Just Joined!
- Join Date
- Oct 2010
- Posts
- 5
I have no idea where libncurses is called.
This is the only part I left out, called just inside the while loop. I didn't include it, because the code runs fine with the part I provided omitted. However, here it is.
Function definition:Code://Check computer for connectivity int ret = 0; ret = pingHost((char*) "computer", 1);
Assume that some of these extra functions are included elsewhere. I've tested the ping code, and it works.Code:int pingHost( char* hostToPing, int timeout ) { struct sockaddr_in *to = (struct sockaddr_in *) &whereto; struct protoent *proto; bzero( (char *)&whereto, sizeof(struct sockaddr) ); to->sin_family = AF_INET; to->sin_addr.s_addr = inet_addr(hostToPing); if(to->sin_addr.s_addr != (unsigned)-1) { strcpy(hnamebuf, hostToPing); hostname = hnamebuf; } else { hp = gethostbyname(hostToPing); if(hp) { to->sin_family = hp->h_addrtype; bcopy(hp->h_addr, (caddr_t)&to->sin_addr, hp->h_length); hostname = hp->h_name; } else { return pingUnknownHost; } } ident = getpid() & 0xFFFF; if ((proto = getprotobyname("icmp")) == NULL) { return pingUnknownProtocol; } if ((sd = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0) { //Usually caused by not running as root return pingSocketError; } //Set socket timeout struct timeval recvTimeout; recvTimeout.tv_sec = timeout; setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, &recvTimeout, sizeof(recvTimeout)); //Set up receive variables int cc; u_char packet[MAXPACKET]; int len = sizeof (packet); socklen_t fromlen = sizeof(from); //Send ping int pingerRet = pingtest_pinger(); if( pingerRet == pingSendingFailed || pingerRet == pingUnknownError ) { return pingerRet; } //Wait for return if ( ( cc = recvfrom(sd, packet, len, 0, &from, &fromlen) ) < 0) { return pingReceiveFailed; } //printf("Packet: %x, %x, %x, %x\n", packet[0], packet[1], packet[2], packet[3]); struct ip *ip = (struct ip *) packet; struct icmp *icp; int hlen = ip->ip_hl << 2; if (cc < hlen + ICMP_MINLEN) { printf("packet too short (%d bytes)\n", cc); } cc -= hlen; icp = (struct icmp *)(packet + hlen); if( icp->icmp_type == ICMP_ECHOREPLY ) { return pingSuccess; } else if( icp->icmp_type == ICMP_DEST_UNREACH ) { return pingUnreachable; } else if( icp->icmp_type == ICMP_SOURCE_QUENCH ) { return pingSourceQuench; } else if( icp->icmp_type == ICMP_REDIRECT ) { return pingRedirect; } else if( icp->icmp_type == ICMP_ECHO ) { return pingEcho; } else if( icp->icmp_type == ICMP_TIME_EXCEEDED ) { return pingTimeExceeded; } else if( icp->icmp_type == ICMP_PARAMETERPROB ) { return pingParameterProb; } else { return pingUnknownError; } //Shouldn't get here return pingUnknownError; }
Some symptoms of this problem:
* The code went through 2039 iterations before erroring, with a cycle time of 3 seconds, so it ran successfully for an 1h42.
* It just immediately starts spewing the error:
sh: error while loading shared libraries: libncurses.so.5: cannot open shared object file: Error 24
* Then, on iteration 2184, it starts with new errors:
ERROR: .sensors file read failed.
ERROR: .cpuinfo file read failed.
"computer": Unknown Host (check /etc/hosts file)
* From that point on, the errors are interspersed for the rest of the run.
- 10-07-2010 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
How are you starting this program? In a command-line shell, or something else? What shell are you using?
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote