Author Topic: Strange Syntax Error Using MIPS Compiler  (Read 365 times)

Offline Authentic

  • Single posting newcomer
  • *
  • Posts: 4
Strange Syntax Error Using MIPS Compiler
« on: October 20, 2017, 12:16:31 pm »
Recently I installed Code::Blocks and everything worked with the mingw compiler. But after following this guide (to the letter) I find myself unable to build even the simplest valid C programs: https://github.com/glankk/n64. The error is always the same:

Code: [Select]
||=== Build: Debug in test (compiler: n64) ===|
c:\msys64\opt\n64-toolchain\bin\..\lib\gcc\mips64\7.2.0\..\..\..\..\mips64\bin\ld.exe:--defsym|1|syntax error|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

I am using Code::Blocks 16.01, and here is an example of a c file that won't build:

Code: [Select]
int main() {
    return 0;
}

I don't want to waste anyone's time if this is a simple problem, but I really cannot find a solution. Do I need to rebuild the compiler?
« Last Edit: October 20, 2017, 09:20:55 pm by Authentic »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5969
    • My Best Post
Re: Strange Syntax Error Using MIPS Compiler
« Reply #1 on: October 20, 2017, 12:43:04 pm »
Post a full rebuild log of your simple program and post the simple program.
http://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

I am trying to build the n64 compiler, right now. But, I have a slow internet connection and a slow computer.

Likely something changed in the Compiler or Code::Blocks (CB) that requires the CB settings to be changed.

Tim S.
« Last Edit: October 20, 2017, 12:57:09 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5969
    • My Best Post
Re: Strange Syntax Error Using MIPS Compiler
« Reply #2 on: October 20, 2017, 01:27:07 pm »
While waiting for the downloads to finish, I am guessing n64.conf is not correct and needs edited to fix this error.

NOTE: It looks like this git project expects an CB "Custom makefile" project instead of a normal CB project like you are trying to use.

But, till you post the requested full build log I will not know what you are trying to use for certain.

Tim S. 
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Authentic

  • Single posting newcomer
  • *
  • Posts: 4
Re: Strange Syntax Error Using MIPS Compiler
« Reply #3 on: October 20, 2017, 07:57:28 pm »
Thank you for responding! I am going to start rebuilding the compiler now to see if that works. Here is the build log:

Code: [Select]
Build started on: 20-10-2017 at 12:53.57
Build ended on: 20-10-2017 at 12:53.57
-------------- Build: Debug in test (compiler: n64)---------------
mips64-g++.exe -o bin\Debug\test.exe obj\Debug\test.o -T "C:\Program Files (x86)\CodeBlocks\n64-master"/ldscripts/gl-n64.ld -Wl,--defsym,start=0x -specs=nosys.specs -flto -Wl,--gc-sections
c:/msys64/opt/n64-toolchain/bin/../lib/gcc/mips64/7.2.0/../../../../mips64/bin/ld.exe:--defsym:1: syntax error
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5969
    • My Best Post
Re: Strange Syntax Error Using MIPS Compiler
« Reply #4 on: October 20, 2017, 11:24:12 pm »
Try putting "n64-master" in a place that does NOT have spaces or special chars in the path.

Please post a full re-build log if you still have problems.

Re-build does not mean build.

Edited: added my re-build log; minus the clean portain.

Code: [Select]
-------------- Build: Debug in test (compiler: n64)---------------

mips64-gcc.exe -Wall -g -ffunction-sections -fdata-sections -flto -ffat-lto-objects -I C:\Users\stahta01\devel\open_source_code\no_version_control\n64-master/include -IC:\Users\stahta01\devel\open_source_code\no_version_control\n64-master\include -c C:\Users\stahta01\devel\open_source_code\no_version_control\test\test\main.c -o obj\Debug\main.o
mips64-g++.exe  -o bin\Debug\test.exe obj\Debug\main.o  -T C:\Users\stahta01\devel\open_source_code\no_version_control\n64-master/ldscripts/gl-n64.ld -Wl,--defsym,start=0x80000400 -specs=nosys.specs -flto -Wl,--gc-sections   
Output file is bin\Debug\test.exe with size 3.04 KB

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Authentic

  • Single posting newcomer
  • *
  • Posts: 4
Re: Strange Syntax Error Using MIPS Compiler
« Reply #5 on: October 21, 2017, 01:00:23 am »
I moved n64-master to c:/users/trevor/desktop/. No dice...

Code: [Select]
-------------- Clean: Debug in test (compiler: n64)---------------

Cleaned "test - Debug"

-------------- Build: Debug in test (compiler: n64)---------------

mips64-gcc.exe -Wall -g -ffunction-sections -fdata-sections -flto -ffat-lto-objects -I C:\Users\Trevor\Desktop\n64-master/include -IC:\Users\Trevor\Desktop\n64-master\include -c "C:\Users\Trevor\Documents\Code Blocks\projects\test\test.c" -o obj\Debug\test.o
mips64-g++.exe  -o bin\Debug\test.exe obj\Debug\test.o  -T C:\Users\Trevor\Desktop\n64-master/ldscripts/gl-n64.ld -Wl,--defsym,start=0x -specs=nosys.specs -flto -Wl,--gc-sections   
c:/msys64/opt/n64-toolchain/bin/../lib/gcc/mips64/7.2.0/../../../../mips64/bin/ld.exe:--defsym:1: syntax error
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5969
    • My Best Post
Re: Strange Syntax Error Using MIPS Compiler
« Reply #6 on: October 21, 2017, 01:08:46 am »
Then, the issue is likely because "-Wl,--defsym,start=0x" the value 0x is wrong. But, I have no idea where the value is set.
I was hoping the linker script was the place it was set; and, the reason it failed was the spaces.

From Compiler Custom Vars.
Code: [Select]
GLDFLAGS
Code: [Select]
-T $(LDSCRIPT) -Wl,--defsym,start=0x$(address) -specs=nosys.specs -flto -Wl,--gc-sections
For some reason your value of $(address) is blank; but, I have no idea where that value is located.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5969
    • My Best Post
Re: Strange Syntax Error Using MIPS Compiler
« Reply #7 on: October 21, 2017, 01:17:12 am »
Found out why it worked for me; and, how to maybe fix the problem.
I had built the template cb project and codeblocks remember the address custom variable from it.

Project -> Build Options
Select top level project in left pane
Click on Tab "Custom Variables"
Click on add
Enter address in key box
Enter 80000400 in value box
Click on OKs

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Authentic

  • Single posting newcomer
  • *
  • Posts: 4
Re: Strange Syntax Error Using MIPS Compiler
« Reply #8 on: October 21, 2017, 01:29:50 am »
It compiles now, no warnings or errors! Thank you so much!