Я установил библиотеку линейной алгебры Armadillo, чтобы выполнять некоторые матричные операции в ОС Linux Mint. но моя проблема в том, что я не могу скомпилировать и выполнить свой код на С++ с помощью makefile:
мой make-файл выглядит следующим образом:
CC=g++
all: file_1.o main.o
$(CC) -o EXCUTE_ALL file_1.o main.o
main.o: main.cpp file_1.h
$(CC) -c main.cpp
file_1.o: file_1.h
$(CC) -c file_1.cpp
#running
run :
./EXCUTE_ALL
.PHONY: clean
clean:
rm -f *.o
rm -f EXCUTE_ALL
файл_1.cpp:
#include <iostream>
#include <stdio.h>
#include "armadillo"
#include "file_1.h"
using namespace std;
using namespace arma;
mat myclass::product(mat my_matrix)
{
mat product=my_matrix * my_matrix;
return product;
}
файл_1.h это:
#include <iostream>
#include <stdio.h>
#include "armadillo"
using namespace std;
using namespace arma;
class myclass{
public:
mat product(mat matrixAA);
};
Main.cpp:
#include <iostream>
#include <stdio.h>
#include "armadillo"
#include "file_1.h"
using namespace std;
using namespace arma;
int main()
{
myclass matfile;
mat BB;
mat AA=randu<mat>(500,500);
BB=matfile.product(AA);
return 0;
}
и получите следующую ошибку:
file_1.o: In function `void arma::blas::gemv<double>(char const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)':
file_1.cpp:(.text._ZN4arma4blas4gemvIdEEvPKcPKiS5_PKT_S8_S5_S8_S5_S8_PS6_S5_[void arma::blas::gemv<double>(char const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)]+0x53): undefined reference to `wrapper_dgemv_'
file_1.o: In function `void arma::blas::gemm<double>(char const*, char const*, int const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)':
file_1.cpp:(.text._ZN4arma4blas4gemmIdEEvPKcS3_PKiS5_S5_PKT_S8_S5_S8_S5_S8_PS6_S5_[void arma::blas::gemm<double>(char const*, char const*, int const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)]+0x61): undefined reference to `wrapper_dgemm_'
collect2: ld returned 1 exit status
make: *** [all] Error 1
Но это работает без make-файла, используя следующую команду:
`g++ -o obj Main.cpp file_1.cpp -l armadillo`.
может ли кто-нибудь помочь мне, пожалуйста, если я что-то пропустил в моем make-файле. Благодарность..