Linking C++ programs with GCC
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Minuous
    Posts: 143 from 2010/2/13
    I'm using this script:

    gcc -noixemul -x c++ -O1 -o amiga.o -c amiga.c -I../source/
    gcc -noixemul -x c++ -O1 -o ahi.o -c ahi.c -I../source/
    gcc -noixemul -x c++ -O1 -o unzip.o -c unzip.c -I../source/
    gcc -noixemul -x c++ -O1 -o cart.o -c cart.cpp -I../source/
    gcc -noixemul -x c++ -O1 -o handy.o -c handy.cpp -I../source/
    gcc -noixemul -x c++ -O1 -o system.o -c system.cpp -I../source/
    gcc -noixemul -x c++ -O1 -o susie.o -c susie.cpp -I../source/
    gcc -noixemul -x c++ -O1 -o rom.o -c rom.cpp -I../source/
    gcc -noixemul -x c++ -O1 -o ram.o -c ram.cpp -I../source/
    gcc -noixemul -x c++ -O1 -o mikie.o -c mikie.cpp -I../source/
    gcc -noixemul -x c++ -O1 -o memmap.o -c memmap.cpp -I../source/
    gcc -noixemul -o ../Handy amiga.o ahi.o unzip.o cart.o handy.o system.o susie.o rom.o ram.o mikie.o memmap.o

    and I keep getting these kinds of errors when linking:

    undefined reference to 'ios virtual table'
    undefined reference to 'strstreambase::ios virtual table'
    undefined reference to 'streambuf::streambuf(int)'
    undefined reference to 'strstreambuf virtual table'
    etc...

    This source code compiles and links fine with StormC in GCC mode, and I can compile and link C programs with GCC without problems.

    Is there another file I should be linking with, if so, what? Thanks.
  • »05.08.12 - 03:09
    Profile Visit Website
  • MorphOS Developer
    Krashan
    Posts: 1107 from 2003/6/11
    From: Białystok...
    I suggest to use "g++" invocation of the compiler at linking stage.

    [ Edited by Krashan 05.08.2012 - 06:46 ]
  • »05.08.12 - 07:46
    Profile Visit Website
  • Fab
  • MorphOS Developer
    Fab
    Posts: 1329 from 2003/6/16
    g++ indeed, or link with -lstdc++ at the end.

    [ Edited by Fab 06.08.2012 - 00:44 ]
  • »05.08.12 - 10:18
    Profile Visit Website
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Minuous
    Posts: 143 from 2010/2/13
    Great, that has fixed the issue. Many thanks.
  • »06.08.12 - 00:34
    Profile Visit Website