Linker 需要静态链接时的MinGw32兼容问题(ADOL-C链接ColPack)

Linker 需要静态链接时的MinGw32兼容问题(ADOL-C链接ColPack),linker,mingw,Linker,Mingw,我有一个数学库()需要链接到另一个库()以执行一些可选任务 我可以在Linux中很好地编译它们,在windows中单独编译ADOl-C或ColPack,但是当我尝试在windows(MinGW 32,ld 2.22)中使用ColPack编译ADOl-C时,我有以下问题: $ make Making all in ADOL-C make[1]: Entering directory `/c/tests/ADOL-C-2.3.0/ADOL-C' [...] CC int_reverse_

我有一个数学库()需要链接到另一个库()以执行一些可选任务

我可以在Linux中很好地编译它们,在windows中单独编译ADOl-C或ColPack,但是当我尝试在windows(MinGW 32,ld 2.22)中使用ColPack编译ADOl-C时,我有以下问题:

$ make
Making all in ADOL-C
make[1]: Entering directory `/c/tests/ADOL-C-2.3.0/ADOL-C'
[...]
  CC     int_reverse_s.lo
  CC     int_reverse_t.lo
  CXXLD  libadolc.la

*** Warning: This system can not link to static lib archive /usr/lib/libColPack.
la.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.
Creating library file: .libs/libadolc.dll.a
sparse/.libs/libsparse.a(sparsedrivers.o): In function `generate_seed_jac':
c:\tests\ADOL-C-2.3.0\ADOL-C\src\sparse/sparsedrivers.cpp:119: undefined referen
ce to `ColPack::BipartiteGraphPartialColoringInterface::BipartiteGraphPartialCol
oringInterface(int, ...)'

[...]
collect2: ld returned 1 exit status
make[5]: *** [libadolc.la] Error 1
make[5]: Leaving directory `/c/tests/ADOL-C-2.3.0/ADOL-C/src'
make[4]: *** [all-recursive] Error 1
我不能像在MinGW中那样提供动态库,即使我用--enable shared配置ColPack,我从它的编译中实际上从未得到任何共享库,只有libColPack[a | la | lai]和ColPack.exe


有什么提示吗?

我花了一点时间才解决问题

下载Colpack-1.0.8.tar.gz并在以下环境中对其进行测试

Msys/mingw 4.7.0

正如您所说,您不能使用它来创建共享库。 一段时间后,我找到了一个更复杂的解决方案。从这个基础上,我找到了一个更短的方法

简短解决方案:

打开配置

行#uuuuuuuuuuuuuuuuuuuuuuuuuuuuuu更改为__

7660        enable_dlopen=no      set it to yes
7663        enable_win32_dll=no   set it to yes
7673        enable_shared=no      set it to yes
7710        enable_static=yes     set it to no
7717        enable_static=yes     set it to no  
8721        enable_shared_with_static_runtimes=no      set it to yes
11797       enable_shared_with_static_runtimes_CXX=no  set it to yes
5547        allow_undefined=yes   set it to no
5550        allow_undefined=yes   set it to no
保存并运行

./configure --disable-static --enable-shared
make clean
make
打开libtool

行#uuuuuuuuuuuuuuuuuuuuuuuuuuuuuu更改为__

7660        enable_dlopen=no      set it to yes
7663        enable_win32_dll=no   set it to yes
7673        enable_shared=no      set it to yes
7710        enable_static=yes     set it to no
7717        enable_static=yes     set it to no  
8721        enable_shared_with_static_runtimes=no      set it to yes
11797       enable_shared_with_static_runtimes_CXX=no  set it to yes
5547        allow_undefined=yes   set it to no
5550        allow_undefined=yes   set it to no
保存并运行

./configure --disable-static --enable-shared
make clean
make
.lib目录中现在应该有以下文件

ColPack.exe      .. 30.08.2012
libColPack.la    .. 30.08.2012
libColPack.lai   .. 30.08.2012
libColPack-0.dll .. 30.08.2012
libColPack.dll.a .. 30.08.2012
从libColPack-0.dll导出

Export Table:
  Name:                          libColPack-0.dll
  Time Date Stamp:               0x503F3A43 (30.08.2012 11:02:43)
  Version:                       0.00
  Ordinal Base:                  1
  Number of Functions:           883
  Number of Names:               883

  Ordinal   Entry Point   Name
        1   0x000012FC    _Z10createArgsiPPKcRSt6vectorISsSaISsEE
        2   0x00011034    _Z10toFileBiPCSsSsSt6vectorISsSaISsEES1_St3mapISsbSt4lessISsESaISt4pairIKSsbEEE
        3   0x00001FB0    _Z11mm_is_validPc
        ........
从libColPack.la的支出

# libColPack.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4 
#
# Please DO NOT delete this file!
# It is necessary for linking the library.

# The name that we can dlopen(3).
dlname='libColPack-0.dll'

# Names of this library.
library_names='libColPack.dll.a'

......
# libColPack.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4 
#
# Please DO NOT delete this file!
# It is necessary for linking the library.

# The name that we can dlopen(3).
dlname='libColPack-0.dll'

# Names of this library.
library_names='libColPack.dll.a'

....

# The name of the static archive.
old_library='libColPack.a'
....
希望有帮助

注意:

没有测试过“make-install”

既有静态的,也有动态的:

将libColPack.la、libColPack.lai和libColPack.dll.a移动到另一个文件夹。我们需要它们,它们将被覆盖。删除文件libColPack.la,一个更高的目录级别

将libtool文件更改回其原始状态(两行)

运行“make”

你将有一个新的libColPack

将libColPack.dll.a移回.libs

将先前移动的两个文件的内容与新的libColPack.la(.lai)合并

将更新后的libColPack.la复制到更高的目录级别

新的混合文件:libColPack.la

# libColPack.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4 
#
# Please DO NOT delete this file!
# It is necessary for linking the library.

# The name that we can dlopen(3).
dlname='libColPack-0.dll'

# Names of this library.
library_names='libColPack.dll.a'

......
# libColPack.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4 
#
# Please DO NOT delete this file!
# It is necessary for linking the library.

# The name that we can dlopen(3).
dlname='libColPack-0.dll'

# Names of this library.
library_names='libColPack.dll.a'

....

# The name of the static archive.
old_library='libColPack.a'
....

有了这个技巧,您就有了静态和动态libs

谢谢您,已经过测试并且可以工作了。ADOL-C包与ColPack动态链接。这意味着libColPacl-0.dll也必须对最终应用程序可用。一种具体情况下的工作方案是使用ADOL-C 2.2.1的配置。它们能够静态链接ColPAck 1.0.8。一个问题:是否有可能将其自动化,以便最终用户不需要使用libtool和configure,仅在mingw中应用此行为,并且仅在实际请求共享库时应用此行为?很高兴提供帮助。看看我的答案:“既要有静态的,也要有动态的: