-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GCC10.3 installation bug with its default -fno-common #5
Comments
I also see this error, and I understand the cause. In the latest versions of gcc, this error is caused because variables are being defined in multiple places as the errors state. This is because variables are being initialized in the .h files, and these .h files are being included in multiple routines. The "modern" solution, is to define the various variables in the .h files as extern, but not to intialize them there. Instead one intializes them in a single .c routine. the -fcommon switch sorts this out. See the explanation here, which notes among other things that this, but with a possible performance penalty. |
In linux adding -fcommon to CFLAGS in makefile doesn't help: This still throws 'multiple definition' issue and compiler doesn't produce 'cod4x18_dedrun' file. |
To modify your Makefile to add the -fcommon flag and potentially address multiple definition issues when compiling your project with GCC version 10 or later, follow these steps: Open the Makefile: Use a text editor of your choice to open the Makefile. You mentioned earlier that you use nano, so you can open it with: bash Add -fcommon to COPTS: Append the -fcommon flag to the existing flags in the COPTS variable. It should look like this: makefile Save and Close: After adding the flag, save the file and exit the text editor. If you’re using nano, you can do this by pressing Ctrl+X to close, then Y to save the changes, followed by Enter to confirm. Recompile Your Project: Go back to your terminal and run the make command to rebuild your project with the new compiler settings: bash Check for Errors: Verify if the compilation completes without the multiple definition errors. If the errors persist, there may be other issues in the code or build system settings that need attention. This process should help in resolving build issues related to the stricter linking behavior of newer GCC versions. If the problem continues, reviewing the source code for incorrect global variable usage or further adjusting the build settings might be necessary. |
I saw lots of thing like:
And I found a solution in kr-colab/discoal#21 which shows:
This modify in makefile helps a lot.
I wish somebody who uses the gcc-10 would see this issue.
The text was updated successfully, but these errors were encountered: