小编mat*_*656的帖子

C++ 生成文件错误“主可执行文件的隐式入口/启动”

我的项目有这个结构:

root
|____Makefile
|
|___src
|     |____*.cpp  
|
|___includes
|      |___*.h
|
|___obj
|___tmp
|___bin
Run Code Online (Sandbox Code Playgroud)

问题是,当我尝试使我收到此错误时:

g++ -std=c++11 obj/book.o -o bin/main
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

我的 main.cpp 位于 src 内,而不是我有一个文件 .h,我在其中声明了一个结构和一些函数以及一个 .cpp,我在其中定义了所有内容。在主要和 cpp 我做

root
|____Makefile
|
|___src
|     |____*.cpp  
|
|___includes
|      |___*.h
|
|___obj
|___tmp
|___bin
Run Code Online (Sandbox Code Playgroud)

我如何编译和解决这个问题?这是我的生成文件:

CXX …
Run Code Online (Sandbox Code Playgroud)

c++ macos compiler-errors makefile

0
推荐指数
1
解决办法
2127
查看次数

标签 统计

c++ ×1

compiler-errors ×1

macos ×1

makefile ×1