0

i tried to use make on my c source code and created executable file. but the executable file did not work the intended task. even if the make file compiled and produced the executable file when i try to compile the .c file individually it gave many undefined reference problem The errors are

/tmp/cc4tx0BG.o: In function `main':
cubist.c:(.text+0xdc): undefined reference to `Of'
cubist.c:(.text+0xe7): undefined reference to `Of'
cubist.c:(.text+0xfa): undefined reference to `Of'
cubist.c:(.text+0x10f): undefined reference to `KRInit'
cubist.c:(.text+0x114): undefined reference to `ExecTime'
cubist.c:(.text+0x127): undefined reference to `PrintHeader'
cubist.c:(.text+0x139): undefined reference to `Of'
[...]
cubist.c:(.text+0xb79): undefined reference to `MaxAtt'
cubist.c:(.text+0xb83): undefined reference to `InitialiseEnvData'
cubist.c:(.text+0xb8a): undefined reference to `XVAL'
cubist.c:(.text+0xb93): undefined reference to `CrossVal'
cubist.c:(.text+0xb9a): undefined reference to `SingleCttee'
cubist.c:(.text+0xb9f): undefined reference to `ExecTime'
cubist.c:(.text+0xbab): undefined reference to `Of'
collect2: error: ld returned 1 exit status

please, could any body tells how to use make and building executables in Linux work.

Jens
  • 69,818
  • 15
  • 125
  • 179
melaku
  • 89
  • 2
  • 11
  • 1
    Cut down the output, it's understandable what's going on from first ~10 lines. – 0andriy Jan 30 '17 at 13:13
  • I think it's a linking error. How did you compile your source? – uzsolt Jan 30 '17 at 13:51
  • i used the gcc compiler to get the executable file called cubist . gcc -o cubist cubist.c – melaku Jan 30 '17 at 14:50
  • @melaku Is the toolchain you're using standard, or custom made? Could you also post your source cubist.c - we could probably help you better with it. – Ram Jan 31 '17 at 02:31
  • is standard toolchain. GPL edition c source code of cubist is availabile at (http://rulequest.com/download.html). you can also see the cubist.c – melaku Feb 01 '17 at 07:03

1 Answers1

0

I think (not sure) that you are saying that you successfully produced an executable using Make (at least that's how I interpret "use make on my c source code and created executable file" -- do correct me if I'm wrong!). If that's the case, invoke make like this: make -B --trace, and you'll see the exact commands that were used to build the executable, and then you'll hopefully know which compiler/linker flags or libraries you missed while trying to build stuff manually.

Michael Livshin
  • 401
  • 3
  • 4