Apologies, I understand questions very similar to this have been asked relatively often, although none of the solutions seem to work for me.When attempting to run any c++ code of a reasonable complexity, I get the above error. The full error message is:
/main: relocation error: ./main: symbol _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference
running another project, I get a very similar error:
./main: relocation error: ./main: symbol _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference
I don't actually have any problem with compilation, as these projects both compile fine. This just happens when I try to run the executable. I thought it was an error with my gcc install, so today I reinstalled it, although that did not help at all. I don't really know what to do to fix this, can anyone offer assistance?
This is the Makefile I'm using to compile one of the projects, I feel this is where the error could be:
CC= g++
CFLAGS= -Wall -g -std=c++11 -lX11 -lpthread
OBJS = main.o Board_Tile.o Sliding_Solver.o
main: $(OBJS)
$(CC) -o $@ $(OBJS)
%.o : %.cc
$(CC) $(CFLAGS) -c $^
My gcc version is 5.3.0, I'm running Ubuntu 14.0.4.
LD_LIBRARY_PATH=/usr/local/lib ./main
instead of just./main
? – Langlois