Amiga.org

Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: EDanaII on January 08, 2012, 04:42:07 AM

Title: Eclipse, Cross Compiling and Makefile Generation
Post by: EDanaII on January 08, 2012, 04:42:07 AM
So close, so close...

So, I've actually got Eclipse crosscompiling and generating Amiga makefiles. However, at present, I'm getting these errors:
Code: [Select]
'Building file: ../Hello.cpp'
'Invoking: Cross G++ Compiler'
m68k-amigaos-g++ -DAMIGA -IP:/Windows/AmiDevCpp/usr/local/amiga/m68k-amigaos/sys-include -IP:\Windows\AmiDevCpp\include\c++\3.4.2\backward -O0 -g3 -Wall -noixemul -MMD -MP -MF"Hello.d" -MT"Hello.d" -o "Hello.o" "../Hello.cpp"
/usr/local/amiga/lib/gcc/m68k-amigaos/3.4.0/../../../../m68k-amigaos/lib/libstdc++.a(misc-inst.o)(.text+0xfe):misc-inst.o: undefined reference to `_getc'
/usr/local/amiga/lib/gcc/m68k-amigaos/3.4.0/../../../../m68k-amigaos/lib/libstdc++.a(misc-inst.o)(.text+0x128):misc-inst.o: undefined reference to `_getc'
/usr/local/amiga/lib/gcc/m68k-amigaos/3.4.0/../../../../m68k-amigaos/lib/libstdc++.a(misc-inst.o)(.text+0x1cc):misc-inst.o: undefined reference to `_putc'
/usr/local/amiga/lib/gcc/m68k-amigaos/3.4.0/../../../../m68k-amigaos/lib/libstdc++.a(basic_file.o)(.text+0x1c4):basic_file.o: undefined reference to `_fdopen'
collect2: ld returned 1 exit status
make: *** [Hello.o] Error 1


Any ideas?
Title: Re: Eclipse, Cross Compiling and Makefile Generation
Post by: Heinz on January 08, 2012, 10:40:23 AM
Quote from: EDanaII;674833
So close, so close...

So, I've actually got Eclipse crosscompiling and generating Amiga makefiles. However, at present, I'm getting these errors:
Code: [Select]
'Building file: ../Hello.cpp'
'Invoking: Cross G++ Compiler'
m68k-amigaos-g++ -DAMIGA -IP:/Windows/AmiDevCpp/usr/local/amiga/m68k-amigaos/sys-include -IP:\Windows\AmiDevCpp\include\c++\3.4.2\backward -O0 -g3 -Wall -noixemul -MMD -MP -MF"Hello.d" -MT"Hello.d" -o "Hello.o" "../Hello.cpp"
/usr/local/amiga/lib/gcc/m68k-amigaos/3.4.0/../../../../m68k-amigaos/lib/libstdc++.a(misc-inst.o)(.text+0xfe):misc-inst.o: undefined reference to `_getc'
/usr/local/amiga/lib/gcc/m68k-amigaos/3.4.0/../../../../m68k-amigaos/lib/libstdc++.a(misc-inst.o)(.text+0x128):misc-inst.o: undefined reference to `_getc'
/usr/local/amiga/lib/gcc/m68k-amigaos/3.4.0/../../../../m68k-amigaos/lib/libstdc++.a(misc-inst.o)(.text+0x1cc):misc-inst.o: undefined reference to `_putc'
/usr/local/amiga/lib/gcc/m68k-amigaos/3.4.0/../../../../m68k-amigaos/lib/libstdc++.a(basic_file.o)(.text+0x1c4):basic_file.o: undefined reference to `_fdopen'
collect2: ld returned 1 exit status
make: *** [Hello.o] Error 1


Any ideas?


Yes. Look at ld`s output.
It is looking for the libraries at the wrong place.
You need to add something like: -L /path/to/your/libs to the g++ call.
Title: Re: Eclipse, Cross Compiling and Makefile Generation
Post by: NovaCoder on January 08, 2012, 10:48:16 AM
Let me know if you ever get it working well, I've always wanted to use eclipse (on Windows) to generate 68k code.
Title: Re: Eclipse, Cross Compiling and Makefile Generation
Post by: EDanaII on January 08, 2012, 04:37:14 PM
Well, I succeeded in figuring out how to get Eclipse to create an Amiga project including automatic generation of Makefiles. And it wasn't as difficult as I thought, I just needed the time to figure it out.

Prerequisites:
1. Eclipse (http://eclipse.org/) and the CDT/ (http://eclipse.org/cdt/), obviously. :)
2a. ZeroHero's Cross Compiler (http://zerohero.se/) tools.
2b. Alternatively AmiDevCpp (http://amidevcpp.amiga-world.de/index.php?HR_LANG=english). I used this as I already had AmiDevCpp set up on my computer.

Steps are as follows:

You are now free to add a Source file to your project. I used this one:
Code: [Select]
#include <iostream>

using namespace std;

int main (int argc, char *argv[])
{
  cout << &quot;Hello Nerd!&quot; << endl;
  cin.get();

  return 0;
}


If you try this, some things to be aware of: Initially, when I tried this, the source code, above, showed errors like not being able to find iostream and/or cout or cin. I tweaked this by for example, turning discovery options on, which caused the problem with my first post in this thread, and then back off, which seemed to allow everything to work perfectly.

So, if you try this and encounter anything different, please report back here so I can continue to refine this.

Up next: try some (slightly) more complex objects.
Title: Re: Eclipse, Cross Compiling and Makefile Generation
Post by: EDanaII on January 08, 2012, 06:00:29 PM
This is turning out to be surprisingly painless. By following the above steps but pointing to an existing project (with C++ classes in it) and omitting the Hello.cpp file, Eclipse discovered everything and made the project with only minor issues. Everything compiled and works, the only issues were code detection. One file, for example, claimed that the header declarations for some methods (involving the string object in the header) were missing, despite everything compiling just fine. Deleting the project and then re-creating it cleared this problem and everything seems to work flawlessly... so far. :)

Kudos to Eclipse for making it this smart.
Title: Re: Eclipse, Cross Compiling and Makefile Generation
Post by: NovaCoder on January 08, 2012, 10:09:29 PM
Thanks, I'll follow your little guide and see how I get on :)
Title: Re: Eclipse, Cross Compiling and Makefile Generation
Post by: NovaCoder on November 14, 2012, 02:41:43 AM
I finally got around to trying this again and just got it working :)

I was trying to use it with a clean Cygwin install + Zero's cross-compiler but couldn't get anywhere with it after a few tries.

I then tried it with AmiDevcpp's cross-compiler setup and that works fine so far (maybe you need mingw32).

Very nice so far, I think this is best solution for building AmigaOS C/C++ on win32.
Title: Re: Eclipse, Cross Compiling and Makefile Generation
Post by: EDanaII on November 14, 2012, 04:23:38 AM
Glad to hear it's workin' out for ya. :)

Since I started using Eclipse for my Amiga tinkering, I've been able to accomplish a lot more than I ever have before. A modern IDE really is a blessing.

I've also tried to use Visual Studio to do the same thing, since VS is slightly better than Eclipse, but so far no luck with makefile generation.

If you had to do anything different than my guide suggested, please feel free to post it here. Maybe others can learn for our adventures. ;)