0

Hi am trying to compile a src file by linking an external library.

Getting below error
undefined reference to `__isoc99_sscanf@GLIBC_2.7'

make -f GNUmakefile
g++ -m32 -D_POSIX_PTHREAD_SEMANTICS -g -Wl,--version-script=fix.txt -D_GNU_SOURCE    -I../include ConnectionAndAuthExample.cpp -o ../Linux/ConnectionAndAuthExample_32 -L../Linux -lsomelib
../Linux/libsomelib.so: undefined reference to `__isoc99_sscanf@GLIBC_2.7'

Contents of fix.txt are

GLIBC_2.7 {
 global: *;
 local: *;
};

Similar query was answered below here doesnt help. I want to know if anyone else have encountered similar error and resolved it.

My GCC version

-bash-3.2$ g++ --version
g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-50)
unbesiegbar
  • 471
  • 2
  • 7
  • 19

1 Answers1

0

Finally the link in the question help with slight modification from other answers. Here is my fix.

I created a new cpp file with below contents

#include <iostream>
#include <stdarg.h>

__asm__(".symver __isoc99_sscanf,__isoc99_sscanf@GLIBC_2.7");

#ifdef __cplusplus
extern "C" {
#endif

int __isoc99_sscanf(const char *a, const char *b, va_list args)
{
   int i;
   va_list ap;
   va_copy(ap,args);
   i=sscanf(a,b,ap);
   va_end(ap);
   return i;
}

#ifdef __cplusplus
}
#endif

Compiled it to get the object file and used it along with fix.txt mentioned in the question.

However, I would like to inform that since my third party library was compiled on an higher version. I am getting ELF file OS ABI invalid when I run my binary.

There solution from some other answer which suggests to use patchelf and modify intert section doesnt help as shared files mostly dont have that section.

I also tried to compile glibc2.7 and build my binary using

-Wl,--dynamic-linker
-Wl,--rpath

flags pointing to glibc2.7 . Still in vain.

unbesiegbar
  • 471
  • 2
  • 7
  • 19