Libtool: 存档文件中的对象名称冲突 (NETCDF + MinGW)

7
我将在Windows中使用NetCDF,我认为它必须使用MinGW进行编译,因为我的主程序和所有其他库已经使用MinGW编译。
但是,当我使用MinGW(gcc版本4.6.2)时,我收到了一些错误消息:
    Making all in liblib
    make[2]: Entering directory `/c/Users/ylylyl/Documents/CB/NETCDF/netcdf-4.2.1.1/liblib'
    /bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I..  -I../include  -DDLL_NETCDF   -DDLL_EXPORT   -g -O2 -MT libnetcdf_la-stub.lo -MD -MP -MF .deps/libnetcdf_la-stub.Tpo -c -o libnetcdf_la-stub.lo `test -f 'stub.c' ||echo './'`stub.c
    libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I../include -DDLL_NETCDF -DDLL_EXPORT -g -O2 -MT libnetcdf_la-stub.lo -MD -MP -MF .deps/libnetcdf_la-stub.Tpo -c stub.c  -DDLL_EXPORT -DPIC -o .libs/libnetcdf_la-stub.o
    libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I../include -DDLL_NETCDF -DDLL_EXPORT -g -O2 -MT libnetcdf_la-stub.lo -MD -MP -MF .deps/libnetcdf_la-stub.Tpo -c stub.c -o libnetcdf_la-stub.o >/dev/null 2>&1
    mv -f .deps/libnetcdf_la-stub.Tpo .deps/libnetcdf_la-stub.Plo
    /bin/sh ../libtool --tag=CC   --mode=link gcc  -g -O2 -version-info 9:0:2 -no-undefined -Wl,--output-def,netcdfdll.def  -o libnetcdf.la -rpath /usr/local/lib libnetcdf_la-stub.lo ../libdispatch/libnetcdf2.la ../libdispatch/libdispatch.la ../libsrc/libnetcdf3.la    -lm
    libtool: link: gcc -shared  .libs/libnetcdf_la-stub.o  -Wl,--whole-archive ../libdispatch/.libs/libnetcdf2.a ../libdispatch/.libs/libdispatch.a ../libsrc/.libs/libnetcdf3.a -Wl,--no-whole-archive   -O2 -Wl,--output-def -Wl,netcdfdll.def   -o .libs/libnetcdf-7.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libnetcdf.dll.a
    Creating library file: .libs/libnetcdf.dll.a
    libtool: link: (cd .libs/libnetcdf.lax/libnetcdf2.a && ar x "/c/Users/ylylyl/Documents/CB/NETCDF/netcdf-4.2.1.1/liblib/../libdispatch/.libs/libnetcdf2.a")
    libtool: link: object name conflicts in archive: .libs/libnetcdf.lax/libnetcdf2.a//c/Users/ylylyl/Documents/CB/NETCDF/netcdf-4.2.1.1/liblib/../libdispatch/.libs/libnetcdf2.a
    make[2]: *** [libnetcdf.la] Error 1
    make[2]: Leaving directory `/c/Users/ylylyl/Documents/CB/NETCDF/netcdf-4.2.1.1/liblib'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/c/Users/ylylyl/Documents/CB/NETCDF/netcdf-4.2.1.1'
    make: *** [all] Error 2

我不知道libtool内部问题的具体内容,但我认为ar命令需要更多的输入参数。可能在生成libtool脚本时出了一些问题?
我在网上搜索过,但是找不到带有Fortran和F90接口的MinGW版本NetCDF。请帮帮我。非常感谢。
1个回答

17

救了我的一天,谢谢!给个反馈:在我的情况下,我忘记了Windows PATH中库的路径,并且我在普通cmd上运行msys sh。然后现在我删除了PATH并回到了msys,只需再次进行编译,它就会在出错的地方继续执行。 :) 基本上,大家要仔细检查一下路径。 - questioner
哦,真是太棒了。这解决了问题。 - NiteRain
我在cygwin下遇到了同样的问题。重新排列PATH条目解决了它。 - aroth

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接