Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

undefined reference to 'omp_get_wtime'

0 votes
asked Nov 17, 2018 by Олександр Ломако (230 points)
Hello everybody! Help solve the problem, do not compile an error program "undefined reference to 'omp_get_wtime'". Here is the program code:

#include <iostream>

#include <stdlib.h>

#include <stdio.h>

#include <time.h>

#include <omp.h>

//#include <intrin.h>

//#include <timetest.h>

using namespace std;

main(){

int arr[500],arr1[500];

srand(time(NULL));

cout<<"------Array_A-------------------------------------------------------------------------------------------------------\n";

for(int i=0; i<50; i++ ){

arr[i]=rand()%100;

cout<<arr[i]<<"\t";

}

cout<<"\n------Array_B-------------------------------------------------------------------------------------------------------\n";

for(int i=0; i<50; i++ ){

arr1[i]=rand()%100;

cout<<arr1[i]<<"\t";

}

cout<<"\n=============Linear_search==========================================================================================";

cout<<"\n------Elements_of_the_first_array,_absent_in_the_second-------------------------------------------------------------\n";

clock_t t;

t=clock();

const int n=50, m=50;

int h,u,r;

for(h=0; h<n; h++){

for(u=0; u<m; u++){

if(arr[h]==arr1[u]){

r=1;

}

}

if(r==0){

cout<<arr[h]<<"\t";

r=0;

}

}

t=clock()-t;

cout<<"\nTime: "<<((float)t)/CLOCKS_PER_SEC<<" seconds";

cout<<"\n===================================================================================================================="

<<"\n---------=Sort_array_A=---------------------------------------------------------------------------------------------\n";

for(int k=0; k<50; k++){

for(int g=0; g<49; g++){

if(arr[g]>arr[g+1]){

int temp=arr[g];

arr[g]=arr[g+1];

arr[g+1]=temp;

}

}

}

for(int g=0; g<50; g++){

cout<<arr[g]<<"\t";

}

cout<<"\n---------=Sort_array_B=---------------------------------------------------------------------------------------------\n";

for(int k=0; k<50; k++){

for(int g=0; g<49; g++){

if(arr1[g]>arr1[g+1]){

int temp1=arr1[g];

arr1[g]=arr1[g+1];

arr1[g+1]=temp1;

}

}

}

for(int g=0; g<50; g++){

cout<<arr1[g]<<"\t";

}

cout<<"\n=============Binary_search==========================================================================================";

cout<<"\n------Elements_of_the_first_array,_absent_in_the_second-------------------------------------------------------------\n";

// long t_time;

// t_time=clock();

double stt, fnt;

int midd=0, left=0, right=49;

stt=omp_get_wtime();

for(int p=0; p<50; p++){

while(1){

midd=(left+right)/2;

if(arr[p]<arr[midd]){

right=midd-1;

}else if(arr[p]>arr[midd]){

left=midd+1;

}else return -1;

if(left>right){

return midd;

}cout<<arr[midd]<<"\t";

}

}

fnt=omp_get_wtime();

cout<<"\nTime: "<<fnt-stt<<" seconds";

// t_time=clock()-t_time;

// cout<<"\nTime: "<<t_time/CLOCKS_PER_SEC<<" seconds";

}

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...