Posted July 21, 200817 yr I'm not incredibly new to this website, I've been browsing it for a long time and I finally made an account to attempt to get some help. Could anyone please help me with this error I'm getting? I've searched for hours and I've found nothing useful. This is from the warpzone.net C++ Dev tutorials. This is the code exactly as it is shown in the tutorial (minus the commented line).#include <cstdlib>#include <iostream>#include <windows.h>using namespace std;int main(int argc, char *argv[]){ char ourstring[50] = "This is a self writing text =)"; int len = strlen(ourstring); for(int i = 0; i < len; i++) { cout << ourstring; Sleep(100); } cout << "\n"; system("PAUSE"); return EXIT_SUCCESS;}When I compile/run i get this error: [Linker error] undefined reference to `__cpu_features_init' ld returned 1 exit status The only useful thing I've found was someone mention I should reinstall Mingw. I've attempted this and still no results, same error. Can anyone help me out? Or does anyone know where I can find steps on how to completely remove any compiler I had and reinstall Mingw? I simply can't get bloodshed or visual studio to work with what I know to be functioning code. If anyone could please message me or post with a reply I'd be incredibly grateful. I just want to learn to program in C/C++ and this problem has been with me for several weeks and it's turning me away from learning the language.-G34rH34d
July 21, 200817 yr Try setting evironment variables:right click "my computer" -> "properties" -> "advanced" -> "evironment variables"edit or add two new variables:LIBRARY_PATH: "C:\Dev-Cpp\lib;C:\Dev-Cpp\mingw32\lib"C_INCLUDE_PATH: "C:\Dev-Cpp\include"
July 22, 200817 yr Author Thank you alaphate! Your instructions made my programming a success, I can now successfully learn C++. I did not try the other things that GaBoR mentioned, but thank you as well.I figured it had something to do with environment variables, but I just didn't think to search for that specifically, nor did I find anything of any particular use/help online. You saved me hours of grief alaphate... thank you again.
July 22, 200817 yr Thank you alaphate! Your instructions made my programming a success, I can now successfully learn C++. I did not try the other things that GaBoR mentioned, but thank you as well.I figured it had something to do with environment variables, but I just didn't think to search for that specifically, nor did I find anything of any particular use/help online. You saved me hours of grief alaphate... thank you again.嘻嘻,楼上的是C++新手,鉴定完毕.Hehe,My upstairs is a C++ newlywed person.
July 23, 200817 yr Just wondering#include <cstdlib> <--- these should not be <cstlib.h> and <iostream.h> ?#include <iostream> <---#include <windows.h>I have not used Dev cpp much, but as far as I knw it automatically sets the environment variables acc to ur installation path. Anyhow, as the problem is solved, this doesnt matter much.
August 11, 200817 yr Author I don't know what they should be, I am a beginner to C++... should they be cstlib.h and iostream.h? What are either of those headers and what do they do?
August 11, 200817 yr I think u should find some books about C++ and start learning it instead of asking these things.
August 15, 200817 yr iostream is c++ standard header fileit has no file extension name such as .hiostream is like iostream.h, it's a text file.iostream.h is none-standard header fileif you use visual c++, you can use iostream.hif you use #include <iostream>you'd better add a line:using namespace std;or you have to add std to all command like below:std::cout<<"hello world"<<std::endl;if you use none-standard header file iostream.hyou won't need: using namespace std;e.g.#include <iostream.h>void main(){ cout<<"hello world"<<endl;} Edited August 15, 200817 yr by alaphate
August 15, 200817 yr gearhead,The code you present is fine, as are all of the include files referenced. I've just re-installed DevCpp as I had a faint recollection of the same issue.As it turns out, you need to add some updated files to DevCpp.Just follow these two steps (assuming default folder locations):1) Copy the 4 folders inside the zip file to C:\Dev-Cpp\mingw322) Copy the files inside the zipped lib folder to C:\Dev-Cpp\libNow try to compile and run and you should get the classic 'typewriter effect'With that said - you will Code::Blocks to be a far more capable IDE. It also uses MinGw, but can use pretty much any other compiler you can think of. It's open-source, CROSS-PLATFORM & updated quite often. Get it here: http://www.codeblocks.org/downloadsOh, and you'll probably get some mileage out of ResEdit: http://www.resedit.net/minGw_runtime_3.13.zip
Create an account or sign in to comment