[Solved] Compile Error when using regular math functions in kinematics file

More
26 Feb 2020 16:14 - 01 Mar 2020 09:22 #158554 by Aciera
I used some math functions in a kinematics file. Things like abs, cos, acos, sin, asine and so forth.
When I try to build it I get this error:
Linking genserkins
/usr/bin/ld: objects/emc/kinematics/genserfuncs.o: undefined reference to symbol 'acos@@GLIBC_2.0'
//lib/i386-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
emc/kinematics/Submakefile:18: recipe for target '../bin/genserkins' failed
make: *** [../bin/genserkins] Error 1

Apparently its a problem with a missing library that needs to be added to the make file. The section for this kinematic file looks like this but I have really not much clue as to what would need to be added.

Warning: Spoiler!


I would appreciate some guidance as to solve this.
Last edit: 01 Mar 2020 09:22 by Aciera.

Please Log in or Create an account to join the conversation.

More
26 Feb 2020 16:24 #158555 by dgarrett
please post the output from:
$ linuxcnc_info

Please Log in or Create an account to join the conversation.

More
26 Feb 2020 16:44 #158557 by Aciera

File Attachment:

File Name: linuxcnc_info.txt
File Size:4 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
27 Feb 2020 02:54 #158596 by dgarrett
linuxcnc_info excerpts:
kernel-vers -v: #1 SMP PREEMPT RT Debian 4.9.189-3+deb9u2 (2019-11-11)
       cmdline: BOOT_IMAGE=/boot/vmlinuz-4.9.0-11-rt-686-pae ...
...
           gcc: gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
So it appears to be debian stretch with preempt rt kernel.
I cannot reproduce on a similar 64bit stretch virtual machine
but need more information.

1) Are you modifying the primary in-tree Makefile (e.g. src/Makefile)?
or
2) Are you using an independent Makefile?

In either case, please explain in more detail and post:
a)the Makefile used to produce the error message posted at
message 158554
b)the exact directory location of the Makefile
c)the source file(s) using added math functions.

Note: you have both a git tree and a deb install for linuxcnc
and that can lead to hard-to-find errors.

Please Log in or Create an account to join the conversation.

More
27 Feb 2020 07:04 - 27 Feb 2020 07:25 #158601 by Aciera
Thanks so much for looking into this!

So I have uninstalled the deb in the synaptic manager and deleted all the RIP installations.

Then :
$ git clone git://github.com/linuxcnc/linuxcnc.git linuxcnc-dev
$ cd linuxcnc-dev/src
$ ./autogen.sh
$ ./configure --with-realtime=uspace

Returning the message to continue to compile by typing make ....

$ make && sudo make setuid

Build fails:

File Attachment:

File Name: output.txt
File Size:133 KB


I tried this a couple of times but I can't build LinuxCNC anymore.
Attachments:
Last edit: 27 Feb 2020 07:25 by Aciera. Reason: added script output.txt of ./configure and make

Please Log in or Create an account to join the conversation.

More
27 Feb 2020 08:19 #158603 by Aciera
I'll try a fresh install and report back.

Please Log in or Create an account to join the conversation.

More
27 Feb 2020 08:58 #158606 by Aciera
tried a fresh Linux Mint 19.1 install and the exact same thing happens when I try to build LinuxCNC from git.
Now I'll try an iso.

Please Log in or Create an account to join the conversation.

More
27 Feb 2020 12:23 - 27 Feb 2020 14:06 #158621 by Aciera
This just threw me on total loop! There must have been something wrong with the linuxcnc-dev on git. I tried about four different systems on two different machines until I decided to just forget about the normal branch and try to build the switchkins-branch.
Turns out that works just fine!
My kinematics file now also compiles without error.
Last edit: 27 Feb 2020 14:06 by Aciera. Reason: Thought it was solved alas no!

Please Log in or Create an account to join the conversation.

More
27 Feb 2020 14:39 - 27 Feb 2020 14:44 #158641 by Aciera
So I'm back to square 1 with this. Im on a new machine (Linux Mint 19.1 Tessa non realtime kernel)

File Attachment:

File Name: linuxcnc_i...2-27.txt
File Size:3 KB


I've made changes to these two files adding a third kinematics case in genser-switchkins.c which corresponds to a remap to M430. This seems to work.

File Attachment:

File Name: genser-switchkins.c
File Size:6 KB


Of course the difficult part is the actual code for the "gensertoolKinematicsInverse" function. Because I'm having a hard time making sense of all the pointers and go_math functions in the original code I'm trying to use a code by Rudy du Preez

File Attachment:

File Name: robot6kins...-02-27.c
File Size:12 KB
that should actually be able to do the toolcoordinate kinematics I want. So I copied that in.

File Attachment:

File Name: genserfuncs.c
File Size:27 KB
Since his code does not define any other includes I thought that would work. But when I rebuild I get the error:
user@user-iMac:~/linuxcnc-dev/src$ make && sudo make setuid 
Reading 194/194 dependency files
Done reading dependencies
Reading 215/215 realtime dependency files
Done reading realtime dependencies
Linking genserkins
/usr/bin/ld: objects/emc/kinematics/genserfuncs.o: undefined reference to symbol 'sincos@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
emc/kinematics/Submakefile:18: recipe for target '../bin/genserkins' failed
make: *** [../bin/genserkins] Error 1

Probably totally obvious to other people who actually know what they're doing but I'm stumped.
All hints are welcome.
Thanks
Attachments:
Last edit: 27 Feb 2020 14:44 by Aciera. Reason: fix wrong attachment

Please Log in or Create an account to join the conversation.

More
27 Feb 2020 16:13 #158648 by Aciera
I found this answer to a similar question:


If your code includes mathematical functions (like exp, cos, etc.), you need to link to the mathematics library libm.so. This is done, just like for serial compiling, by adding -lm to the end of your compile command, that is,

mpicc -o sample sample.c -lm


But where would I add that "-lm"?

Please Log in or Create an account to join the conversation.

Time to create page: 0.086 seconds
Powered by Kunena Forum