简体   繁体   English

您可以在64位计算机上编译32位Apache DSO(Oracle HTTP服务器)吗?

[英]Can you compile 32-bit Apache DSOs (Oracle HTTP Server) on a 64-bit machine?

I've migrated an Oracle database and Oracle HTTP server install from a 32-bit machine to a 64-bit machine - both machines running Linux. 我已经将Oracle数据库和Oracle HTTP服务器安装从32位计算机迁移到64位计算机-这两台计算机都运行Linux。 Oracle Database is 64-bit, but the (Apache) HTTP server is 32-bit. Oracle数据库是64位的,但是(Apache)HTTP服务器是32位的。

I use some non-Oracle DSOs (mod_ntlm for one) but whenever I run the standard "make install" type thing I end up with a 64-bit module. 我使用了一些非Oracle DSO(一个是mod_ntlm),但是每当我运行标准的“ make install”类型的东西时,我都会得到一个64位模块。

Is there a standard way to compile 32-bit Apache modules on a 64-bit machine? 有没有在64位计算机上编译32位Apache模块的标准方法?

As an alternative to Andrew Medico's answer, use ' -m32 ' for 32-bit compilations and ' -m64 ' for 64-bit compilations on PPC or SPARC or Intel machines - since you don't actually mention which chip architecture you are using and that notation works on all of these. 作为一种替代医学生安德鲁的回答,请使用“ -m32针对32位编译和“ -m64对PPC或SPARC或英特尔机器上的64位汇编” -因为你实际上并不提及您正在使用的芯片架构和该符号适用于所有这些。

I often use: 我经常使用:

CC="gcc -m32" ./configure

to ensure a 32-bit compilation (or, more frequently, CC="gcc -m64" to ensure 64-bit compilation). 以确保32位编译(或更常见的是, CC="gcc -m64"以确保64位编译)。


Question: "Is CC an environment variable used by make?" 问题:“ CC是make使用的环境变量吗?”

Answer: Yes, though in this case, it is also recognized by configure , which is a shell script generated by autoconf . 答:是的,尽管在这种情况下, configure也可以识别它,这是autoconf生成的shell脚本。 The notation I used - which is what I use at the command line - sets CC in the environment while the configure command is run. 我使用的符号-这是我在命令行上使用的符号-在运行configure命令时在环境中设置CC。 The other answer suggests using: 另一个答案建议使用:

./configure CC="gcc -m32"

I assume that works and achieves much the same effect; 我认为这种方法可以达到相同的效果。 I've not tried it so I don't know that it works. 我没有尝试过,所以我不知道它有用。

If you run ./configure --help | less 如果您运行./configure --help | less ./configure --help | less , you will see information (often just standard information) about how to use the script. ./configure --help | less ,您将看到有关如何使用脚本的信息(通常只是标准信息)。 And at the end, it will list (some of the) relevant environment variables, of which CC is one. 最后,它将列出(一些)相关的环境变量,其中CC是其中之一。

The advantage of setting the C compiler to "gcc -m32" is that the 32-bit flag is set every time the compiler is used - there is very little room for it to go wrong. 将C编译器设置为“ gcc -m32”的优点是,每次使用编译器时都会设置32位标志-出错的空间很小。 If you set a flags variable (CFLAGS, etc), there is a chance that some command won't use it, and then things can go awry. 如果设置标志变量(CFLAGS等),则某些命令可能不会使用它,那么事情可能会出错。

Also, going back to the question, make certainly uses a variable (macro) called CC. 此外,要回的问题, make一定使用变量(宏)称为CC。 And you can set that on the make command line: 您可以在make命令行上进行设置:

make CC="gcc -m32"

That overrides any setting in the makefile. 这将覆盖makefile中的任何设置。 By contrast, using an environment variable, the setting in the makefile overrides the value in the environment, so setting CC as an environment variable is less helpful. 相比之下,使用环境变量,makefile中的设置会覆盖环境中的值,因此将CC设置为环境变量的作用较小。 Although make -e gives the environment precedence over the makefile, it is usually a dangerous option to use - it can have unexpected side-effects. 尽管make -e优先于make -e文件使用环境,但是使用它通常是一个危险的选择-它可能会产生意想不到的副作用。

./configure CFLAGS="-march=i686" 

应该做

Along with the -m32 flag in gcc, you may need to include the -melf_i386 flag for ld to properly link the 32bit object files to the 32bit libraries if you have both the 32bit and 64bit libraries. 与gcc中的-m32标志一起,如果您同时具有32位和64位库,则可能需要为ld包括-melf_i386标志,以将32位目标文件正确链接到32位库。 The standard ld on 64bit linux boxes will default to the 64bit libraries and you get a compatibility error when the linking occurs. 64位linux盒上的标准ld将默认为64位库,并且在发生链接时会出现兼容性错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM