5

我将承担将相当大的 C++ 网络应用程序代码库从 Solaris 移植到 Linux 平台的任务。该代码还使用 ACE 等第三方库。最初编写的应用程序没有计划在将来进行可能的移植。

我想就如何完成这项任务获得一些建议和建议。最好的方法是什么。

-帕布。小号

4

4 回答 4

7

ACE 是一个优势,因为它是多平台的。您必须检查字体大小的使用位置和方式。如果使用了 ACE_* 基本类型,那么您会遇到连胜,因为它们是可移植的,否则我将首先将 Solaris 版本更改为使用多平台数据类型和元素(使用 ACE 工具,因为您已经有了它)。

如果您使用任何 Solaris 唯一的外部库,则必须在 linux 中找到一个等效的库并编写一个包装器,以便应用程序的其余部分不需要知道正在使用什么实现。

之后,只需一个代码库就可以直接迁移到 linux。您应该完全编译和测试它。

于 2008-12-17T11:49:47.227 回答
6

“没有可移植的应用程序,只有被移植的应用程序”

如果可以的话,首先在两个平台上使用相同的工具。IE 如果 Solaris 版本没有更改为使用 GCC 和 GNU make 等,我建议您先更改它并让 Solaris 构建工作。您会发现您将首先修复编译器问题,而不是在尝试移植应用程序的同时尝试在 Linux 上修复它们。

其次,确保您可以在每个平台上以相同的版本获得所有相同的库。我认为您可以获得适用于 Linux 的 ACE。确保该版本的库可以在 Solaris 上运行。这将限制兼容性问题。

一旦你做到了,那么真正的工作就开始了。

You will need to compile each source file one at a time and find the functions that are not available in Linux. First look for a replacement that is available in both OSs. If there is no simple replacement then create two libraries one for Solaris and one for Linux. Create wrapper classes or functions to abstract the incompatibilities away.

If this sounds like a lot of work - it is.

于 2008-12-17T11:53:51.180 回答
2

I'm in agreement with what David Allan Finch wrote. Take the port one step at a time. In addition:

Are you coming from Solaris/SPARC or Solaris x86? If it's x86, you'll have no endian issues, but if it's SPARC, you'll need to examine your code to make sure that there are no byte-order (endian) issues.

Is the Solaris code 32-bit or 64-bit? Certainly keep the address space the same initially.

于 2008-12-24T17:44:43.133 回答
1

列出您当前的外部依赖项是什么。找出在 Linux 上可用的这些。对于那些不是,你必须找到一个替代品。如果对这些外部依赖项的引用没有在函数或对象后面抽象出来,请重构代码,使其如此。然后替换依赖关系,这样就可以用替换实现抽象函数。

于 2008-12-17T11:51:50.483 回答