1

I am trying to figure out something that is causing an error when trying to compile code in Qt Creator, that is linking in my externally built libraries.

It is complaining about an "undefined reference to myclass::myclass(args)" constructor.

However, this class has been built, and the object file was included in an archive called common.a .

The code that references myclass is actually in another library, called CSV.a

So, I know my Qt project can see CSV.a, and I know that there are other references to stuff in common.a that it is not complaining about, but apparently the stuff in CSV.a can't see the stuff in common.a in this arrangement.

What do I need to do differently?

Derek
  • 11,715
  • 32
  • 127
  • 228
  • Did you define that constructor? – Fred Foo Feb 28 '11 at 18:36
  • yes, the constructor was defined in a myclass.cpp file, and a myclass.o was generated, and included in the archive common.a – Derek Feb 28 '11 at 18:41
  • Does this solve your problem: http://stackoverflow.com/questions/1095298/gcc-c-linker-errors-undefined-reference-to-vtable-for-xxx-undefined-referen/1095321#1095321 – Martin York Feb 28 '11 at 19:04

2 Answers2

4

The linker uses the order that libraries are listed on the command line to determine which symbols are actually needed. You need to order them from most-dependent to least-dependent so it can make that determination. For example, list CSV.a first so the compiler knows that it needs to find myclass::myclass(args) somewhere. Then list common.a second and the compiler will then find and link that constructor.

Mark B
  • 95,107
  • 10
  • 109
  • 188
0

You may need to make sure that on the linker command line CSV.a is followed by common.a, not the other way around.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271