Linker error

Dec 3, 2010 at 10:58pm
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
Dec 3, 2010 at 11:10pm
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
Dec 3, 2010 at 11:22pm
Uninstall Dev-C++ and make sure the folder you installed it to is completely gone.
Then install the Code::Blocks/MinGW bundle.
Dec 3, 2010 at 11:25pm
I replaced pause with cin.get and still received the same linker errors.
Dec 3, 2010 at 11:27pm
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 Dec 3, 2010 at 11:28pm
Dec 4, 2010 at 12:06am
system() may be portable, but "pause" isn't portable.

but yeah it's not going to cause a linker error in any case.
Dec 4, 2010 at 12:44am
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'
Dec 4, 2010 at 1:07am
> 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?

Dec 4, 2010 at 1:29am
It does, Code::Blocks is currently bundled with GCC 4.4.1.
Dec 4, 2010 at 3:23am
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.
Dec 29, 2010 at 4:50am
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.