问题
I'm trying to compile ffmpeg in windows for VisualStudio and one of the step is to compile c99-to-c89 code with clang according to this post. I managed to create clang.exe but how I compile c99-to-c89 code with it?
I changed a little bit the makefile in c99-to-c89 so CC
variable points now to clang.exe compiler and not cl.exe
EXT=.exe
all: c99conv$(EXT) c99wrap$(EXT)
CLANGDIR=C:/build
CC=C:/build/bin/Release/clang.exe
CFLAGS=-nologo -Z7 -D_CRT_SECURE_NO_WARNINGS=1 -Dpopen=_popen -Dunlink=_unlink -Dstrdup=_strdup -Dsnprintf=_snprintf -I. -I$(CLANGDIR)/tools/clang/include
LDFLAGS=-nologo -Z7 $(CLANGDIR)/lib/Release/libclang.lib
clean:
rm -f c99conv$(EXT) c99wrap$(EXT) convert.o compilewrap.o
rm -f unit.c.c unit2.c.c
test1: c99conv$(EXT)
$(CC) -P unit.c -Fiunit.prev.c
./c99conv unit.prev.c unit.post.c
diff -u unit.{prev,post}.c
test2: c99conv$(EXT)
$(CC) -P unit2.c -Fiunit2.prev.c
./c99conv unit2.prev.c unit2.post.c
diff -u unit2.{prev,post}.c
test3: c99conv$(EXT)
$(CC) $(CFLAGS) -P -Ficonvert.prev.c convert.c
./c99conv convert.prev.c convert.post.c
diff -u convert.{prev,post}.c
c99conv$(EXT): convert.o
$(CC) -Fe$@ $< $(LDFLAGS) $(LIBS)
c99wrap$(EXT): compilewrap.o
$(CC) -Fe$@ $< $(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -Fo$@ -c $<
but when I run make
command I get clang: error: unsupported use of internal gcc -Z option '-Z7'
. I guess the problem in CFLAGS
and LDFLAGS
but I don't know how to fix it because the lack of knowledge in makefile and clang.
回答1:
If someone still needs, the guys from libav provided me with this link to download the binaries c99conv.exe
, c99wrap.exe
, makedef
回答2:
c99conv wust be compilled with msvc compiller, but it uses libraries from LLVM. Actualy, converter uses clang as a parser C99 sources.
Therefore clang needs to be compilled with MSVC (because MSVC will link libclang with c99conv).
So, just lead the build instructions from article you link.
- Run visual studio command promt.
- Run msys shell from mingw.
- Tune Makefile.w32 for your environment
- Compile c99conv with Makefile.w32
make -f Makefile.w32
来源:https://stackoverflow.com/questions/13475775/how-to-compile-c99-to-c89-convertor-with-clang