Math header doesn't work

Answered

Hello, I have a problem with CLion. I did some research, tried some suggestions, but neither of them helped me. I am using CLion on Elementary OS to write programs in C. The problem is I can't build any project with math header. It's very strange, because the editor itself knows the syntax of math funtions and I am sure the needed libraries are installed (I can compile the code in terminal). I followed some tutorials and added this to my CMakeList: target_link_libraries(projectName C m). Before this, the build console would output: undefined reference to sqrt , for example. Now it says /usr/bin/ld: cannot find -lC . If somebody would help me I would be very grateful. 

0
4 comments

Hi! What is "C" and why do you need it? According to this answer, for example, to link to libm you link to m, i.e. target_link_libraries(projectName m).

1
Avatar
Permanently deleted user

Hello, thanks a lot, it works now. I thought when the project is written in C, C has to be after the project name. Thanks a lot one more time and sorry for wasting your time with this novice error.

0

No problem! I'm glad it works now. 

0

Yes, ma'am it certainly works. I faced this just today and I'm glad the issue is fixed. Thank you.

 

0

Please sign in to leave a comment.