gpt4 book ai didi

c++ - 在 Linux 上将 GraphicsMagick++ 与 clang libc++ 链接起来

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:36:26 25 4
gpt4 key购买 nike

我正在尝试在 Ubuntu 12.04 x64 上编译应用程序。它基于带有 clang 3.2 的 osx 构建,使用新的 c++11 标准并且依赖于 boost 和 GraphicsMagick++ 并且运行良好。使用 gcc 4.8.1 编译会导致编译器崩溃。不幸的是,我们必须尽快发布软件,不能等待 gcc 修复错误。

在 linux 上使用 clang 进行了一些试验和错误并阅读了一些邮件列表后,我根据这篇文章 https://plus.google.com/u/0/+DeWittClinton/posts/Vr7y8TPsKgR 进行了管理。用 clang 3.3 和 libc++(和 libc++abi)编译它。所有与提升相关的单元测试(仅 header 和共享对象库)执行良好。在我们开始链接到 GraphicsMagick++ 后,它会导致下面的 undefined reference 错误。

"/usr/bin/ld" -export-dynamic -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o ../test_xxx_import /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/local/lib/ -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -L/lib -L/usr/lib -lc++ -lc++abi CMakeFiles/test_xxx_import.dir/xxx_http_binding_test.cpp.o CMakeFiles/test_xxx_import.dir/resource_test.cpp.o CMakeFiles/test_xxx_import.dir/slugify_test.cpp.o CMakeFiles/test_xxx_import.dir/product_test.cpp.o CMakeFiles/test_xxx_import.dir/field_semantic_test.cpp.o CMakeFiles/test_xxx_import.dir/files.index-parser_test.cpp.o CMakeFiles/test_xxx_import.dir/thread_pool_test.cpp.o CMakeFiles/test_xxx_import.dir/container_sink_test.cpp.o CMakeFiles/test_xxx_import.dir/factories_test.cpp.o CMakeFiles/test_xxx_import.dir/thread_safe_queue_test.cpp.o CMakeFiles/test_xxx_import.dir/container_device_test.cpp.o CMakeFiles/test_xxx_import.dir/product_catalog_test.cpp.o CMakeFiles/test_xxx_import.dir/config_object_test.cpp.o CMakeFiles/test_xxx_import.dir/sha1_test.cpp.o CMakeFiles/test_xxx_import.dir/resize_test.cpp.o CMakeFiles/test_xxx_import.dir/redis_connection_test.cpp.o CMakeFiles/test_xxx_import.dir/redis_util_test.cpp.o CMakeFiles/test_xxx_import.dir/redis_product_test.cpp.o CMakeFiles/test_xxx_import.dir/redis_string_util_test.cpp.o CMakeFiles/test_xxx_import.dir/redis_task_queue_test.cpp.o CMakeFiles/test_xxx_import.dir/stream_manipulator_test.cpp.o CMakeFiles/test_xxx_import.dir/category_info_test.cpp.o CMakeFiles/test_xxx_import.dir/localized_string_test.cpp.o CMakeFiles/test_xxx_import.dir/product_description_test.cpp.o CMakeFiles/test_xxx_import.dir/product_picture_test.cpp.o CMakeFiles/test_xxx_import.dir/product_relation_test.cpp.o CMakeFiles/test_xxx_import.dir/supplier_test.cpp.o CMakeFiles/test_xxx_import.dir/summary_description_test.cpp.o CMakeFiles/test_xxx_import.dir/summary_descriptions_test.cpp.o CMakeFiles/test_xxx_import.dir/stage_base_test.cpp.o CMakeFiles/test_xxx_import.dir/thread_reclaimer_test.cpp.o CMakeFiles/test_xxx_import.dir/product_sheet_download_test.cpp.o CMakeFiles/test_xxx_import.dir/image_scaling_test.cpp.o CMakeFiles/test_xxx_import.dir/image_download_test.cpp.o CMakeFiles/test_xxx_import.dir/product_data_sheet_parser_test.cpp.o ../libxxx_import.a /usr/local/lib/libboost_unit_test_framework.a /usr/local/lib/libboost_thread.a /usr/local/lib/libboost_date_time.a /usr/local/lib/libGraphicsMagick++.a /usr/local/lib/libboost_filesystem.a /usr/local/lib/libboost_system.a /usr/local/lib/libboost_exception.a /usr/local/lib/libboost_chrono.a /usr/local/lib/libboost_log.a /usr/local/lib/libPocoNet.so /usr/local/lib/libPocoFoundation.so /usr/local/lib/libPocoNetSSL.so /usr/local/lib/libPocoUtil.so -Bstatic -lexpat -lhiredis -Bdynamic /usr/local/lib/libboost_date_time.a /usr/local/lib/libGraphicsMagick++.a -rpath /usr/local/lib -lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
/usr/local/lib/libGraphicsMagick++.a(Image.o): In function `Magick::Image::signature(bool) const':
/home/xxx_import/temp/GraphicsMagick-1.3.18/Magick++/lib/Image.cpp:3271: undefined reference to `GetImageAttribute'
/home/xxx_import/temp/GraphicsMagick-1.3.18/Magick++/lib/Image.cpp:3274: undefined reference to `SignatureImage'
/home/xxx_import/temp/GraphicsMagick-1.3.18/Magick++/lib/Image.cpp:3278: undefined reference to `GetImageAttribute'
/usr/local/lib/libGraphicsMagick++.a(Image.o): In function `Magick::Image::read(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)':

GraphicsMagick-1.3.18 配置了以下调用:

CC=clang CXX=clang++ ./configure --with-jbig=yes --with-png=yes --with-jpeg=yes --enable-shared=yes CXXFLAGS="-O2 -g -stdlib=libc++  -isystem /usr/local/include/c++/v1/" LDFLAGS="-stdlib=libc++ -L/usr/local/lib/ -R/usr/local/lib/" LIBS="-lc++ -lc++abi"

然后构建和安装。

手动查找符号发现未定义:

nm /usr/local/lib/libGraphicsMagick++.a | grep GetImageAttribute
U GetImageAttribute

属性位于/usr/local/lib/libGraphicsMagick.a 中。

我的 ldd 输出如下:

ldd /usr/local/lib/libGraphicsMagick++.so
linux-vdso.so.1 => (0x00007fff78592000)
libGraphicsMagick.so.3 => /usr/local/lib/libGraphicsMagick.so.3 (0x00007fd0b0309000)
libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007fd0b00b0000)
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007fd0afe87000)
libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007fd0afc77000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd0afa60000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd0af842000)
libc++abi.so.1 => /usr/local/lib/libc++abi.so.1 (0x00007fd0af5f5000)
libc++.so.1 => /usr/local/lib/libc++.so.1 (0x00007fd0af351000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd0af054000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd0aec95000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd0aea7f000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd0b09c3000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd0ae876000)

它链接来自 gcc 工具链的一些 C 库。我也应该用 clang 构建它们吗?非常欢迎任何建议。

最佳答案

您是否还明确链接了 GraphicsMagick++ 的依赖项?我认为,如果您将 GraphicsMagick++ 的所有依赖项枚举为生成的可执行文件的依赖项,那么这可能会解决您的问题,因此还要链接这些库:

-lGraphicsMagick -ljpeg -lpng12 -lbz2 -lz

然后看看您的链接错误是更少还是没有。

关于c++ - 在 Linux 上将 GraphicsMagick++ 与 clang libc++ 链接起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17573759/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com