Linker error

I am trying to run a simple "Hello World" program. I am running Windows 7, Dev C++ ver 4.9.9.2.
My programs is:

[code]
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{


cout << "Hello World" <<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
[\code]

I received the following errors:
[Linker error] undefined reference to `__dyn_tls_init_callback'
[Linker error] undefined reference to `__cpu_features_init'
ld returned 1 exit status

Any help would be greatly appreciated!
Thanks
Mike
Probably has something to do with the system("PAUSE"); call. AFAIK, this is not portable and may not work on your system. I would recommend just replacing it with a cin.get() and press return to continue the program as is recommended on this page:

http://www.gidnetwork.com/b-61.html
Uninstall Dev-C++ and make sure the folder you installed it to is completely gone.
Then install the Code::Blocks/MinGW bundle.
I replaced pause with cin.get and still received the same linker errors.
system itself is portable in the sense that the function is part of the C++ standard library, so it would certainly not lead to a linker error.
Dev-C++ is horribly outdated, so you should not use it.
Last edited on
system() may be portable, but "pause" isn't portable.

but yeah it's not going to cause a linker error in any case.
Well, if it is not the PAUSE being undefined, then it is probably your environment is not set up properly in some manner. I work on Linux and am currently using a mac at home so I can't offer any advice for windows stuff. The only environment I have used on windows is cygwin, without any ide. On my mac, your above code compiles and links fine with g++, but issues an error at runtime for the PAUSE command.

[Linker error] undefined reference to `__dyn_tls_init_callback'
[Linker error] undefined reference to `__cpu_features_init'
> Dev-C++ is horribly outdated, so you should not use it.

It looks like Dev-C++ 5 contains GCC 3.4.2. My mac with OS 10.5.8 seems to have 4.0.1 and the newest release looks like it is 4.5. I am just curious; does Code::Blocks/MinGW install bring it up to what comes with 5.0, ore something newer?

It does, Code::Blocks is currently bundled with GCC 4.4.1.
problem solved. I uninstalled Dev C++ completely. I used system restore to roll back my computer from when I first started using DEV C++ which was two weeks ago. Reinstalled Dev C++ and (for now) the above program (hello world) is working.
I encountered this problem when I had another mingw installed at c:\mingw and it was a newer version of the compiler than that bundled with Dev C++. (The version bundled with Dev C++ is 3.4.2...the current version is 4.5.0).

There are two ways to fix this problem.
1. update the compiler used by Dev C++, this is probably not an appropriate approach for a beginner though it's not hard to do
2. remove the installation of mingw and reinstall it elsewhere (e.g., c:\mingw4.5), this is an easy fix but don't forget to update your path variable to reflect the new directory (c:\mingw4.5\MinGW\bin)
Topic archived. No new replies allowed.