So I am using Dev C++ to compile this program; however, whenever I attempt to compile, I recieve a linker error that states,
"[Linker error] undefined reference to '_cpu_features_init'
ld returned 1 exit status"

I googled the question, and people suggested that it may have something to do with the directory location of my source code; however, its all located right on my desktop.

Any help would be greatly appreciated.
The code is below.

#include <iostream>
using namespace std;

void GetInput(int board[9][9], bool boardstatus[9][9]);
void BruteForce(int board[9][9], bool boardstatus[9][9]);
bool CheckSolution(int board[9][9], int row, int column);

int main()
{
    int board[9][9];
    bool boardstatus[9][9];
    for (int i=0; i<=8; i++)  // rows
    {
        for (int j=0; j<=8; j++)  // columns
        {
            board[i][j] = 0;
        }
    }
    GetInput(board, boardstatus);  // is this allowed?
    BruteForce(board, boardstatus); 
    return 0;
}
void GetInput(int board[9][9], bool boardstatus[9][9])
{
     int row, column, value;
     bool status;
     cout << "Input the row, column and value, respectively.";
     cin >> row;
     cin >> column;
     cin >> value;
     board [row][column] = value;
     boardstatus [row][column] = true;
     cout << "Are all the values entered?"  << "respond y if true, and n if false";
     cin >> status;
     if (status == 'y')
     {
        GetInput(board, boardstatus);
     }
}
void BruteForce (int board[9][9], bool boardstatus[9][9])
{
    int row = 8, column = 8;
    bool answer;
    answer = CheckSolution(board, row, column);
    if (boardstatus [row][column] == false && answer == false)
    {
       board [row][column] = board [row][column] + 1;
    }
    column = column - 1;
    if (column < 0)
    {
       row = row - 1;
       column = 8;
    }
    BruteForce (board, boardstatus);
}
bool CheckSolution(int board[9][9], int row, int column)
{
	for(int i = 0; i < 9; i++)
		if((i != row && board[row][column] == board[i][column]) || (i != column && board[row][column] == board[row][i]))
			return false;
	
	for(int x = column % 3; x < (column % 3) + 3; x++)
		for(int y = row % 3; y < (row % 3) + 3; y++)
			if(x != column && y != row && board[row][column] == board[y][x])
				return false;
	return true;
}

Recommended Answers

All 4 Replies

I compiled/linked your program without any warnings or errors. Maybe you need to move the source code to a folder whose name does not contain any spaces, such as c:\dev-cpp\source

Thank you for the advice.

I tried making said folder and placing my source code in it, but the program still did not link.

what version of MS-Windows is on your computer ?

compiles fine for me also. Do you have more than 1 gcc compiler installed on your computer? There may be a possibility of them interfering with each other.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.