免费的 Pascal 编译器无法 link,错误 "heaptrc.o: undefined reference to symbol '_end'"

Free Pascal compiler failed to link with error "heaptrc.o: undefined reference to symbol '_end'"

我正在尝试使用 Free Pascal 编译程序,使用 -gh 标志打开 heaptrc 以找出内存泄漏并获取错误消息

/usr/bin/ld: /usr/local/lib/fpc/3.0.4/units/x86_64-linux/rtl/heaptrc.o: undefined reference to symbol '_end'
//usr/lib/x86_64-linux-gnu/librtmp.so.1: error adding symbols: DSO missing from command line

如果我关闭 -gh 标志,我的程序就会成功构建。

以前 -gh 标记工作正常。它似乎发生在我 运行 Free Pascal cross compiling 或安装 libcurl4-gnutls-dev 之后。不知道也不记得了

为什么会触发错误消息?

我 post 在这里,Jonas Maebe 的回答来自 FreePascal forum

It seems that linking libcurl somehow hides the "_end" symbol: _end symbol disappears when linking to libcurl

-gh needs this symbol to know where the initialised data section ends. I'm not sure there's anything FPC can do to fix this, since it apparently also happens with gcc (and I'm not aware of another easy way to detect that address).