BUILDING 64位版本的二进制文件有什么大不了的?

时间:2021-07-23 05:29:17

There are a ton of drivers & famous applications that are not available in 64-bit. Adobe for instance does not provider a 64-bit Flash player plugin for Internet Explorer. And because of that, even though I am running 64-bit Vista, I have to run 32-bit IE. Microsoft Office, Visual Studio also don't ship in 64-bit AFAIK.

有大量的驱动程序和着名的应用程序没有64位。例如,Adobe没有为Internet Explorer提供64位Flash播放器插件。正因为如此,即使我运行的是64位Vista,我也必须运行32位IE。 Microsoft Office,Visual Studio也不提供64位AFAIK。

Now personally, I haven't had much problems building my applications in 64-bit. I just have to remember a few rules of thumb, e.g. always use SIZE_T instead of UINT32 for string lengths etc.

现在个人而言,我在使用64位构建应用程序时没有遇到太多问题。我只需记住一些经验法则,例如:对于字符串长度等,总是使用SIZE_T而不是UINT32。

So my question is, what is preventing people from building for 64-bit?

所以我的问题是,是什么阻止了人们为64位构建?

8 个解决方案

#1


16  

If you are starting from scratch, 64-bit programming is not that hard. However, all the programs you mention are not new.

如果从头开始,64位编程就不那么难了。但是,您提到的所有程序都不是新的。

It's a whole lot easier to build a 64-bit application from scratch, rather than port it from an existing code base. There are many gotchas when porting, especially when you get into applications where some level of optimization has been done. Programmers use lots of little assumptions to gain speed, and these are not always easy to quickly port to 64-bit. A few examples I've had to deal with:

从头开始构建64位应用程序要容易得多,而不是从现有的代码库中移植它。移植时有很多问题,尤其是当您进入已经完成某种程度优化的应用程序时。程序员使用许多小的假设来获得速度,并且这些并不总是很容易快速移植到64位。我必须处理的几个例子:

  • Proper alignment of elements within a struct. As data sizes change, assumptions that certain fields in a struct will be aligned on an optimal memory boundary may fail
  • 正确对齐结构中的元素。随着数据大小的改变,假设结构中的某些字段将在最佳内存边界上对齐可能会失败

  • Length of long integers change, so if you pass values over a socket to another program that may not be 64-bit, you need to refactor your code
  • 长整数的长度会发生变化,因此如果将套接字上的值传递给另一个可能不是64位的程序,则需要重构代码

  • Pointer lengths change, as so hard to decipher code written be a guru that has left the company become a little trickier to debug
  • 指针长度发生变化,因为编写的代码难以破解,导致公司调试变得有点棘手

  • Underlying libraries will also need to have 64-bit support to properly link. This is a large part of the problem of porting code if you rely on any libraries that are not open source
  • 底层库还需要64位支持才能正确链接。如果您依赖任何非开源的库,这是移植代码问题的很大一部分

#2


5  

In addition to the things in @jvasak's post, the major thing that can causes bugs:

除了@jvasak帖子中的内容之外,还有可能导致错误的主要因素:

  • pointers are larger than ints - a huge amount of code makes the assumption that the sizes are the same.
  • 指针大于整数 - 大量的代码假设大小相同。

Remember that Windows will not even allow an application (whether 32-bit or 64-bit) to handle pointers that have an address above 0x7FFFFFFF (2GB or above) unless they have been specially marked as "LARGE_ADDRESS_AWARE" because so many applications will treat the pointer as a negative value at some point and fall over.

请记住,Windows甚至不允许应用程序(无论是32位还是64位)处理地址大于0x7FFFFFFF(2GB或更高)的指针,除非它们被特别标记为“LARGE_ADDRESS_AWARE”,因为许多应用程序会将指针在某个时刻作为负值并且摔倒。

#3


5  

The biggest issues that I've run into porting our C/C++ code to 64 bit is support from 3rd party libraries. E.g. there is currently only 32 bit versions of the Lotus Notes API and also MAPI so you can't even link against them.

我将C / C ++代码移植到64位的最大问题是来自第三方库的支持。例如。目前只有32位版本的Lotus Notes API以及MAPI,因此您甚至无法链接它们。

Also since you can't load a 32 bit DLL into your 64 bit process you get burnt again trying to load things dynamically. We ran into this problem again trying to support Microsoft Access under 64 bit. From wikipedia:

此外,由于您无法将64位DLL加载到64位进程中,因此再次尝试动态加载内容。我们再次尝试在64位下支持Microsoft Access遇到此问题。来自*:

The Jet Database Engine will remain 32-bit for the foreseeable future. Microsoft has no plans to natively support Jet under 64-bit versions of Windows

在可预见的未来,Jet数据库引擎将保持32位。微软没有计划在64位版本的Windows下原生支持Jet

#4


3  

Just a guess, but I would think a large part of it would be support - If Adobe compiles the 64 bit version, they have to support it. Even though it may be a simple compile switch, they'd still have to run through a lot of testing, etc, followed by training their support staff to respond correctly, when they do run into issues fixing them either results in a new version of the 32 bit binary or a branch in the code, etc. So while it seems simple, for a large application it can still end up costing a lot.

只是一个猜测,但我认为其中很大一部分将是支持 - 如果Adobe编译64位版本,他们必须支持它。即使它可能是一个简单的编译开关,他们仍然需要经过大量的测试等,然后训练他们的支持人员正确响应,当他们遇到问题修复它们或者导致新版本的32位二进制或代码中的分支等。因此,虽然它看起来很简单,但对于大型应用程序来说,它仍然会花费很多。

#5


3  

Another reason that a lot of companies have not gone through the effort of creating 64 bit versions is simply they don't need to.

许多公司没有完成创建64位版本的努力的另一个原因是他们不需要。

Windows has WoW64 (Windows on Windows 64 bit) and Linux can have the 32 bit libraries available alongside the 64 bit. Both of these allow us to run 32 bit applications in 64 bit environments.

Windows具有WoW64(Windows 64位上的Windows),Linux可以在64位下提供32位库。这两者都允许我们在64位环境中运行32位应用程序。

As long as the software is able to run in this way, there is not a major incentive to convert to 64 bit.

只要软件能够以这种方式运行,就没有转换为64位的主要动机。

Exceptions to this are things such as device drivers as they are tied in deeper with the operating systems and cannot run in the 32 bit layer that the x86-64/AMD64 based 64-bit operating systems offer (IA64 is unable to do this from what I understand).

例外情况是设备驱动程序,因为它们与操作系统的关系更深,并且无法在基于x86-64 / AMD64的64位操作系统提供的32位层中运行(IA64无法通过我明白)。

I agree with you on flash player though, I am very disappointed in Adobe that they have not updated this product. As you have pointed out, it does not work properly in 64 bit requiring you to run the 32 bit version of Internet Explorer.

我同意你对Flash播放器的看法,我对Adobe非常失望,他们没有更新这个产品。正如您所指出的,它在64位中无法正常运行,需要您运行32位版本的Internet Explorer。

I think it is a strategic mistake on Adobe's part. Having to run the 32 bit browser for flash player is an inconvenience for users, and many will not understand this solution. This could lead to developers being apprehensive about using flash. The most important thing for a web site is to make sure everyone can view it, solutions that alienate users are typically not popular ones. Flash's popularity was fed by its own popularity, the more sites that used it, the more users had it on their systems, the more users that had it on their systems, the more sites were willing to use it.

我认为这是Adobe的一个战略性错误。必须为闪存播放器运行32位浏览器对用户来说是一个不便,许多人不会理解这个解决方案。这可能会导致开发人员对使用闪存感到担心。对于网站来说,最重要的是确保每个人都可以查看它,疏远用户的解决方案通常不受欢迎。 Flash的受欢迎程度取决于它自己的受欢迎程度,使用它的站点越多,用户在系统上拥有的用户越多,在系统上拥有它的用户就越多,站点就越愿意使用它。

The retail market pushes these things forward, when a general consumer goes to buy a new computer, they aren't going to know they don't need a 64 bit OS they are going to get it either because they hear it is the latest and greatest thing, the future of computing, or just because they don't know the difference.

零售市场将这些事情推向前进,当普通消费者购买新电脑时,他们不会知道他们不需要64位操作系统他们会得到它,因为他们听到它是最新的和最伟大的事情,计算的未来,或仅仅因为他们不知道差异。

Vista has been out for about 2 years now, and Windows XP 64-bit was out before that. In my mind that is too long for a major technology such as Flash to not be upgraded if they want to hold on to their market. It may have to do with Adobe taking over Macromedia and this is a sign that Adobe does not feel Flash is part of their future, I find it hard to believe as I think Flash and Dreamweaver were the top parts of what they got out of Macromedia, but then why have they not updated it yet?

Vista已经推出了大约2年,之前Windows XP 64位已经推出。在我看来,如果他们想要坚持他们的市场,那么像Flash这样的主要技术就不会升级太久了。它可能与Adobe接管Macromedia有关,这表明Adobe并不认为Flash是他们未来的一部分,我觉得很难相信,因为我认为Flash和Dreamweaver是他们从Macromedia获得的最重要的部分,但为什么他们还没有更新呢?

#6


2  

It is not as simple as just flipping a switch on your compiler. At least, not if you want to do it right. The most obvious example is that you need to declare all your pointers using 64-bit datatypes. If you have any code which makes assumptions about the size of these pointers (e.g. a datatype which allocates 4 bytes of memory per pointer), you'll need to change it. All this needs to have been done in any libraries you use, too. Further, if you miss just a few then you'll end up with pointers being down-casted and at the wrong location. Pointers are not the only sticky point but are certainly the most obvious.

它并不像在编译器上翻转开关那么简单。至少,如果你想做得对,那就不行了。最明显的例子是您需要使用64位数据类型声明所有指针。如果您有任何代码可以对这些指针的大小进行假设(例如,每个指针分配4个字节内存的数据类型),则需要更改它。所有这些都需要在您使用的任何库中完成。此外,如果你错过了一些,那么你最终会得到指针下降和错误的位置。指针不是唯一的粘性点,但肯定是最明显的。

#7


1  

Primarily a support and QA issue. The engineering work to build for 64-bit is fairly trivial for most code, but the testing effort, and the support cost, don't scale down the same way.

主要是支持和质量保证问题。对于大多数代码而言,为64位构建的工程工作相当简单,但是测试工作和支持成本不会以相同的方式缩小。

On the testing side, you'll still have to run all the same tests, even though you "know" they should pass.

在测试方面,你仍然必须运行所有相同的测试,即使你“知道”它们应该通过。

For a lot of applications, converting to a 64-bit memory model doesn't actually give any benefit (since they never need more than a few GB of RAM), and can actually make things slower, due to the larger pointer size (makes every object field twice as large).

对于很多应用程序来说,转换为64位内存模型实际上并没有带来任何好处(因为它们从不需要超过几GB的RAM),并且由于指针大小较大(实际上可能会使速度变慢)每个对象字段的两倍大)。

Add to that the lack of demand (due to the chicken/egg problem), and you can see why it wouldn't be worth it for most developers.

再加上缺乏需求(由于鸡/蛋问题),你可以看出为什么对大多数开发者来说它不值得。

#8


0  

Their Linux/Flash blog goes some way to explain why there isn't a 64bit Flash Player as yet. Some is Linux-specific, some is not.

他们的Linux / Flash博客在某种程度上解释了为什么还没有64位Flash Player。有些是特定于Linux的,有些则不是。

#1


16  

If you are starting from scratch, 64-bit programming is not that hard. However, all the programs you mention are not new.

如果从头开始,64位编程就不那么难了。但是,您提到的所有程序都不是新的。

It's a whole lot easier to build a 64-bit application from scratch, rather than port it from an existing code base. There are many gotchas when porting, especially when you get into applications where some level of optimization has been done. Programmers use lots of little assumptions to gain speed, and these are not always easy to quickly port to 64-bit. A few examples I've had to deal with:

从头开始构建64位应用程序要容易得多,而不是从现有的代码库中移植它。移植时有很多问题,尤其是当您进入已经完成某种程度优化的应用程序时。程序员使用许多小的假设来获得速度,并且这些并不总是很容易快速移植到64位。我必须处理的几个例子:

  • Proper alignment of elements within a struct. As data sizes change, assumptions that certain fields in a struct will be aligned on an optimal memory boundary may fail
  • 正确对齐结构中的元素。随着数据大小的改变,假设结构中的某些字段将在最佳内存边界上对齐可能会失败

  • Length of long integers change, so if you pass values over a socket to another program that may not be 64-bit, you need to refactor your code
  • 长整数的长度会发生变化,因此如果将套接字上的值传递给另一个可能不是64位的程序,则需要重构代码

  • Pointer lengths change, as so hard to decipher code written be a guru that has left the company become a little trickier to debug
  • 指针长度发生变化,因为编写的代码难以破解,导致公司调试变得有点棘手

  • Underlying libraries will also need to have 64-bit support to properly link. This is a large part of the problem of porting code if you rely on any libraries that are not open source
  • 底层库还需要64位支持才能正确链接。如果您依赖任何非开源的库,这是移植代码问题的很大一部分

#2


5  

In addition to the things in @jvasak's post, the major thing that can causes bugs:

除了@jvasak帖子中的内容之外,还有可能导致错误的主要因素:

  • pointers are larger than ints - a huge amount of code makes the assumption that the sizes are the same.
  • 指针大于整数 - 大量的代码假设大小相同。

Remember that Windows will not even allow an application (whether 32-bit or 64-bit) to handle pointers that have an address above 0x7FFFFFFF (2GB or above) unless they have been specially marked as "LARGE_ADDRESS_AWARE" because so many applications will treat the pointer as a negative value at some point and fall over.

请记住,Windows甚至不允许应用程序(无论是32位还是64位)处理地址大于0x7FFFFFFF(2GB或更高)的指针,除非它们被特别标记为“LARGE_ADDRESS_AWARE”,因为许多应用程序会将指针在某个时刻作为负值并且摔倒。

#3


5  

The biggest issues that I've run into porting our C/C++ code to 64 bit is support from 3rd party libraries. E.g. there is currently only 32 bit versions of the Lotus Notes API and also MAPI so you can't even link against them.

我将C / C ++代码移植到64位的最大问题是来自第三方库的支持。例如。目前只有32位版本的Lotus Notes API以及MAPI,因此您甚至无法链接它们。

Also since you can't load a 32 bit DLL into your 64 bit process you get burnt again trying to load things dynamically. We ran into this problem again trying to support Microsoft Access under 64 bit. From wikipedia:

此外,由于您无法将64位DLL加载到64位进程中,因此再次尝试动态加载内容。我们再次尝试在64位下支持Microsoft Access遇到此问题。来自*:

The Jet Database Engine will remain 32-bit for the foreseeable future. Microsoft has no plans to natively support Jet under 64-bit versions of Windows

在可预见的未来,Jet数据库引擎将保持32位。微软没有计划在64位版本的Windows下原生支持Jet

#4


3  

Just a guess, but I would think a large part of it would be support - If Adobe compiles the 64 bit version, they have to support it. Even though it may be a simple compile switch, they'd still have to run through a lot of testing, etc, followed by training their support staff to respond correctly, when they do run into issues fixing them either results in a new version of the 32 bit binary or a branch in the code, etc. So while it seems simple, for a large application it can still end up costing a lot.

只是一个猜测,但我认为其中很大一部分将是支持 - 如果Adobe编译64位版本,他们必须支持它。即使它可能是一个简单的编译开关,他们仍然需要经过大量的测试等,然后训练他们的支持人员正确响应,当他们遇到问题修复它们或者导致新版本的32位二进制或代码中的分支等。因此,虽然它看起来很简单,但对于大型应用程序来说,它仍然会花费很多。

#5


3  

Another reason that a lot of companies have not gone through the effort of creating 64 bit versions is simply they don't need to.

许多公司没有完成创建64位版本的努力的另一个原因是他们不需要。

Windows has WoW64 (Windows on Windows 64 bit) and Linux can have the 32 bit libraries available alongside the 64 bit. Both of these allow us to run 32 bit applications in 64 bit environments.

Windows具有WoW64(Windows 64位上的Windows),Linux可以在64位下提供32位库。这两者都允许我们在64位环境中运行32位应用程序。

As long as the software is able to run in this way, there is not a major incentive to convert to 64 bit.

只要软件能够以这种方式运行,就没有转换为64位的主要动机。

Exceptions to this are things such as device drivers as they are tied in deeper with the operating systems and cannot run in the 32 bit layer that the x86-64/AMD64 based 64-bit operating systems offer (IA64 is unable to do this from what I understand).

例外情况是设备驱动程序,因为它们与操作系统的关系更深,并且无法在基于x86-64 / AMD64的64位操作系统提供的32位层中运行(IA64无法通过我明白)。

I agree with you on flash player though, I am very disappointed in Adobe that they have not updated this product. As you have pointed out, it does not work properly in 64 bit requiring you to run the 32 bit version of Internet Explorer.

我同意你对Flash播放器的看法,我对Adobe非常失望,他们没有更新这个产品。正如您所指出的,它在64位中无法正常运行,需要您运行32位版本的Internet Explorer。

I think it is a strategic mistake on Adobe's part. Having to run the 32 bit browser for flash player is an inconvenience for users, and many will not understand this solution. This could lead to developers being apprehensive about using flash. The most important thing for a web site is to make sure everyone can view it, solutions that alienate users are typically not popular ones. Flash's popularity was fed by its own popularity, the more sites that used it, the more users had it on their systems, the more users that had it on their systems, the more sites were willing to use it.

我认为这是Adobe的一个战略性错误。必须为闪存播放器运行32位浏览器对用户来说是一个不便,许多人不会理解这个解决方案。这可能会导致开发人员对使用闪存感到担心。对于网站来说,最重要的是确保每个人都可以查看它,疏远用户的解决方案通常不受欢迎。 Flash的受欢迎程度取决于它自己的受欢迎程度,使用它的站点越多,用户在系统上拥有的用户越多,在系统上拥有它的用户就越多,站点就越愿意使用它。

The retail market pushes these things forward, when a general consumer goes to buy a new computer, they aren't going to know they don't need a 64 bit OS they are going to get it either because they hear it is the latest and greatest thing, the future of computing, or just because they don't know the difference.

零售市场将这些事情推向前进,当普通消费者购买新电脑时,他们不会知道他们不需要64位操作系统他们会得到它,因为他们听到它是最新的和最伟大的事情,计算的未来,或仅仅因为他们不知道差异。

Vista has been out for about 2 years now, and Windows XP 64-bit was out before that. In my mind that is too long for a major technology such as Flash to not be upgraded if they want to hold on to their market. It may have to do with Adobe taking over Macromedia and this is a sign that Adobe does not feel Flash is part of their future, I find it hard to believe as I think Flash and Dreamweaver were the top parts of what they got out of Macromedia, but then why have they not updated it yet?

Vista已经推出了大约2年,之前Windows XP 64位已经推出。在我看来,如果他们想要坚持他们的市场,那么像Flash这样的主要技术就不会升级太久了。它可能与Adobe接管Macromedia有关,这表明Adobe并不认为Flash是他们未来的一部分,我觉得很难相信,因为我认为Flash和Dreamweaver是他们从Macromedia获得的最重要的部分,但为什么他们还没有更新呢?

#6


2  

It is not as simple as just flipping a switch on your compiler. At least, not if you want to do it right. The most obvious example is that you need to declare all your pointers using 64-bit datatypes. If you have any code which makes assumptions about the size of these pointers (e.g. a datatype which allocates 4 bytes of memory per pointer), you'll need to change it. All this needs to have been done in any libraries you use, too. Further, if you miss just a few then you'll end up with pointers being down-casted and at the wrong location. Pointers are not the only sticky point but are certainly the most obvious.

它并不像在编译器上翻转开关那么简单。至少,如果你想做得对,那就不行了。最明显的例子是您需要使用64位数据类型声明所有指针。如果您有任何代码可以对这些指针的大小进行假设(例如,每个指针分配4个字节内存的数据类型),则需要更改它。所有这些都需要在您使用的任何库中完成。此外,如果你错过了一些,那么你最终会得到指针下降和错误的位置。指针不是唯一的粘性点,但肯定是最明显的。

#7


1  

Primarily a support and QA issue. The engineering work to build for 64-bit is fairly trivial for most code, but the testing effort, and the support cost, don't scale down the same way.

主要是支持和质量保证问题。对于大多数代码而言,为64位构建的工程工作相当简单,但是测试工作和支持成本不会以相同的方式缩小。

On the testing side, you'll still have to run all the same tests, even though you "know" they should pass.

在测试方面,你仍然必须运行所有相同的测试,即使你“知道”它们应该通过。

For a lot of applications, converting to a 64-bit memory model doesn't actually give any benefit (since they never need more than a few GB of RAM), and can actually make things slower, due to the larger pointer size (makes every object field twice as large).

对于很多应用程序来说,转换为64位内存模型实际上并没有带来任何好处(因为它们从不需要超过几GB的RAM),并且由于指针大小较大(实际上可能会使速度变慢)每个对象字段的两倍大)。

Add to that the lack of demand (due to the chicken/egg problem), and you can see why it wouldn't be worth it for most developers.

再加上缺乏需求(由于鸡/蛋问题),你可以看出为什么对大多数开发者来说它不值得。

#8


0  

Their Linux/Flash blog goes some way to explain why there isn't a 64bit Flash Player as yet. Some is Linux-specific, some is not.

他们的Linux / Flash博客在某种程度上解释了为什么还没有64位Flash Player。有些是特定于Linux的,有些则不是。