Mono / Ubuntu - 冲突的定义
Posted
技术标签:
【中文标题】Mono / Ubuntu - 冲突的定义【英文标题】:Mono / Ubuntu - Conflicting definitions 【发布时间】:2011-12-02 03:12:20 【问题描述】:我正在尝试在 Ubuntu 上构建一个库 (Medsphere.Widgets),但它给我一个错误。我已经进行了很好的搜索,但似乎没有人对此有答案。配置脚本工作正常,完成时没有警告或错误。当我去运行 make 时,它会这样做:
polynomial@ubuntu:~/Projects/Medsphere/$ make
Making all in src
make[1]: Entering directory `/home/polynomial/Projects/Medsphere/src'
/usr/bin/mcs /target:library /out:Medsphere.Widgets.dll -r:/usr/lib/pkgconfig/../../lib/cli/pango-sharp-2.0/pango-sharp.dll -r:/usr/lib/pkgconfig/../../lib/cli/atk-sharp-2.0/atk-sharp.dll -r:/usr/lib/pkgconfig/../../lib/cli/gdk-sharp-2.0/gdk-sharp.dll -r:/usr/lib/pkgconfig/../../lib/cli/gtk-sharp-2.0/gtk-sharp.dll -r:/usr/lib/pkgconfig/../../lib/cli/glib-sharp-2.0/glib-sharp.dll -r:/usr/lib/mono/2.0/Mono.Cairo.dll ./CPaned.cs ./FBox.cs ./GridView.cs ./CairoHelper.cs ./IconLayout.cs ./ICairoCellRenderer.cs ./BoxCellRenderer.cs ./PixbufCellRenderer.cs ./TextCellRenderer.cs ./graph/AxisLocation.cs ./graph/AxisSizeGroup.cs ./graph/BaseTreeModelPlot.cs ./graph/DateTimeAxis.cs ./graph/EventPlot.cs ./graph/Graph2D.cs ./graph/Graph.cs ./graph/GtkStyleProvider.cs ./graph/HistogramPlot.cs ./graph/IAxis.cs ./graph/IPlot.cs ./graph/IStyleProvider.cs ./graph/ITreeModelPlot.cs ./graph/LabelAxis.cs ./graph/Legend.cs ./graph/LinearAxis.cs ./graph/LinePlot.cs ./graph/LinkedLinePlot.cs ./graph/PlotColor.cs ./graph/PointShape.cs ./graph/ReferenceRangePlot.cs
./IconLayout.cs(414,25): error CS0029: Cannot implicitly convert type `Cairo.Context' to `Cairo.Context'
./IconLayout.cs(414,25): The type `Cairo.Context' has two conflicting definitions, one comes from `Mono.Cairo, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' and the other from `Mono.Cairo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' (in the previous error)
Internal(1,1): The type `Cairo.Context' has two conflicting definitions, one comes from `Mono.Cairo, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' and the other from `Mono.Cairo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' (in the previous error)
./IconLayout.cs(920,41): error CS1502: The best overloaded method match for `Gdk.CairoHelper.SetSourceColor(Cairo.Context, Gdk.Color)' has some invalid arguments
/usr/lib/cli/gdk-sharp-2.0/gdk-sharp.dll (Location of the symbol related to previous error)
./IconLayout.cs(920,41): error CS1503: Argument `#1' cannot convert `Cairo.Context' expression to type `Cairo.Context'
./IconLayout.cs(920,41): (equally named types possibly from different assemblies in previous error)
/usr/lib/mono/gac/Mono.Cairo/2.0.0.0__0738eb9f132ed756/Mono.Cairo.dll (Location of the symbol related to previous error)
/usr/lib/mono/gac/Mono.Cairo/1.0.5000.0__0738eb9f132ed756/Mono.Cairo.dll (Location of the symbol related to previous error)
Compilation failed: 3 error(s), 0 warnings
我只能想象两个版本的 Cairo 存在冲突,但我不知道如何解决它。有什么想法吗?
【问题讨论】:
嗯,看起来很奇怪。全局程序集缓存应该意识到它们对于不同版本的 CLR 是同一个库并选择一个。 对不起,我的意思是mcs
。不知道为什么我用gcc
标记它。重新标记适当。
我尝试用/usr/lib/mono/gac/Mono.Cairo/2.0.0.0__0738eb9f132ed756/Mono.Cairo.dll
替换/usr/lib/mono/Mono.Cairo.dll
的所有实例,但这并没有解决问题。
这个东西应该使用编译器的-pkg选项,mono编译器一般会忽略GAC btw。
设法自己修复了它。我修改了config.status
以使用gmcs
并修补了所有Mono.Cairo 引用,以便它们指向特定于版本的DLL。修补了 lib 中的几个演员表错误后,效果很好!
【参考方案1】:
只是为了清除这个:
我修改了 config.status 以使用 gmcs
而不仅仅是 mcs
并修补了所有 Mono.Cairo
引用,以便它们指向特定于版本的 DLL,而不是 GAC 中的通用 DLL。在修复了库中的几个演员错误后,它工作得很好!
【讨论】:
以上是关于Mono / Ubuntu - 冲突的定义的主要内容,如果未能解决你的问题,请参考以下文章
G006-OS-LIN-UBUN-02 Ubuntu Server 22.04 安装