Quantcast
Channel: openSUSE Forums
Viewing all articles
Browse latest Browse all 40713

How to add -lm flag in cmake in spec file?

$
0
0
Hello,

I have been trying to build tinyspline with cmake on Tumbleweed.
https://build.opensuse.org/package/s...eat/tinyspline

I encounter error:

Code:

[    5s] /usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /tmp/libtinyspline.so.FCXWuN.ltrans0.ltrans.o: in function `ts_distance':
[    5s] /home/abuild/rpmbuild/BUILD/tinyspline-snapshot/src/tinyspline.c:2069: undefined reference to `sqrt'
[    5s] /usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /tmp/libtinyspline.so.FCXWuN.ltrans0.ltrans.o: in function `ts_bspline_interpolate_catmull_rom':
[    5s] /home/abuild/rpmbuild/BUILD/tinyspline-snapshot/src/tinyspline.c:987: undefined reference to `pow'
[    5s] /usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/tinyspline-snapshot/src/tinyspline.c:988: undefined reference to `pow'
[    5s] /usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/tinyspline-snapshot/src/tinyspline.c:989: undefined reference to `pow'
[    5s] collect2: error: ld returned 1 exit status

It is complaining about undefined reference to `sqrt' and `pow'
I found that I have to add link flag -lm, which told gcc to use math library.
https://stackoverflow.com/questions/...-pow-and-floor

But I think I was adding it the wrong way, which still cause the same error.
Code:

%prep
%autosetup -n %{name}-%{version}

%build
%cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
      -DCMAKE_LD_FLAGS:STRING="%optflags -lm" \
      -DCMAKE_CXX_FLAGS:STRING="%optflags -lm" \

%cmake_build

%install
%cmake_install

Thanks,
Andy

Viewing all articles
Browse latest Browse all 40713

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>