Gmagick和GraphicsMagicks:静态链接

发布于 2025-02-08 19:33:13 字数 5964 浏览 3 评论 0原文

我正在尝试编译一本用Go写成的二进制文件,该二进制文件与GraphicsMagick有一个静态链接(GO Gmagick和他的LibgraphicsMagick1-Dev套件)。

实际上,该二进制可以在动态中完美地工作,但是我想开箱即用,以避免安装库,配置等。

我根本不熟悉静态链接,这是我尝试的:

CGO_ENABLED=0
go build --ldflags='-extldflags=-static'

结果是一个错误的雪崩(我将提到一些,输出比那大):

/usr/bin/ld: (.text+0xd18): undefined reference to `exp'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-gem.o): in function `Hull':
(.text+0x1369): undefined reference to `GOMP_parallel'
/usr/bin/ld: (.text+0x13ad): undefined reference to `GOMP_parallel'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-gem.o): in function `Contrast':
(.text+0x17d3): undefined reference to `sin'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-gem.o): in function `ExpandAffine':
(.text+0x3a8): undefined reference to `sqrt'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-image.o): in function `DisplayImages':
(.text+0x1bde): undefined reference to `XOpenDisplay'
/usr/bin/ld: (.text+0x1bfd): undefined reference to `XSetErrorHandler'
/usr/bin/ld: (.text+0x1cb0): undefined reference to `XCloseDisplay'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-image.o): in function `AnimateImages':
(.text+0x26ca): undefined reference to `XOpenDisplay'
/usr/bin/ld: (.text+0x26e9): undefined reference to `XSetErrorHandler'
/usr/bin/ld: (.text+0x2746): undefined reference to `XCloseDisplay'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-log.o): in function `LogMagickEventList':
(.text+0xbb0): undefined reference to `fmod'
/usr/bin/ld: (.text+0xf01): undefined reference to `fmod'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-omp_data_view.o): in function `AllocateThreadViewDataSet':
(.text+0xba): undefined reference to `omp_get_max_threads'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-omp_data_view.o): in function `AccessThreadViewData':
(.text+0x2c5): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `AccessDefaultCacheView':
(.text+0x17ad): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `AccessImmutableIndexes':
(.text+0x1839): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `AccessMutableIndexes':
(.text+0x1909): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `AccessMutablePixels':
(.text+0x19d5): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o):(.text+0x1b76): more undefined references to `omp_get_thread_num' follow
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `AllocateThreadViewSet':
(.text+0x3c25): undefined reference to `omp_get_max_threads'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `GetImagePixelsEx':
(.text+0x5e56): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `GetImagePixels':
(.text+0x5f6a): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `SetImagePixels':
(.text+0x617c): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `SetImagePixelsEx':
(.text+0x622c): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `SyncImagePixels':
(.text+0x67a8): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o):(.text+0x6838): more undefined references to `omp_get_thread_num' follow
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_iterator.o): in function `PixelIterateMonoRead._omp_fn.0':
(.text+0x94): undefined reference to `GOMP_loop_nonmonotonic_guided_start'
/usr/bin/ld: (.text+0x184): undefined reference to `GOMP_loop_nonmonotonic_guided_next'
/usr/bin/ld: (.text+0x191): undefined reference to `GOMP_loop_end_nowait'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_iterator.o): in function `PixelIterateMonoModifyImplementation._omp_fn.0':
(.text+0x2c5): undefined reference to `GOMP_loop_nonmonotonic_guided_start'
/usr/bin/ld: (.text+0x443): undefined reference to `GOMP_loop_nonmonotonic_guided_next'
/usr/bin/ld: (.text+0x450): undefined reference to `GOMP_loop_end_nowait'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_iterator.o): in function `PixelIterateTripleImplementation':
(.text+0x506): undefined reference to `omp_get_max_threads'

显然不是创建二进制文件。

好像编译器没有找到要编译的C代码。接下来我可以尝试什么?

I'm trying to compile a binary written in Go that we have a static linking with GraphicsMagick (go gmagick and his libgraphicsmagick1-dev package).

Actually the binary works perfectly in dynamic, but I would like an out-of-the-box, to avoid installing libraries, configurations, etc.

I'm not at all familiar with static linking, here's what I tried:

CGO_ENABLED=0
go build --ldflags='-extldflags=-static'

and the result was an avalanche of errors (I will mention a few, the output is way bigger than that):

/usr/bin/ld: (.text+0xd18): undefined reference to `exp'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-gem.o): in function `Hull':
(.text+0x1369): undefined reference to `GOMP_parallel'
/usr/bin/ld: (.text+0x13ad): undefined reference to `GOMP_parallel'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-gem.o): in function `Contrast':
(.text+0x17d3): undefined reference to `sin'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-gem.o): in function `ExpandAffine':
(.text+0x3a8): undefined reference to `sqrt'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-image.o): in function `DisplayImages':
(.text+0x1bde): undefined reference to `XOpenDisplay'
/usr/bin/ld: (.text+0x1bfd): undefined reference to `XSetErrorHandler'
/usr/bin/ld: (.text+0x1cb0): undefined reference to `XCloseDisplay'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-image.o): in function `AnimateImages':
(.text+0x26ca): undefined reference to `XOpenDisplay'
/usr/bin/ld: (.text+0x26e9): undefined reference to `XSetErrorHandler'
/usr/bin/ld: (.text+0x2746): undefined reference to `XCloseDisplay'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-log.o): in function `LogMagickEventList':
(.text+0xbb0): undefined reference to `fmod'
/usr/bin/ld: (.text+0xf01): undefined reference to `fmod'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-omp_data_view.o): in function `AllocateThreadViewDataSet':
(.text+0xba): undefined reference to `omp_get_max_threads'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-omp_data_view.o): in function `AccessThreadViewData':
(.text+0x2c5): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `AccessDefaultCacheView':
(.text+0x17ad): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `AccessImmutableIndexes':
(.text+0x1839): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `AccessMutableIndexes':
(.text+0x1909): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `AccessMutablePixels':
(.text+0x19d5): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o):(.text+0x1b76): more undefined references to `omp_get_thread_num' follow
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `AllocateThreadViewSet':
(.text+0x3c25): undefined reference to `omp_get_max_threads'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `GetImagePixelsEx':
(.text+0x5e56): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `GetImagePixels':
(.text+0x5f6a): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `SetImagePixels':
(.text+0x617c): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `SetImagePixelsEx':
(.text+0x622c): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o): in function `SyncImagePixels':
(.text+0x67a8): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_cache.o):(.text+0x6838): more undefined references to `omp_get_thread_num' follow
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_iterator.o): in function `PixelIterateMonoRead._omp_fn.0':
(.text+0x94): undefined reference to `GOMP_loop_nonmonotonic_guided_start'
/usr/bin/ld: (.text+0x184): undefined reference to `GOMP_loop_nonmonotonic_guided_next'
/usr/bin/ld: (.text+0x191): undefined reference to `GOMP_loop_end_nowait'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_iterator.o): in function `PixelIterateMonoModifyImplementation._omp_fn.0':
(.text+0x2c5): undefined reference to `GOMP_loop_nonmonotonic_guided_start'
/usr/bin/ld: (.text+0x443): undefined reference to `GOMP_loop_nonmonotonic_guided_next'
/usr/bin/ld: (.text+0x450): undefined reference to `GOMP_loop_end_nowait'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/libGraphicsMagick.a(libGraphicsMagick_la-pixel_iterator.o): in function `PixelIterateTripleImplementation':
(.text+0x506): undefined reference to `omp_get_max_threads'

and obviously the binary is not created.

It is as if the compiler did not find the C code to compile. What can I try next?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街角卖回忆 2025-02-15 19:33:13

我相信问题是,虽然您在静态编译中进行了“ GraphicSmagick”,但libgraphicsmagick.a,您没有静态编译的依赖项,为:

  • op_get_max_threads是来自OpenMP
  • 来自OpenMP XCLOSEDISPLAY我认为来自Xlib
  • 数学功能“ sin”和“ fmod”也来自另一个库

I believe the issue is that while you have 'GraphicsMagick' statically compiled , libGraphicsMagick.a, you do not have its dependencies compiled statically as:

  • omp_get_max_threads is from OpenMP
  • XCloseDisplay I think is from Xlib
  • the math functions 'sin' and 'fmod' are coming from another library as well
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文