0

When I make a plasma simulation project, the linker reports this error:

../libpsc/.libs/libpsc.a(push_part_1vb_mix.o):(.rodata+0x38): undefined reference to `psc_push_particles_1vb_ps2_ops'

Actually, the problem is obvious. The c file ../libpsc/FOLDER_A/push_part_1vb_mix.c (call it A.c) refers to a

struct psc_push_particles_ops psc_push_particles_1vb_ps2_ops = { //definition

defined in ../libpsc/FOLDER_B/psc_push_particles_ps.c (call it B.c). The A.c includes a header file (located in ../include/) which contains

extern struct psc_push_particles_ops psc_push_particles_1vb_ps2_ops;

However, the linker report this error anyway. So how can I fix this problem? Is this caused by the makefile? I don't know how the linker solves references and any suggestion will be appreciated. Thanks in advance!

Asgard
  • 103
  • 1
  • 2
  • 9
  • Is `psc_push_particles_1vb_ps2_ops` in a conditional in `B.c`? It could be conditioned out. Is `B.c` getting added to the `libpsc.a` library or linked to whatever the final binary is? – ldav1s Feb 20 '14 at 17:07
  • @ldav1s Nope, there is no condition proceeding that struct. I think the problem is in Makefile. B.c didn't get compiled into B.o. Is this the problem? – Asgard Feb 20 '14 at 18:24
  • If `B.c` isn't compiled into `B.o`, then there's no way for `B.o` to be added to a library or linked to some other binary. So yes, that's a problem. – ldav1s Feb 20 '14 at 18:54

0 Answers0