C++ template file does not compile

Viewed 81

I am creating a C++ program that makes use of templates, but when I try to build my project my CLI returns this error.

C:\...\bin>g++ ../src/main.cpp ../src/lib/* -o main
../src/lib/Row.tpp: file not recognized: file format not recognized
collect2.exe: error: ld returned 1 exit status

Are any general issues that may cause this?

1 Answers

g++ applies an heuristic based on the extension to know what to do with given files: compile it (and with which compiler C, C++, Ada, ...), pass it to the linker, ... The default is passing it to the linker. .tpp is not a recognized extension and thus ../src/lib/Row.tpp is passed to the linker which does not recognize the file format.

The root cause is probably the subject of this question.

Related