Author Topic: Compilation Error: "Too many new sections"  (Read 2605 times)

Emerald Nova

  • Newbie
  • *
  • Posts: 19
  • Karma: +2/-0
    • View Profile
    • Emerald Nova Games
Compilation Error: "Too many new sections"
« on: January 28, 2019, 03:42:04 am »
I was playing around with making a text based Mean Bean Machine clone. I was implementing a series print statements and I kept compiling and making progress with test runs. For some reason, I have suddenly come to a point where I am no longer allowed to compile. The full output of the compilation attempt is attached as an image. I don't think there's anything wrong with my actual code, but I have attached it in case that helps. I read here (https://stackoverflow.com/questions/16596876/object-file-has-too-many-sections) that it can be remedied in GCC through command line inputs, but the Jo Engine Cue Maker is something of a black box to me.

ponut64

  • Full Member
  • ***
  • Posts: 220
  • Karma: +22/-1
    • View Profile
Re: Compilation Error: "Too many new sections"
« Reply #1 on: January 28, 2019, 08:05:26 am »
You are getting this error because a single source file has too many functions (the object code is too big).

This is an artifact of compiling for SH2s, as I understand it.

You must break up your code into separate source files, compile them separately, and structure them to share data properly with header files.
To add files to the compiler, edit the makefile in your project's directory such that your additional source files are in the SRCS line. You need only put a space between each file name.
For example:
SRCS=main.c mymath.c draw.c bounder.c collision.c control.c msfs.c ZT/ZT_LOAD_MODEL.c ZT/ZT_TOOLS.c ZT/ZT_CD.c

This is why your typical Saturn project is divided between a great many source files.
« Last Edit: January 28, 2019, 08:13:44 am by ponut64 »

Emerald Nova

  • Newbie
  • *
  • Posts: 19
  • Karma: +2/-0
    • View Profile
    • Emerald Nova Games
Re: Compilation Error: "Too many new sections"
« Reply #2 on: January 28, 2019, 11:42:30 am »
That makes sense, thank you. This probably happened as I was adding functions. I have a lot of mutual include statements, those should still be fine, correct?

ponut64

  • Full Member
  • ***
  • Posts: 220
  • Karma: +22/-1
    • View Profile
Re: Compilation Error: "Too many new sections"
« Reply #3 on: January 28, 2019, 04:55:48 pm »
Mutual inclusions of header files is OK. Just don't throw actual function code into header files :)
Mutual inclusions of source files is something you ought to avoid.
Basically, a source file includes its header and any other headers it needs. To access data and functions from that source file, you include its header.
If you want to define data in the source file, specify the data in the header file as "extern" so other sources can access it.
If you want to define data in the header file, define it normally.
Headers themselves can become too large, so perhaps they ought to be separated like I suggest too. If you have "common" data that you typically need everywhere, you can make a common header, it should work.
« Last Edit: January 28, 2019, 05:04:44 pm by ponut64 »

 

Sitemap 1 2 3 4 5 6 7 8 9 10