[英]C++ Eclipse g++: error: ./Matrix.o: No such file or directory make: *** [MatrixSample] Error 1
I am trying to make a program that can manipulate matrixes and I am getting that error in Eclipse on Ubuntu 14.04. 我正在尝试制作一个可以处理矩阵的程序,并且在Ubuntu 14.04上的Eclipse中遇到该错误。 I searched on google and on stack over flow, but I did not find anything that I could understand and I am stuck.
我在Google和堆栈上进行了搜索,但没有找到我所能理解的东西,因此被卡住了。 May anybody help me out with this please?
有人可以帮我吗?
The complete error message: 完整的错误消息:
14:29:27 **** Incremental Build of configuration Debug for project MatrixSample ****
make all
Building file: ../Matrix.inl
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Matrix.d" -MT"Matrix.d" -o "Matrix.o" "../Matrix.inl"
g++: warning: ../Matrix.inl: linker input file unused because linking not done
Finished building: ../Matrix.inl
Building target: MatrixSample
Invoking: GCC C++ Linker
g++ -o "MatrixSample" ./Main.o ./Matrix.o
g++: error: ./Matrix.o: No such file or directory
make: *** [MatrixSample] Error 1
Here is the code: 这是代码:
/*
* Main.cpp
*/
#include "Matrix.hpp"
int main()
{
Matrix<int> firstMatrix();
return 0;
}
/*
* Matrix.hpp
*
*/
#ifndef MATRIX_H_
#define MATRIX_H_
template <typename T>
class Matrix
{
public:
Matrix();
private:
int nbrRows;
int nbrColumns;
};
#include "Matrix.inl"
#endif /* MATRIX_H_ */
/*
* Matrix.inl
*/
template <typename T>
Matrix<T>::Matrix()
:nbrRows(0), nbrColumns(0){}
I found what the problem was. 我发现了问题所在。 I added .inl files as C++ Source file instead of adding it to C++ Header file.
我将.inl文件添加为C ++源文件,而不是将其添加到C ++头文件中。 Now it's working fine.
现在一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.