1

I am trying to compile and link an Athena Xt program on Ubuntu linux.

I have compiled program into an object file but I am unable to link it with Xt library no matter what.

My linker call is

ld /usr/lib/x86_64-linux-gnu/libXt.a program.o

I am getting this linker error

program.o: In function `main':
program.c:(.text+0x37): undefined reference to `XtInitialize'
program.c:(.text+0x42): undefined reference to `commandWidgetClass'
program.c:(.text+0x5e): undefined reference to `XtCreateManagedWidget'
program.c:(.text+0x75): undefined reference to `XtStrings'
program.c:(.text+0x7d): undefined reference to `XtAddCallback'
program.c:(.text+0x89): undefined reference to `XtRealizeWidget'
program.c:(.text+0x8e): undefined reference to `XtMainLoop'

I probed Xt library with nm and symbols are there:

nm /usr/lib/x86_64-linux-gnu/libXt.a | grep XtInitialize
                 U _XtInitializeActionData
0000000000000360 T XtInitializeWidgetClass
00000000000018b0 T XtInitialize
                 U XtInitializeWidgetClass
00000000000006d0 T _XtInitializeActionData
                 U XtInitializeWidgetClass

Any idea what's wrong?

Sourav Ghosh
  • 130,437
  • 16
  • 177
  • 247
Martin Macak
  • 3,196
  • 2
  • 26
  • 43

1 Answers1

1

Try:

ld  program.o /usr/lib/x86_64-linux-gnu/libXt.a

argument order to ld matters, it expects to find the library after the object file with the reference.

Sasha Pachev
  • 4,884
  • 3
  • 19
  • 19