sgan81 / apfs-fuse

FUSE driver for APFS (Apple File System)
GNU General Public License v2.0
1.78k stars 164 forks source link

Compile error on CentOS 7 #94

Open travisbutton opened 5 years ago

travisbutton commented 5 years ago

Apologies in advance for what may be a simple fix, I'm very unfamiliar with C. I've looked for solutions on several forums, gone into the makefile both in the "build" directory and "lzfse" directory to add CFLAGS=-std=c99 and this is still kicking the same error. Any ideas?

make
[  2%] Building C object CMakeFiles/lzfse.dir/3rdparty/lzfse/src/lzfse_decode.c.o
In file included from /home/administrator/apfs-fuse/3rdparty/lzfse/src/lzfse_internal.h:30:0,
                 from /home/administrator/apfs-fuse/3rdparty/lzfse/src/lzfse_decode.c:25:
/home/administrator/apfs-fuse/3rdparty/lzfse/src/lzfse_fse.h: In function \u2018fse_check_freq\u2019:
/home/administrator/apfs-fuse/3rdparty/lzfse/src/lzfse_fse.h:564:3: error: \u2018for\u2019 loop initial declarations are only allowed in C99 mode
   for (int i = 0; i < table_size; i++) {
   ^
/home/administrator/apfs-fuse/3rdparty/lzfse/src/lzfse_fse.h:564:3: note: use option -std=c99 or -std=gnu99 to compile your code
/home/administrator/apfs-fuse/3rdparty/lzfse/src/lzfse_fse.h:564:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < table_size; i++) {
                     ^
make[2]: *** [CMakeFiles/lzfse.dir/3rdparty/lzfse/src/lzfse_decode.c.o] Error 1
make[1]: *** [CMakeFiles/lzfse.dir/all] Error 2
make: *** [all] Error 2
BShefter commented 4 years ago

I'm on CentOS 7, and I got past this error by editing the "CMakeCache.txt" file in the "build" subdirectory. The file contains two lines that looked like "CMAKE_CXX_FLAGS:STRING=" and "CMAKE_C_FLAGS:STRING=" and I added the flag to each of them:

CMAKE_CXX_FLAGS:STRING=-std=c99 and CMAKE_C_FLAGS:STRING=-std=c99

In case you get the same error I encountered next, you can combine multiple compiler flags on the same line. This is what ultimately worked for me:

CMAKE_CXX_FLAGS:STRING=-std=c99 -std=c++11 and CMAKE_C_FLAGS:STRING=-std=c99 -std=c++11

It may be that only one of these lines needed to be changed, but changing both worked for me.