CC \ GCC编译的可执行文件无法在我的计算机上运行?

时间:2019-07-04 17:38:05

标签: c gcc cc

简而言之,我想开始一个辅助项目,我需要将我的代码制作成this.customers.forEach(customer => { this.customerService .createCustomer(customer) .pipe(take(1)) .subscribe(() => {}); }); 。我设法做到了,但是每当我尝试单击它时,都会出现错误:

  

此应用无法在您的PC上运行

普通终端完美运行可执行文件。

我已经知道这是一个路径问题,并且我一直在寻找答案已有几天了。我只是不知道PATH问题是什么,也不知道如何使.exe包含其路径,以便它可以单击。

我认为问题不在实际代码中,但我仍将在此处包括Makefile的快照:

%.exe

正常模式下的主要错误消息:

  

此应用无法在此PC上运行

管理模式下的错误消息:

  

Windows找不到“ [] / [] / server.exe”,请确保键入   正确命名。

如果可能的话,我只是不知道在哪里设置路径或如何自动进行设置。

2 个答案:

答案 0 :(得分:0)

解释肯定是二进制文件与GCC安装目录中的DLL链接。

确定二进制文件链接到的dll的最简单方法是执行strings server.exe | find /i ".dll"

没有strings.exe吗?看到以下问题:https://superuser.com/questions/124081/is-there-a-windows-equivalent-of-the-unix-strings-command

答案 1 :(得分:0)

以下建议的Makefile:

  1. 应产生所需的输出
  2. 启用警告,以便将编译问题通知用户

,现在是建议的Makefile:

OBJDIR   := obj
LIBDIR   := lib
SRCDIR   := src
INCDIR   := include


NAME    := server.exe

SHELL   := /bin/sh
CC      := gcc
DEBUG   :=  -ggdb3

CFLAGS  :=  $(DEBUG) -Wall -Wextra -pedantic -Wconversion -std=c11
MAKE    :=  /usr/bin/make
CC      :=  /usr/bin/gcc
LFLAGS  :=  -L/usr/local/lib
LIBS    :=   -lm


.PHONY: all
all : $(NAME) 


#
# macro of all *.c files 
# (NOTE:
# (the following 'wildcard' will pick up ALL .c files in the source directory
SRC := $(wildcard $(SRCDIR)/*.c)
OBJ := $(SRC:.c=.o)
DEP := $(SRC:.c=.d)


#
# link the .o files into the executable 
# using the linker flags
# -- explicit rule
#
%(LIBDIR)/$(NAME): $(OBJDIR)/$(OBJ) 
    #
    # ======= $(NAME) Link Start =========
    @echo "linking into executable..."
    $(CC) -o $@ $^  $(LFLAGS) $(LIBS)
    # ======= $(NAME) Link Done ==========
    #

#
#create dependency files 
%.d: %.c 
    # 
    # ========= START $< TO $@ =========
    @echo "Making dependencies..."
    $(CC) -MMD $(CFLAGS) -c -o $@ $<
    # ========= END $< TO $@ =========

# 
# compile the .c file into .o files using the compiler flags
#
%.o: %.c %.d 
    # 
    # ========= START $< TO $@ =========
    @echo "Making objects..."
    $(CC) $(CFLAGS) -c $< -o $@ -I$(INCDIR)
    # ========= END $< TO $@ =========
    # 

.PHONY: clean
clean: 
    # ========== CLEANING UP ==========
    rm -f $(OBJDIR)/*.o
    rm -f $(name)
    rm -f *.d
    # ========== DONE ==========



# include the contents of all the .d files
# note: the .d files contain:
# <filename>.o:<filename>.c plus all the dependencies for that .c file 
# I.E. the #include'd header files
# wrap with ifneg... so will not rebuild *.d files when goal is 'clean'
#
ifneq "$(MAKECMDGOALS)" "clean"
-include $(DEP)
endif
相关问题