'gcc'에 해당되는 글 1건

  1. 2024.08.13 gcc linking error due to library option location
2024. 8. 13. 17:21

gcc linking error due to library option location

gcc 로 compile 하는데, library option을 앞에 주면 오류가 나고, 뒤에 주면 오류가 나지 않는다?

$ gcc -lm -o test test.c nml.c nml_util.c    
/tmp/cc4KiP0A.o: In function `nml_mat_col_l2norm':
nml.c:(.text+0x3165): undefined reference to `sqrt'
/tmp/cc4KiP0A.o: In function `nml_mat_l2norm':
nml.c:(.text+0x3257): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status

$ gcc -o test test.c nml.c nml_util.c -lm

어떤 문법의 오류가 있는지, gcc v7 에서의 오류인지, 찾아볼 시간이 없어서,,, 기록만 남긴다.

linking 할 때 사용하는 것이라서, 뒤에 었이야 하나?