Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么相同的代码不能在Ubuntu服务器上编译?_Ubuntu_Postfix Mta_Ubuntu 12.04 - Fatal编程技术网

为什么相同的代码不能在Ubuntu服务器上编译?

为什么相同的代码不能在Ubuntu服务器上编译?,ubuntu,postfix-mta,ubuntu-12.04,Ubuntu,Postfix Mta,Ubuntu 12.04,我刚从源代码在Ubuntu服务器上安装了Postfix2.7.11。我不使用ubuntu自己的版本,因为我需要旧版本 我发现了一个非常有趣的问题。以前,在CentOS 5和6中,我可以毫无问题地构建源代码。但是,在Ubuntu服务器中,12.04是完全不同的 我遇到了以下问题: dict_nis.c:173: error: undefined reference to 'yp_match'<br> dict_nis.c:187: error: undefined reference

我刚从源代码在Ubuntu服务器上安装了Postfix2.7.11。我不使用ubuntu自己的版本,因为我需要旧版本

我发现了一个非常有趣的问题。以前,在CentOS 5和6中,我可以毫无问题地构建源代码。但是,在Ubuntu服务器中,12.04是完全不同的

我遇到了以下问题:

dict_nis.c:173: error: undefined reference to 'yp_match'<br>
dict_nis.c:187: error: undefined reference to 'yp_match'<br>

dns_lookup.c:347: error: undefined reference to '__dn_expand'<br>
dns_lookup.c:218: error: undefined reference to '__res_search'<br>
dns_lookup.c:287: error: undefined reference to '__dn_expand'<br>
dns_lookup.c:498: error: undefined reference to '__dn_expand'<br>
dns_lookup.c:383: error: undefined reference to '__dn_expand'<br>
dict_nis.c:173:错误:未定义对“yp_匹配”的引用
dict_nis.c:187:错误:未定义对“yp_匹配”的引用
dns_lookup.c:347:错误:未定义对“u dn_expand”的引用
dns_lookup.c:218:错误:未定义对“u res_search”的引用
dns_lookup.c:287:错误:未定义对“u dn_expand”的引用
dns_lookup.c:498:错误:未定义对“u dn_expand”的引用
dns_lookup.c:383:错误:未定义对“u dn_expand”的引用
是的,这个原因很明显。我只是搜索相关库并将其添加到makefile中。它起作用了

问题是为什么?Ubuntu服务器和CentOS有什么区别


一种可能是gcc和ld版本。Ubuntu服务器在CentOS上使用不同版本的gcc和ld。但我不确定

最后,在其他人的帮助下。我找到了原因
Ubuntu有特殊的位置。位置与CentOS不同
但在Postfix makedefs文件中,它不包括这个特定的位置。让我们检查一下来源:

SYSLIBS="-ldb"
        for name in nsl resolv
        do
            for lib in /usr/lib64 /lib64 /usr/lib /lib
            do
            test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
                SYSLIBS="$SYSLIBS -l$name"
                break
            }
            done
        done 

这里,当do make时将使用SYSLIBS。此脚本将检查一些要添加的特殊文件夹.so lib。但这些地点不包括Ubuntu

我在Ubuntu 12.04和postfix 2.9.3以及vda补丁2.9.1中遇到了同样的问题

gcc -Wmissing-prototypes -Wformat -DDEBIAN -DMAX_DYNAMIC_MAPS -DHAS_PCRE -DHAS_LDAP -DHAS_SQLITE -DMYORIGIN_FROM_FILE -DNO_NIS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAS_CDB -DHAS_MYSQL -I/usr/include/mysql -DHAS_PGSQL -I/usr/include/postgresql -DHAS_SQLITE -I/usr/include -DHAS_SSL -I/usr/include/openssl -DUSE_SASL_AUTH -I/usr/include/sasl -DUSE_CYRUS_SASL -DUSE_TLS  -O2 -I. -I../../include -DLINUX3 -o smtpd smtpd.o smtpd_token.o smtpd_check.o smtpd_chat.o smtpd_state.o smtpd_peer.o smtpd_sasl_proto.o smtpd_sasl_glue.o smtpd_proxy.o smtpd_xforward.o smtpd_dsn_fix.o smtpd_milter.o smtpd_resolve.o smtpd_expand.o ../../lib/libmaster.a ../../lib/libtls.a ../../lib/libdns.a ../../lib/libxsasl.a ../../lib/libmilter.a ../../lib/libglobal.a ../../lib/libutil.a -lssl -lcrypto -lsasl2 -lpthread -L/usr/src/postfix-2.9.3/debian -ldb
../../lib/libdns.a: undefined reference to `__res_search'
../../lib/libdns.a: undefined reference to `__dn_expand'
collect2: ld gab 1 als Ende-Status zurück
make: *** [smtpd] Fehler 1
问题:缺少-lresolv

在文件“makedefs”:gcc-print search dirs | sed-n'/^libraries:=/s/libraries:=//p'中,我无法使用,因为我有德语版的Ubuntu。gcc-print搜索目录输出为“Bibliotheken:”


请参见

您应该将
-ldb-lnsl-lresolv
附加到
AUXLIBS

IIRC postfix是基于
autoconf
的,因此,如果您可以发布
config.log
,或者只需自己先查看一下,您就可以了解为什么它无法检测到所需的库。Hi@favovoritetti我找不到config.log,你能告诉我怎么找到它吗?我应该提到的一件事是,当我从源代码安装postfix时,我不需要在make之前运行./configure。事实上,我可以直接运行make。CCARGS=“-DHAS_CDB-DHAS_PCRE”AUXLIBS=“-lnsl-lpcre-lcdb”制作制作文件和制作-j 3