-
Notifications
You must be signed in to change notification settings - Fork 51
Description
2018-19880
예시로 올려주신 코드를 실행해보려 하였으나,
구글 독스에 알려주신 것과 같이 cpp을 터미널에서 실행시킬 경우, 함수들을 찾지 못하여
Undefined symbols for architecture x86_64: "clearMemory()", referenced from: _main in hw3-2e04a0.o "readDataGraph(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from: _main in hw3-2e04a0.o "readQueryGraph(std::__1::basic_ifstream<char, std::__1::char_traits<char> >&, int)", referenced from: _main in hw3-2e04a0.o "buildDAG()", referenced from: _main in hw3-2e04a0.o "_numQueryNode", referenced from: _main in hw3-2e04a0.o ld: symbol(s) not found for architecture x86_64
와 같은 에러메세지를 띄웁니다.
제가 검색하여 해결방법을 찾은 결과, header파일에는 각 함수에 대한 이름만 있어 실제로 함수가 구현된 cpp파일도 같이 컴파일 해주어야 한다는 것을 알게 되었습니다.
그래서 터미널에서
g++ -std=c++11 -o hw3 hw3.cpp
대신
g++ -std=c++11 -o hw3 dag.cpp hw3.cpp 을 이용할 경우 에러 없이 잘 컴파일 되는 것을 확인할 수 있었습니다.
그렇다면, 조교님이 채점하실 때에는 구글 독스에 있는 대로 컴파일을 하시는 건지,
아니면 g++ -std=c++11 -o hw3 dag.cpp hw3.cpp를 이용하여 채점하실지 궁금합니다.