I'm trying to use libjasper from http://www.ece.uvic.ca/~frodo/jasper/ as a static library in compiling dcraw.c from http://www.cybercom.net/~dcoffin/dcraw/ on windows with VC9. I have resolved several issues on the way and finally get three linking errors.
1>dcraw.obj : error LNK2001: unresolved external symbol _ftello
1>dcraw.obj : error LNK2001: unresolved external symbol _fseeko
1>dcraw.obj : error LNK2001: unresolved external symbol _getc_unlocked
the first two of these are easily resolved it seems, I added
#define fseeko _fseeki64
#define ftello _ftelli64
and that does it but what about the third one:
1>dcraw.obj : error LNK2001: unresolved external symbol _getc_unlocked
How can I work around that on windows with visual studio?
Thanks.
The actual equivalent of getc_unlocked
is not getc
, it's _fgetc_nolock
. So, assuming that whoever wrote the original code knew what he's doing and had some reasons to prefer the thread-unsafe version, you probably want this :
#define getc_unlocked _fgetc_nolock
#define getc_unlocked _fgetc_nolock
Only difference is that getc
is thread-safe (and probably slower).
http://pubs.opengroup.org/onlinepubs/000095399/functions/getc_unlocked.html
EDIT: As @Fanael pointed out in another answer, _fgetc_nolock
makes for a better replacement than getc
.
这是一个不在win32上的posix函数,只是这样做
#define getc_unlocked fgetc
Replace calls to getc
and getc_unlocked
with fgetc
when compiling for Windows.
I vaguely remember ftello, fseeko and possibly getc_unlocked as being specific to linux/gcc/posix.
getc is roughly prototyped as int getc( FILE* f);
fgetc is roughly prototyped as int fgetc( FILE* f );
and, in fact, in MSVS 10, getc is a define for fgetc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.