Answer the question
In order to leave comments, you need to log in
How to fix collect2.exe: error: ld returned 1 exit status?
#include <iostream>
#include <ctime>
#include <omp.h>
#include <stdlib.h>
#include "stdio.h"
using namespace std;
const int MAX_RAND = 100;
int **OutMass(int N){
int **Mas = new int*[N];
for (int i = 0; i < N; i++)
Mas[i] = new int[N];
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
Mas[i][j]=rand();
return Mas;
}
int main(int argc, char* argv[])
{
srand(time(NULL));
omp_set_num_threads(4);
int N = argc != 0 ? atol(argv[1]) : 10;
int **A = OutMass(N);
int **B = OutMass(N);
int **C = new int*[N];
for (int i = 0; i < N; i++)
C[i] = new int[N];
double t1 = omp_get_wtime();
#pragma omp parallel for
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
C[i][j] = 0;
for (int k = 0; k < N; ++k)
C[i][j] += A[i][k] * B[k][j];
}
}
double t2 = omp_get_wtime();
printf("Execution time : %.5f s\n", t2 - t1);
printf("Timer resolution : %.5f s\n", omp_get_wtick());
return 0;
}
Answer the question
In order to leave comments, you need to log in
On a rather old version of mingw that I had, it turned out to be done like this - by running the compiler and the linker separately.
PATH %PATH%;d:\MinGW\x86\bin
g++ -fopenmp -c main.cpp -o main.o
g++ -o test.exe main.o -lgomp
pause
PATH %PATH%;d:\MinGW\i686-5.2.0-win32-dwarf-rt_v4-rev0\mingw32\bin\
g++ -fopenmp main.cpp -o test.exe
pause
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question