Hi, as the forum indicates I'm only just beginning to understand the depths of the gulf that is my ignorance on this subject (C++) and have stumbled across this error on my first attempt to code: [Linker error] undefined reference to `__cpu_features_init'
#include <iostream>
usingnamespace std;
int main()
{
int skill[10], stat[7], statXP[7], advLevel=0, target;
for ( target=0 ; target<7 ; ++target ) stat[target]=0;//stat initalisation to 0
for ( target=0 ; target<10 ; ++target ) skill[target]=0;//skill initalised to 0
again://goto target
cout << "Which skill do you wish to increase? (1-5)";
cout << "enter 20 to finish";
cin >> target;
if (target>0&&target<11)
{
skill[target-1]++;
switch (target)
{
case 1:
statXP[5]+=4, statXP[3]+=2;
if (statXP[5]=advLevel)
{
stat[5]++;
statXP[5]=0;
cout << "Agility Increase";
}
if (statXP[3]=advLevel)
{
stat[3]++;
statXP[3]=0;
cout << "Strength Increase";
}
break;
}
//advLevel updated
for ( target=0 ; target<7 ; target++ )
{
advLevel += stat[target];
}
for ( target=0 ; target<10 ; target++ )
{
advLevel += skill[target];
}
cout << "You are now level";
cout << advLevel;
cout << "\n With stats of:\n";
for (int target=0; target<7; target++) cout << stat[target] << " ";
cout << "\n";
goto again;
}
return 0;
}
The switches have been abbreviated to save space, there are 5 of them all the same until I get at least this working.
I am using Dev-C++ as my compiler, and would greatly appreciate any advice on this error, please? :D
Well I've made the modifications you have suggested (thanks for those) but am still getting the same error message. (buggerit)
UPDATE:
Just on a hunch I copy/paste this from the tutorials & tried to compile it
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// i/o example
#include <iostream>
usingnamespace std;
int main ()
{
int i;
cout << "Please enter an integer value: ";
cin >> i;
cout << "The value you entered is " << i;
cout << " and its double is " << i*2 << ".\n";
return 0;
}
It failed with the same error.
Any ideas on just how difficult this will be to fix?
I googled your error and it sounds about what I thought: you have library clashes somewhere. Do you have more than one copy of MinGW installed? (The Dev-C++ IDE installs its own copy.)
Either delete the extra copy or make sure that when the Dev IDE runs that only Dev's MinGW lib/ directory is in the PATH variable.
Does this help?
@averageGuy: careful there. <iostream> is the standard C++ header. Anything else is pre-standard.
This site has a top-notch reference that will list all the ISO C++ standard includes and functions and classes etc. with the correct includes. The .h was deprecated, and <stdio.h> became <cstdio>, etc.
Newer compilers tend to put-up with older stuff, but since there wasn't a fixed standard for the older stuff, it is unreliable.