c++ - How to fix error "clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)"? -


when compiling c++ program containing main.cpp, pattern.cpp, , pattern.h (a header file containing 2 function declarations no class; functions defined in pattern.cpp , main.cpp contains #include "pattern.h" @ top) typing:

clang++ main.cpp 

error message was:

/tmp/cc-nrpup0.o: in function `main': main.cpp:(.text+0x69): undefined reference `pattern(int, int)' collect2: ld returned 1 exit status clang: error: linker (via gcc) command failed exit code 1 (use -v see invocation) 

how fix this? tried typing -v clang output had terminated , invalid command

it looks compiled main.cpp not pattern.cpp. when came time link executable together, functions defined in pattern.cpp won't found. undefined reference indicates main.cpp using pattern(int, int) somewhere. can see why becomes problem if pattern.cpp never compiled in.

try compiling with:

clang++ -wall -pedantic main.cpp pattern.cpp -o main 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -