EJane
EJane

Reputation: 53

undefined reference to __isoc99_sscanf

I have a static C library libex.a that uses sscanf. Library was compiled using -std=c99

I want to use the library function in some C++ code that I am compiling using -std=c++11, but I get the following error:

lib/libex.a(srcfile.o): In function `my_function':
/srcpath/srcfile.c:215: undefined reference to `__isoc99_sscanf'

After poking around a bit, I have discovered that sscanf has issues with versions due to a backwards compatibility hack, hence the redirect to __isoc99_sscanf, so I suspect that is somehow the source of the problem. However, I checked my version of glibc and it looks recent enough that the solution suggested elsewhere (update your copy of glibc to at least 2.7) isn't helpful.

$ ldd --version
ldd (Ubuntu EGLIBC 2.19-0ubuntu6.6) 2.19

Any suggestions?

Of course, let me know if there's any additional information that would be relevant.

Thanks!

UPDATE: If I compile libex.a with -D_GNU_SOURCE the error message is changed to undefined reference to sscanf. Not sure if that will help figure out what's going wrong.

Upvotes: 4

Views: 5795

Answers (1)

EJane
EJane

Reputation: 53

In case anyone else runs into this problem:

The Makefile for the C++ code disabled the standard libraries and start files using flags -nostdlib -nodefaultlibs -nostartfiles. It instead linked to the version of stdio.h included in the Intel SGX SDK for running inside enclaves. That version deprecates sscanf.

Upvotes: 1

Related Questions