简体   繁体   中英

Can't compile RIES with MinGW on Win7

I'm trying to compile this program using MinGW on Windows 7. On my first try it gave me this error:

>gcc -o ries.exe ries.c -lm

ries.c:1582:21: fatal error: stdafx.h: No such file or directory
compilation terminated.

I googled for a bit and found out I should remove the # include "stdafx.h" line, which I did.

Now it gives me this:

C:\Users\XXXXXX\AppData\Local\Temp\cczlkqve.o:ries.c:(.text+0xb9): undefined reference to `asprintf'
collect2: ld returned 1 exit status

Google is now silent... what should I do next?

Thanks in advance.

MinGW uses (AFAIK) the Microsoft C run-time library. I don't think asprintf or an equivalent exists in that - although that is odd since he's included stdafx.h for Windows builds anyway, although not in a particularly useful way (it can't AFAICS be used for pre-compiled headers since it's inside an #if)

The simplest fix would be to allocate the buffer yourself, ie change

char * name_ext;
int nc;
nc = asprintf(&name_ext, "%s.ries", filename);

to

char name_ext[MAX_PATH];
int nc;
nc = snprintf(name_ext, MAX_PATH, "%s.ries", filename);

If MAX_PATH isn't defined (but I think it will be: you've already got stdlib.h) then either define it yourself or just substitute the number 260.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM