如何解决符号的混乱?

时间:2017-08-11 05:52:25

标签: c++ g++

我有一个库Select @sipcount= (SELECT ISNULL(SUM(SIP.[Total]),0) FROM ( SELECT COUNT(1) AS Total FROM [dbo].[MF_tblSundaramSIPDetails] AS [mtfsd] WHERE ISNULL([mtfsd].[TrxnType],'') = 'SYSTEMATIC PURCHASE' AND [mtfsd].[ClientFK] IN (SELECT NewspaperFK FROM dbo.Split(@ClientPK,',') AND EXISTS (SELECT 1 FROM TableName WHERE Column_Value = 'STR') ) UNION ALL SELECT COUNT(1) AS Total FROM [dbo].[MF_tblCamsSIPDetails] AS [mtfsd] WHERE ISNULL([AUT_Trntyp],'') = 'P' AND [mtfsd].[ClientFK] IN (SELECT NewspaperFK FROM dbo.Split(@ClientPK,',') AND EXISTS (SELECT 1 FROM TableName WHERE Column_Value = 'STR')) UNION ALL SELECT COUNT(1) AS Total FROM [dbo].[MF_tblFranklinSIPDetails] AS [mtfsd] WHERE ISNULL([mtfsd].[isSipStp],'') = 'SIP' AND [mtfsd].[ClientFK] IN (SELECT NewspaperFK FROM dbo.Split(@ClientPK,',') AND EXISTS (SELECT 1 FROM TableName WHERE Column_Value = 'STR')) UNION ALL SELECT COUNT(1) AS Total FROM [dbo].[MF_tblKarvySIPDetails] AS [mtfsd] WHERE ISNULL([mtfsd].[TrType],'') = 'SIP' AND [mtfsd].[ClientFK] IN (SELECT NewspaperFK FROM dbo.Split(@ClientPK,',') AND EXISTS (SELECT 1 FROM TableName WHERE Column_Value = 'STR') ) ) AS SIP) ,其中包含libA.so类,我有一个库MyClass,它也有名为libB.so的类。这些类仅用于库中。首先,我的程序会加载MyClass,然后加载libA.so

问题是libB.so使用libB.so中的MyClass,但必须使用自己的libA.so

如何在不重命名或使用命名空间的情况下解决问题?

g ++版本是5.4.0

1 个答案:

答案 0 :(得分:0)

使用动态链接,您可以使用linker version script来限制从库中导出哪些符号。如果您确保所有冲突的符号都是本地的(或隐藏的,因为它们有时被称为),那么冲突就会消失,因为符号完全是库内部的。

无论如何,以这种方式管理符号可见性是一种很好的做法,它也可以减少程序加载时间,因为动态链接器必须处理更少的符号。