gcc 编译TPC-DS工具时出现了许多“多重定义”错误

qxgroojn  于 2023-02-12  发布在  其他
关注(0)|答案(1)|浏览(347)

我尝试编译TPC-DS工具(即用于基准测试数据库的工具),但我看到以下错误:

$ make
gcc -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DYYDEBUG  -DLINUX -g -Wall  -o dsdgen s_brand.o s_customer_address.o s_call_center.o s_catalog.o s_catalog_order.o s_catalog_order_lineitem.o s_catalog_page.o s_catalog_promotional_item.o s_catalog_returns.o s_category.o s_class.o s_company.o s_customer.o s_division.o s_inventory.o s_item.o s_manager.o s_manufacturer.o s_market.o s_pline.o s_product.o s_promotion.o s_purchase.o s_reason.o s_store.o s_store_promotional_item.o s_store_returns.o s_subcategory.o s_subclass.o s_warehouse.o s_web_order.o s_web_order_lineitem.o s_web_page.o s_web_promotinal_item.o s_web_returns.o s_web_site.o s_zip_to_gmt.o w_call_center.o w_catalog_page.o w_catalog_returns.o w_catalog_sales.o w_customer_address.o w_customer.o w_customer_demographics.o w_datetbl.o w_household_demographics.o w_income_band.o w_inventory.o w_item.o w_promotion.o w_reason.o w_ship_mode.o w_store.o w_store_returns.o w_store_sales.o w_timetbl.o w_warehouse.o w_web_page.o w_web_returns.o w_web_sales.o w_web_site.o dbgen_version.o address.o build_support.o date.o decimal.o dist.o driver.o error_msg.o genrand.o join.o list.o load.o misc.o nulls.o parallel.o permute.o pricing.o print.o r_params.o StringBuffer.o tdef_functions.o tdefs.o text.o scd.o scaling.o release.o sparse.o validate.o -lm
/usr/bin/ld: s_purchase.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_purchase.c:55: multiple definition of `nItemIndex'; s_catalog_order.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_catalog_order.c:56: first defined here
/usr/bin/ld: s_web_order.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_web_order.c:56: multiple definition of `nItemIndex'; s_catalog_order.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_catalog_order.c:56: first defined here
/usr/bin/ld: s_web_order_lineitem.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_web_order_lineitem.c:54: multiple definition of `g_s_web_order_lineitem'; s_web_order.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_web_order.c:54: first defined here
/usr/bin/ld: w_catalog_page.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/w_catalog_page.c:52: multiple definition of `g_w_catalog_page'; s_catalog_page.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_catalog_page.c:51: first defined here
/usr/bin/ld: w_warehouse.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/w_warehouse.c:53: multiple definition of `g_w_warehouse'; s_warehouse.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_warehouse.c:51: first defined here
/usr/bin/ld: w_web_site.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/w_web_site.c:59: multiple definition of `g_w_web_site'; s_web_site.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_web_site.c:51: first defined here
collect2: error: ld returned 1 exit status
make: *** [makefile:233: dsdgen] Error 1

在四处搜索之后,我发现旧的GCC版本可以容忍这个错误,并且使用-fcommong GCC选项应该可以容忍重复声明,但它没有:

$ make
gcc -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DYYDEBUG  -DLINUX -g -Wall -fcommon  -o dsdgen s_brand.o s_customer_address.o s_call_center.o s_catalog.o s_catalog_order.o s_catalog_order_lineitem.o s_catalog_page.o s_catalog_promotional_item.o s_catalog_returns.o s_category.o s_class.o s_company.o s_customer.o s_division.o s_inventory.o s_item.o s_manager.o s_manufacturer.o s_market.o s_pline.o s_product.o s_promotion.o s_purchase.o s_reason.o s_store.o s_store_promotional_item.o s_store_returns.o s_subcategory.o s_subclass.o s_warehouse.o s_web_order.o s_web_order_lineitem.o s_web_page.o s_web_promotinal_item.o s_web_returns.o s_web_site.o s_zip_to_gmt.o w_call_center.o w_catalog_page.o w_catalog_returns.o w_catalog_sales.o w_customer_address.o w_customer.o w_customer_demographics.o w_datetbl.o w_household_demographics.o w_income_band.o w_inventory.o w_item.o w_promotion.o w_reason.o w_ship_mode.o w_store.o w_store_returns.o w_store_sales.o w_timetbl.o w_warehouse.o w_web_page.o w_web_returns.o w_web_sales.o w_web_site.o dbgen_version.o address.o build_support.o date.o decimal.o dist.o driver.o error_msg.o genrand.o join.o list.o load.o misc.o nulls.o parallel.o permute.o pricing.o print.o r_params.o StringBuffer.o tdef_functions.o tdefs.o text.o scd.o scaling.o release.o sparse.o validate.o -lm
/usr/bin/ld: s_purchase.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_purchase.c:55: multiple definition of `nItemIndex'; s_catalog_order.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_catalog_order.c:56: first defined here
/usr/bin/ld: s_web_order.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_web_order.c:56: multiple definition of `nItemIndex'; s_catalog_order.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_catalog_order.c:56: first defined here
/usr/bin/ld: s_web_order_lineitem.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_web_order_lineitem.c:54: multiple definition of `g_s_web_order_lineitem'; s_web_order.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_web_order.c:54: first defined here
/usr/bin/ld: w_catalog_page.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/w_catalog_page.c:52: multiple definition of `g_w_catalog_page'; s_catalog_page.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_catalog_page.c:51: first defined here
/usr/bin/ld: w_warehouse.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/w_warehouse.c:53: multiple definition of `g_w_warehouse'; s_warehouse.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_warehouse.c:51: first defined here
/usr/bin/ld: w_web_site.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/w_web_site.c:59: multiple definition of `g_w_web_site'; s_web_site.o:/home/mgelbana/workspace/tools/TPC/TPC-DS/DSGen-software-code-3.2.0rc1/tools/s_web_site.c:51: first defined here
collect2: error: ld returned 1 exit status
make: *** [makefile:233: dsdgen] Error 1

我不能修改这个工具,它的文档也没有说明我应该使用哪个GCC版本来编译它。
我的GCC版本是:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.3.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-xKiWfi/gcc-11-11.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-xKiWfi/gcc-11-11.3.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)

那么有没有办法配置我的GCC来容忍这个声明问题呢?或者至少配置它作为自己的一个旧版本(兼容模式?),这样我就可以尝试不同的版本,直到一个工作?

waxmsbnn

waxmsbnn1#

解决方案是清理一下并使用GCC v9:

make clean
make CC=gcc-9

或者你可以把操作系统相关的CC变量设置为等价的GCC v9命令。在我的例子中,当我使用Linux时,变量的结果如下:

LINUX_CC = gcc-9

相关问题