views:

99

answers:

1

I just moved some code from one platform to another which required a change in compiler versions. Two of the utility sources caused linking problems with undefined symbols, for this example call them Foo.c and Foo.h.

Everything was compiling and linking fine with g++ 3.4.2 and I figured the switch to g++ 4.1.2 would be a no brainer. When using 4.1.2 the compilation went fine but the linking failed due to undefined symbols. The symbols for every function in Foo that were used in other source files, ie. Bar.c, were undefined even though Foo.h was included in Bar.c.

The problem was that the Foo.c file did not include the Foo.h. So the question is, how did g++ 3.4.2 link this code when 4.1.2 could not? I figure that 3.4.2 was expecting a .h file and was then including it "magically" so as to avoid this problem. But does anyone have a better explanation?

+4  A: 

There is a ABI difference between 3.4 and 4.1, so make sure you've cleaned and recompiled the project. And updated all the libraries you're linking against.

sfossen