jeudi 24 septembre 2020

compiling c++ with g++ from -c to -std=c++11

When I run my code for these files with g++ -c I don't get any errors, but when I run it with g++ -std=c++11 I am getting a linker error. I am assuming that means that the error isn't in the code of the files, but in the makefile. How can I fix this?

parse: parse.o scan.o
    g++ -std=c++11 -Wall parse.o scan.o -o parse
    #g++ -o parse parse.o scan.o

clean:
    rm -f parse.o parse

parse.o: scanpp.h parse.cpp 
    #g++ -c parse.cpp
    g++ -std=c++11 parse.cpp

scan.o: scanpp.h scan.cpp 
    #g++ -c scan.cpp
    g++ -std=c++11 scan.cpp

Here is the error I get when I run make

#g++ -c parse.cpp
g++ -std=c++11 parse.cpp
Undefined symbols for architecture x86_64:
  "scan()", referenced from:
      match(token) in parse-405e06.o
      _main in parse-405e06.o
  "_token_image", referenced from:
      match(token) in parse-405e06.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [parse.o] Error 1

Aucun commentaire:

Enregistrer un commentaire