ThePhD / sol2

Sol3 (sol2 v3.0) - a C++ <-> Lua API wrapper with advanced features and top notch performance - is here, and it's great! Documentation:
http://sol2.rtfd.io/
MIT License
4.16k stars 504 forks source link

Getting 'cc1plus.exe: out of memory allocating 65536 bytes' in MinGW #1398

Closed eduardodoria closed 2 years ago

eduardodoria commented 2 years ago

I am trying to build using MinGW-w64 11.2.0 (and other recent versions) but sometimes getting this error in one of bindings C++ source file:

cc1plus.exe: out of memory allocating 65536 bytes

Already tried compile with parameters like: -ftrack-macro-expansion=0, -Wa,-mbig-obj, -Os, -O1, -O2. Also tried to placing groups of bindings in multiple different C++ source files. Nothing works.

Rochet2 commented 2 years ago

How are you making the binding? Try using the following method if you are currently binding everything for a single usertype at once in the usertype constructor.

auto bindings = sol::new_usertype<MyThing>("MyThing");

// Add bindings to the usertype afterwards one at a time
bindings["MyMethod1"] = &MyThing::MyMethod1;
bindings["MyMethod2"] = &MyThing::MyMethod2;
bindings["MyMethod3"] = &MyThing::MyMethod3;
eduardodoria commented 2 years ago

I used to use all in single new_usertype call. I will do more tests, but it seems to works now! Thanks!