Cygwin平台 编译QFS

本文记录了在Cygwin64位环境下编译QFS时遇到的too many sections错误,并尝试通过修改CMakeLists.txt来解决,但最终未能解决该问题,转而在Cygwin32位环境下完成编译。
摘要由CSDN通过智能技术生成

QFS是一个开源分布式文件系统 基于Google File System的实现KFS

文档中写明支持Cygwin 所以打算在cygwin下使用

由于之前在公司机器上编译成功(cygwin32) 想当然认为64位下也没什么问题


于是按照正确顺序:安装cygwin 64位, JDK,

修改~/.bashrc 添加

export JAVA_HOME=/cygdrive/d/app/JDK

export JAVA_AWT_LIBRARY=/cygdrive/d/app/JDK/jawt.lib

export JAVA_JVM_LIBRARY=/cygdrive/d/app/JDK/jvm.lib

不加这些也行,但是就不能支持java了


修改默认的CMakeLists.txt :

IF (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
    find_package(Boost COMPONENTS regex system REQUIRED)
ELSE (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
    find_package(Boost COMPONENTS regex system REQUIRED) #这一行添加system,默认的配置文件有误,将不会正确链接libboost_system-mt.dll.a
ENDIF (CMAKE_SYSTEM_NAME STREQUAL "Darwin")

进入qfs目录
cmake .

一切正常

make... 就出状况啦

[ 18%] Building CXX object src/cc/meta/CMakeFiles/kfsMeta.dir/MetaRequest.o
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../x86_64-pc-cygwin/bin/as: CMakeFiles/kfsMeta.dir/MetaRequest.o: too many sections (33439)
/tmp/ccAOJfOA.s: Assembler messages:
/tmp/ccAOJfOA.s: Fatal error: can't write CMakeFiles/kfsMeta.dir/MetaRequest.o: ▒ļ▒▒▒▒▒
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../x86_64-pc-cygwin/bin/as: CMakeFiles/kfsMeta.dir/MetaRequest.o: too many sections (33439)
/tmp/ccAOJfOA.s: Fatal error: can't close CMakeFiles/kfsMeta.dir/MetaRequest.o: ▒ļ▒▒▒▒▒
src/cc/meta/CMakeFiles/kfsMeta.dir/build.make:310: recipe for target 'src/cc/meta/CMakeFiles/kfsMeta.dir/MetaRequest.o' failed
make[2]: *** [src/cc/meta/CMakeFiles/kfsMeta.dir/MetaRequest.o] Error 1
CMakeFiles/Makefile2:250: recipe for target 'src/cc/meta/CMakeFiles/kfsMeta.dir/all' failed
make[1]: *** [src/cc/meta/CMakeFiles/kfsMeta.dir/all] Error 2
Makefile:126: recipe for target 'all' failed
make: *** [all] Error 2


网上一查"too many sections" 结果令人绝望:

http://stackoverflow.com/questions/16596876/object-file-has-too-many-sections

The error "%B: too many sections (%d)" comes from the function coff_compute_section_file_positions() located in bfd/coffcode.h. It's produced when the output.obj file (in COFF format) contains more than 32766 sections. There is no way to avoid this error, at least not if you want to use Windows' PE/COFF object format; COFF files use onlytwo bytes for "NumberOfSections" in the file header.

It's not clear to me why as (the GNU assembler) caps the number of sections at 32768-minus-2, instead of 65536-minus-1 (section 0 is reserved); but either way, that might not be enough if you're making heavy use of templatesand your compiler implements templates via COMDAT sections.

As you've already noticed, passing /bigobj to Microsoft's compiler causes it to output a munged COFF format with up to 231 sections, which "should be enough for anybody." However, the munged format is formally undocumented, and I don't see any informal documentation (blog posts or what-have-you) on the subject, so until someone with a copy of MSVC can write up a specification for/bigobj, it doesn't stand much chance of getting into the GNU tools.

IMHO, if you're trying to make a Windows build, you should just bite the bullet and use MSVC. Nobody besides Microsoft is particularly motivated to waste time wrestling with the PE/COFF format.


暂时这个问题就没法解决了 最终换回了cygwin 32位版本 顺利编译

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值