开源项目是 c 语言开发的,自己开发的代码也是 c,编译器用的 mac 自带的 clang ,项目用 cmake 构建,后面我写了简单的 demo ,直接使用命令行编译也是一样的错误,实在有点想不明白。
错误如下:
Undefined symbols for architecture arm64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
系统:
CPU: Apple M1 Max
内存: 64G
系统版本: macOS Monterey 12.6 (21G115)
clang 版本:
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
cmake 版本:
cmake version 3.25.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Demo 静态库代码:
tt.h
#ifndef DLB_TT_H
#define DLB_TT_H
void hello(void);
#endif //DLB_TT_H
tt.c
#include "tt.h"
#include
void hello(void)
{
printf("Hello, I m lj!\n");
}