10

I was trying to compile exprtk.hpp file (https://exprtk.codeplex.com/) with mingw32(491_32) on Qt (win7). During compilation, I give this error message:

debug\main.o:-1: error: too many sections (35325)

I've been noticed that the exprtk.hpp file is huge (>32000 lines). I've been trying optimization flags on compiler but It didn't help eighter. I'll be appreciated if somebody help me... Regards,

Mosi
  • 1,178
  • 2
  • 12
  • 30
  • I think that the "bigobj" flag will solve my problem but my compiler cant recognize this flag. – Mosi Aug 08 '15 at 06:16

2 Answers2

4

You can by adding the compilation flags -flto -Wl,-allow-multiple-definition and you can add -fuse-linker-plugin

-Wa,-mbig-obj do not work on x86/32bits architecture (only x64)

Shaheryar.Akram
  • 722
  • 10
  • 19
  • Worked for me. Only need the `-fto` option. I also have to separate all my class methods into separate compilation units (.cpp). Thanks a lot. – Bobax Nov 07 '20 at 11:13
-1

Such huge header-only code is already bad design, i'd rather recommend to use another library, like muParser.

Your problem was already discussed in other threads, like this.

As you've already noticed, passing /bigobj to Microsoft's compiler causes it to output a munged COFF format with up to 2^31 sections, which "should be enough for anybody."

I've tested this new option with MinGW-w64 and it works. You need to pass -Wa,-mbig-obj to gcc to opt-in to big objects (-Wa means pass this option to the assembler). – Francis Gagné

Community
  • 1
  • 1
Youka
  • 2,646
  • 21
  • 33
  • Thanks, First of all I've tested -Wa, -mbig-obj option and It didn't worked. Second, I'm looking for a library which support "logic operations", "control and loop structures". – Mosi Aug 08 '15 at 07:33
  • @Mosi That's already more than a math parser should provide, you should rather add a light scripting language, like [Lua](http://www.lua.org/). – Youka Aug 08 '15 at 07:35
  • The option `-Wa,-mbig-obj` didn't work for me (invalid option), but the last post (Shaheryar.Akram) solved my issue. – Bobax Nov 07 '20 at 11:15