2

I'm specifically building a test program to work on Chaiscript, which is how I encountered this issue:

chai.cpp:

#include <cstdio>
#include <iostream>

#include <chaiscript/chaiscript.hpp>
#include <chaiscript/chaiscript_stdlib.hpp>

std::string helloWorld(const std::string &t_name)
{
  return "Hello " + t_name + "!";
}

int main(int argc, char** argv, char** env)    {
  chaiscript::ChaiScript chai;
  chai.add(chaiscript::fun(&helloWorld), "helloWorld");

  chai.eval("puts(helloWorld(\"Bob\"));");

    return 0L;
}


/usr/lib/gcc/i686-pc-cygwin/5.4.0/../../../../i686-pc-cygwin/bin/as: CMakeFiles/chai.dir/src/chai.cpp.o: too many sections (37830)
/tmp/ccqGbeku.s: Assembler messages:
/tmp/ccqGbeku.s: Fatal error: can't write CMakeFiles/chai.dir/src/chai.cpp.o: File too big
/usr/lib/gcc/i686-pc-cygwin/5.4.0/../../../../i686-pc-cygwin/bin/as: CMakeFiles/chai.dir/src/chai.cpp.o: too many sections (37830)

This issue doesn't appear when I build on Mac or Linux.

Chris K
  • 11,996
  • 7
  • 37
  • 65
  • Possible duplicate of [Object file has too many sections](https://stackoverflow.com/questions/16596876/object-file-has-too-many-sections) – ivan_pozdeev Oct 31 '18 at 02:58

1 Answers1

3

I discovered a workaround to this issue from the Chaiscript CMakeLists.txt:

if(MINGW OR CYGWIN)
  add_definitions(-O3)
endif()

Other searches on the Internet imply this big-object problem is linked the Windows executable format, and is not likely to be addressed in G++. Using MingW32 did not address this error in my case - I'm not going to 64-bit.

Chris K
  • 11,996
  • 7
  • 37
  • 65