halcopile problem / new ubunu 14.04 installation

More
29 Nov 2016 10:06 - 08 Feb 2017 11:40 #83422 by bkt
I have just post these problem to other thread ...but the title was not responding my actual problem, I've found an error but there is other with path library ... so I repost the question ...

I install on ubuntu 14.04 linuxcnnc-dev folder on Home dir .... I've my custom comp for run a MBus server ... The com is running for test in my old ubuntu 10.04 config and works fine .... actually I try to install that config with custom kins e comp in fresh linuxcnc Master on ubuntu 14.04... kins compile good and my config works... but nothing to do with my comp firtrly is because I use:
singleton yes;
so I obtauin these error:
k1MbServer.c: In function ‘__comp_parse_names’:
/tmp/tmpLc0aCs/k1MbServer.c:573:17: error: ‘names’ undeclared (first use in this function)
                 names[j] = strtok(p, ",");
                 ^

So I see inside halcompile file and I see some void parser araund count names .... so I write the new option and cancel the oldone:
option singleton no;

In these way merge these type of error:
/tmp/cc1kjkzO.o: in function "user_mainloop":
/tmp/tmp_RtXP2/k1MbServer.comp:210: undefined reference  "floor"
/tmp/tmp_RtXP2/k1MbServer.comp:216: undefined reference  "floor"
/tmp/tmp_RtXP2/k1MbServer.comp:217: undefined reference  "floor"
/tmp/tmp_RtXP2/k1MbServer.comp:218: undefined reference  "floor"
/tmp/tmp_RtXP2/k1MbServer.comp:219: undefined reference  "floor"
/tmp/tmp_RtXP2/k1MbServer.comp:236: undefined reference  "modbus_new_tcp"
/tmp/tmp_RtXP2/k1MbServer.comp:238: undefined reference  "modbus_get_header_length"
/tmp/tmp_RtXP2/k1MbServer.comp:240: undefined reference  "modbus_set_debug"

//and other about modbus

So now I not understand if singleton yes (old on ubuntu 10.04) is right or there are the problem with path of library and singleton no is right(today in new ubuntu 14.04) .. THE OLD CONFIG ON UBUNTU10.04 WITH THESE COMP COMPILE FINE .... in the doc and terminal I read about linuxcnc-dev installation for library refer to path linuxcnc-dev/lib ... so I try to make a symlink of libmodbus on these dir but nothing change.....
Other:undefined reference "floor" is because is not find -lm on extra option row ... And I think same for -lmodbus and -L/usr/include/lib/modbus.....

I need some help for define the problem ...

Actually in linuxcnc-dev/lib there are normal link after install + symlink of libmodbus.so, all other lib is on usual dir or normal ubuntu installation ....

the comp:

File Attachment:

File Name: k1MbServer...1-29.txt
File Size:18 KB


(if this is not the right place to ask these question please advice me or change the folder of question).

Regards
Giorgio
Attachments:
Last edit: 08 Feb 2017 11:40 by bkt.

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

More
29 Nov 2016 14:32 #83432 by andypugh

/tmp/tmp_RtXP2/k1MbServer.comp:210: undefined reference "floor"
/tmp/tmp_RtXP2/k1MbServer.comp:216: undefined reference "floor"


I would have expected halcompile to automatically add a reference to rtapi_math
github.com/LinuxCNC/linuxcnc/blob/master/src/rtapi/rtapi_math.h
And that contains the "floor" function.

If you try halcompile without the --compile switch (and are you sure you don't want --install ? ) to view the generated C-code and check that that includes the rtapi_math.h #include.
The following user(s) said Thank You: bkt

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

More
29 Nov 2016 15:27 - 29 Nov 2016 15:42 #83434 by bkt
Tanks a lot but not knows these opportunity.....

andypugh wrote: without the --compile switch (and are you sure you don't want --install ? )


obviusly later I install but now would try to solve these problem... out of --compile & --install is the same... so now I have .c file..... whats is mean "count= and names= are mutually exclusive".... Is not possible names variables in these way: ja1?...

I'm not familiar with rtai.c file ... so I not see anything ... see only these it sounds to me suspiciously ...:
static int default_count=1, count=0;
char *names[16] = {0,};
int rtapi_app_main(void) {
    int r = 0;
    int i;
    comp_id = hal_init("konembserver");
    if(comp_id < 0) return comp_id;
    if(count && names[0]) {
        rtapi_print_msg(RTAPI_MSG_ERR,"count= and names= are mutually exclusive\n");
        return -EINVAL;
    }
    if(!count && !names[0]) count = default_count;
    if(count) {
        for(i=0; i<count; i++) {
            char buf[HAL_NAME_LEN + 1];
            rtapi_snprintf(buf, sizeof(buf), "konembserver.%d", i);
            r = export(buf, i);
            if(r != 0) break;
       }
    } else {
        int max_names = sizeof(names)/sizeof(names[0]);
        for(i=0; (i < max_names) && names[i]; i++) {
            if (strlen(names[i]) < 1) {
                rtapi_print_msg(RTAPI_MSG_ERR, "names[%d] is invalid (empty string)\n", i);
                r = -EINVAL;
                break;
            }
            r = export(names[i], i);
            if(r != 0) break;
       }
    }
    if(r) {
        hal_exit(comp_id);
    } else {
        hal_ready(comp_id);
    }
    return r;
}


konembserver-with-singleton-no.c file

File Attachment:

File Name: konembserv...gleton.c
File Size:44 KB


konembserver-with-singleton-yes.c file

File Attachment:

File Name: konembserv...on-yes.c
File Size:43 KB



regards
Giorgio
Attachments:
Last edit: 29 Nov 2016 15:42 by bkt.

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

More
29 Nov 2016 15:41 #83436 by andypugh
"Mutually exclusive" means that you can't use both
You can't have:

loadrt mycomp count=3 names=names1,names2,names3,names4

You have neither, so it won't matter.
The following user(s) said Thank You: bkt

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

More
29 Nov 2016 15:49 #83438 by bkt
Tanks a lot ...:laugh: ... Ha ok So :singleton yes is my definitive option....

regards
Giorgio

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

More
30 Nov 2016 12:20 #83483 by bkt
I'm pretty convinced that it is only a path problem ... so I compiled with halcompile mycomp.c no singleton ... but I can not use it on Lcnc because libmodbus is uspace lib .... So:

other things ....

option extra_link_args "…" - (default: "") This option is ignored if the option userspace (see above) is set to no. When linking a userspace component, the arguments given are inserted in the link line. Note that because compilation takes place in a temporary directory, "-L." refers to the temporary directory and not the directory where the .comp source file resides.


so:

gcc -Os -g -I. -I/home/k1/linuxcnc-dev/src/include -DUSPACE -fno-fast-math -mieee-fp -fno-unsafe-math-optimizations -DRTAPI -D_GNU_SOURCE -Drealtime -D__MODULE__ -I/home/k1/linuxcnc-dev/include -Wframe-larger-than=2560 -DSIM -fPIC -URTAPI -U__MODULE__ -DULAPI -Os -lm -ldl -L/usr/local/include/modbus -lmodbus -o K1MbServer /tmp/tmp0wIaJv/konembserver.c -Wl,-rpath,/home/k1/linuxcnc-dev/lib -L/home/k1/linuxcnc-dev/lib -llinuxcnchal

/*********** -lm -ldl -L/usr/local/include/modbus -lmodbus*************/


the commented row .. the link is search in /tmp/.... or in the right place on /usr/include...???

Regards
giorgio


I "virtually" joint the post :laugh: ... because the proble is probabily the path ...

regards
giorgio

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

More
30 Nov 2016 14:34 #83485 by andypugh
libmdbus being userspace is not a problem, because your component is also userspace
(option userpspace yes )

It seems that a bug with halcompile means that userpsace and singleton don't work well together, but you can probably work round that.

I am afraid that I don't know the meaning of any of the compiler switches.
The following user(s) said Thank You: bkt

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

More
30 Nov 2016 16:42 - 30 Nov 2016 16:42 #83488 by bkt
names & count error when compile with singleton

Is possible to add declaration of names and count variable ... I add global as long unsigned int for count and int for names ... the error disappear ....

For libmodbus and math .... i'm working around

regards
giorgio
Last edit: 30 Nov 2016 16:42 by bkt.

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

More
30 Nov 2016 16:47 #83489 by andypugh
Do you need "singleton" or do you need "names / count" ?

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

More
30 Nov 2016 16:59 - 30 Nov 2016 17:06 #83492 by bkt
I need singleton ... my compPin on hal file is named compPin.idle for example .... these comp work from 6mounth every day on other machine with same config of these ... only SO is ubuntu10.04 ....And in twin machine the option singleton is yes.

I have bad understand the doc? If I need mycomp.idle for example I need option singleton yes... or I'm in wrong?

Please make your correction ... I'm confused on the arguments...


UPDATE:

option singleton yes - (default: no) Do not create a count module parameter, and always create a single instance. With singleton, items are named component-name.item-name and without singleton, items for numbered instances are named component-name.<num>.item-name.


I understand if option singleton yes => mycomp.idle is possible...whitout mycomp.0.idle ... I understand well? :ohmy:

regards
Giorgio
Last edit: 30 Nov 2016 17:06 by bkt.

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

Time to create page: 0.081 seconds
Powered by Kunena Forum