Ubuntu
找不到-lgcc
我正在嘗試在 hello-world 之後編譯我的下一個基本 c 程序。這包含兩個支持模組。我通過 Mac 上的 VirtualBox 在 VM 中執行 Ubuntu。一切都是最新的,但我似乎無法建構:
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc /usr/bin/ld: cannot find -lgcc /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s /usr/bin/ld: cannot find -lgcc_s collect2: error: ld returned 1 exit status
我也只是在學習makefile,所以很可能有一些東西在那裡。
main
包括b
其中包括c
。我正在嘗試連結<stdlib.h>
和<math.h>
。我的
makefile
:# Specify the C complier CC = gcc # List the compiler flags you want to pass to the compiler # -g compile with debug information # -Wall give all diagnostic warnings # -pedantic require compliance with ANSI standard # -O0 do not optimize generated code # -std=gnu99 use the Gnu C99 standard language definition # -m32 emit code for IA32 architecture # -D_GNU_SOURCE use GNU library extension # -v verbose, display detailed information about the exact # sequence of commands used to compile and link a program CFLAGS = -g -Wall -pedantic -O0 -std=gnu99 -m32 -D_GNU_SOURCE # The LDFLAGS variable sets flags for linker # -lm link in libm (math library) # -m32 link with IA32 libraries LDFLAGS = -lm -m32 # In this section, list the files that are part of the project. # If you add/change names of header/source files, here is where you # edit the makefile. # List your c header files HEADERS = c.h b.h # List your c source files SOURCES = c.c b.c main.c OBJECTS = $(SOURCES:.c=.o) # List your libraries #LIBRARIES = -L. # specify the build target (what is your program name?) TARGET = validator # The first target defined in the makefile is the one # used when make is invoked with no argument. Given the definitions # above, this makefile file will build the one named TARGET and # assume that it depends on all the named OBJECTS files. default: $(TARGET) $(TARGET) : $(OBJECTS) makefile.dependencies $(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LDFLAGS) $(LIBRARIES) # In make's default rules, a .o automatically depends on its .c file # (so editing the .c will cause recompilation into its .o file). # The line below creates additional dependencies, most notably that it # will cause the .c to be recompiled if any included .h file changes. makefile.dependencies:: $(SOURCES) $(HEADERS) $(CC) $(CFLAGS) -MM $(SOURCES) > makefile.dependencies -include makefile.dependencies # Phony means not a "real" target, it doesn't build anything # The phony target "clean" that is used to remove all compiled object files. .PHONY: clean clean: @rm -f $(TARGET) $(OBJECTS) core makefile.dependencies
哦,沒關係。我剛剛意識到我似乎沒有 32 位庫。
makefile
應該-m64
代替-m32
. _