【问题标题】:Why does tcc not recognize "main" when I include the -pthreads flag?当我包含 -pthreads 标志时,为什么 tcc 无法识别“main”?
【发布时间】:2018-07-17 06:05:19
【问题描述】:

我正在尝试使用带有 tcc 的 gtk 3.0 库编译一个 c 应用程序。文档说运行编译的命令是

gcc `pkg-config --cflags gtk+-3.0` -o [executable name] [source file] `pkg-config --libs gtk+-3.0`

我正在尝试使用 tcc 进行编译,据我所知,语法应该是相同的。但是,在 gcc 编译良好的地方,当我使用 tcc 时,编译失败并出现错误:

tcc: error: undefined symbol 'main'

我将问题与pkg-config --cflags gtk+-3.0 插入的-pthread 标志隔离开来,因此,运行一个简单的“Hello, World”c 程序并编译

tcc -pthread -o [executable name] [source file]

导致同样的错误。是我编译错了,是编译器的bug,还是别的什么?

【问题讨论】:

  • 查看 TCC 文档以了解 -pthread 对您的主程序意味着什么。
  • 最近在 TCC 中出现了一些与 -pthread 相关的问题。请参阅 repo.or.cz/tinycc.git/commit/… 和之前的两个提交。

标签: c gcc pthreads gtk tcc


【解决方案1】:

试试-lpthread

tcc hello.c -lpthread -o hello

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-30
    • 2020-10-11
    • 2018-10-21
    • 2019-11-15
    • 2013-06-20
    • 2021-09-10
    • 1970-01-01
    相关资源
    最近更新 更多