3

I'm trying to compile a simple code wich calls one function of Simd Library:

// simd.c
#include <stdint.h>
#include "Simd/SimdLib.h"

int main(void) {

    uint8_t buf1[720*576];
    uint8_t buf2[900*720];

    SimdResizeBilinear(buf1, 720, 576, 720*1, buf2, 900, 720, 900*1, 1);

    return 0;
}

with following command-line:

gcc -I./ -L./Simd/ -lSimd simd.c -o simd
/tmp/cckOlRnm.o: In function `main':
simd.c:(.text+0x46): undefined reference to `SimdResizeBilinear'
collect2: error: ld returned 1 exit status

Subdirectory ./Simd contains following files:

ls -A1 ./Simd/
libSimd.a
libSimdAvx1.a
libSimdAvx2.a
libSimdBase.a
libSimdSse1.a
libSimdSse2.a
libSimdSse3.a
libSimdSse41.a
libSimdSse42.a
libSimdSsse3.a
SimdAvx1.h
SimdAvx2.h
SimdBase.h
SimdBase_tinyxml2.h
SimdCompare.h
SimdConfig.h
SimdConst.h
SimdConversion.h
SimdDefs.h
SimdDetection.h
SimdEnable.h
SimdExtract.h
SimdHelp.h
SimdInit.h
SimdLib.h
SimdLoad.h
SimdLog.h
SimdMath.h
SimdMemory.h
SimdNeon.h
SimdSet.h
SimdSse1.h
SimdSse2.h
SimdSse3.h
SimdSse41.h
SimdSse42.h
SimdSsse3.h
SimdStore.h
SimdStream.h
SimdVersion.h
SimdVmx.h
SimdVsx.h

I was surprised by the compiler message 'undefined reference' and I tried to find the required function in the library files:

nm -o ./Simd/*.a | grep SimdResizeBilinear
Simd/libSimd.a:SimdLib.cpp.o:00005510 T SimdResizeBilinear

I realize that my question is rather silly, but I will be glad to any your advice to help me link that correctly.

Paul R
  • 208,748
  • 37
  • 389
  • 560
MikeZ
  • 33
  • 6
  • Change the link order on the command line, e.g.: `gcc simd.c -I./ -L./Simd/ -lSimd -o simd` – Paul R Apr 20 '17 at 11:51
  • It solved my problem. Thanks a lot! – MikeZ Apr 20 '17 at 12:33
  • You're welcome - this is quite a common error and there are already a number of similar questions about this type of problem, so I'm voting to close as a duplicate. – Paul R Apr 20 '17 at 12:48

1 Answers1

2

I have built your example with using of the following options:

gcc simd.c -I./ -L./Simd/ -o simd -lSimd -lSimdBase -lSimdSse1 -lSimdSse2 -lSimdSse3 -lSimdSsse3 -lSimdSse41 -lSimdSse42 -lSimdAvx1 -lSimdAvx2 -lstdc++ -lm
Akira
  • 213
  • 2
  • 11