Sublimetext 3 c++ compilation error "undefined reference to class::constructor() -
i have problem sublimetext 3 , undefined reference class constructor. think problem linking.
i've got main.cpp, student.cpp , student.h.
code simple now
main.cpp:
#include "student.h" int main(int argc, char const *argv[]) { student student1; return 0; }
student.h:
#ifndef _s #define _s #include <iostream> using namespace std; class student { public: student(); ~student(); }; #endif
end student.cpp
#include "student.h" student::student() {} student::~student(){}
any suggestion packages have install or change?
i grateful help
maria
edit:
thank answers! resolve problem making makefile. had install gnuwin, 'make' work, on sublime i've choosen buildsystem - > make , how makefile looks like:
new=5.1 new2 = student komp=g++ flags= -std=c++11 -wall -g $(new):$(new).o $(new2).o $(komp) $(flags) $^ -o $@ $(new).o:$(new).cpp $(komp) -c $(flags) $^ -o $@ $(new2).o:$(new2).cpp $(new2).h $(komp) -c $(flags) $^ clean: rm -f *.o *.gch $(new) run: $(new) ./$(new) valgrind: $(new) valgrind -v ./$(new) gdb: $(new) gdb ./$(new)
after have install packageresourceviewer add there variants "run" , other (remember add , after every {} in "variants")
hope post :)
the error originated linker because can not see definition of constructor located. in sublime text 3 there build system "logic" makefile. (tools -> build system) example test cpp build system windows somethink :
{ "shell_cmd": "\"%vs120comntools%\\..\\..\\vc\\vcvarsall.bat\" amd64 && cl /nologo \"$file\"", "file_regex": "^(.*?)\\(([0-9+])(?:,([0-9+]))?\\)\\s+:\\s+(.*)$", "working_dir": "${file_path}", "selector": "source.c, source.c++" }
try create "build system" fits needs , build source code.
Comments
Post a Comment