title: Linking C++ code with 'gcc' (without g++)
body: <p>Hi all: quick question: I'm in a situation where it would be useful to generate my C++ executable using only 'gcc' (without g++). Reason for this is that I have to submit the code to an automatic submission server which doesn't recognize the 'g++' (or 'c++', for that matter) command.</p>
  
  <p>In my experiments, while I'm <strong>compiling</strong> gcc works well. Problem is, when I try to link the generated object files it gets messed up. Now, based on what I understood from the gcc man page (I may be way off, so tell me if I am), g++ is basically gcc, but it links the C++ library.</p>
  
  <p>If this is true, how can I (if possible) explicitly link the C++ library <strong>without</strong> using the g++ (or c++) command?</p>
  
  <p><strong>EDIT:</strong> I'm adding the makefile to better illustrate the problem:</p>
  
  <pre><code>COMPILER = gcc
  CFLAGS = -Wall -g -x c++
  
  # MODULE COMPILATION
  model: modules/model.h modules/sources/model.cpp
      $(COMPILER) $(CFLAGS) -c modules/sources/model.cpp -o obj/model.o
  
  algorithms: modules/algorithms.h modules/sources/algorithms.cpp
      $(COMPILER) $(CFLAGS) -c modules/sources/algorithms.cpp -o obj/algorithms.o
  
  io: modules/io.h modules/sources/io.cpp
      $(COMPILER) $(CFLAGS) -c modules/sources/io.cpp -o obj/io.o
  
  stopwatch: modules/stopwatch.h modules/sources/stopwatch.cpp
      $(COMPILER) $(CFLAGS) -c modules/sources/stopwatch.cpp -o obj/stopwatch.o
  
  # EXECUTABLE GENERATION
  exe: model algorithms io stopwatch
      $(COMPILER) $(CFLAGS) main.cpp obj/model.o obj/algorithms.o obj/io.o obj/stopwatch.o -o bin/process
  
  # DEFAULT TEST CASE
  run: exe
      ./bin/process -i data/nasa_small.log -a data/nasa_small.access -s data/nasa_small.stack
  
  # CLEANING ROUTINE
  clean:
      rm -f obj/*
  </code></pre>