找不到-lgcc

找不到-lgcc

我正在尝试在 hello-world 之后编译我的下一个基本 c 程序。这包含两个支持模块。我在 Mac 上通过 VirtualBox 在虚拟机中运行 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

答案1

哦,没关系。我刚刚意识到我似乎没有 32 位库。应该makefile代替.-m64-m32

相关内容