crevell
crevell

Reputation: 460

Fortran: Interpreting "Undefined symbols for architecture x86_64"

When compiling a program, I am shown the following error messages:

Undefined symbols for architecture x86_64:
  "_jrand_", referenced from:
      ___trfind_module_MOD_trfind in ccqRBw2L.o
     (maybe you meant: ___jrand_module_MOD_jrand)
  "_left_", referenced from:
      ___trmesh_module_MOD_trmesh in ccq56SyA.o
     (maybe you meant: ___left_module_MOD_left)
  "_lstptr_", referenced from:
      ___intadd_module_MOD_intadd in ccr7Tz7x.o
      ___swap_module_MOD_swap in cclq1Td3.o
      ___trfind_module_MOD_trfind in ccqRBw2L.o
      ___addnod_module_MOD_addnod in ccwGNCEK.o
     (maybe you meant: ___lstptr_module_MOD_lstptr)
  "_store_", referenced from:
      ___trfind_module_MOD_trfind in ccqRBw2L.o
     (maybe you meant: ___store_module_MOD_store)
  "_swptst_", referenced from:
      ___addnod_module_MOD_addnod in ccwGNCEK.o
     (maybe you meant: ___swptst_module_MOD_swptst)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

I understand that this comes about because of incorrect linking between modules. My question is how exactly to interpret the information the compiler is giving. What does "in ccqRBw2L.o" mean, for example?

Upvotes: 0

Views: 2400

Answers (1)

For you the most important are the suggestions maybe you meant.

It as very probable you forgot to use the relevant modules. In particular

"_jrand_", referenced from:
      ___trfind_module_MOD_trfind in ccqRBw2L.o
     (maybe you meant: ___jrand_module_MOD_jrand)

when linking the object file ccqRBw2L.o (the name is controlled by your build mechanism, some Makefile or similar) the linker did not find any symbol _jrand_ which would be an external subroutine or function called jrand.

However the linker sees that there is something called jrand.

     maybe you meant: ___jrand_module_MOD_jrand

but it is not external, it seems to be located in the module called jrand.

You should make sure you use the module (use jrand) when calling the subroutine or function which is in this module.

Upvotes: 1

Related Questions