halcompile missing additionnal include file

More
24 Oct 2018 11:08 #119326 by oro06
Hi,

i'm working on userspace wj200_vfd
i've added a local include file wj200_vfd.h in the declaration section of the comp file
and halcompile --preprocess works fine and generate .c file to the local folder
when invoking
halcompile --compile wj200_vfd.comp
i get
fatal error: wj200_vfd.h: No such file or directory
it seems .h file is not copied to the temp directory where the wj200_vfd.c file is generated

as a workaround i added it manually to the gcc cmd line generated using halcompile --compile wj200_vfd.comp

but is there a way to properly add missing .h file either by having the missing file copied to the temp directory or to force
halcompile --compile not to use a temp dir or something else ?

thanks
OR

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

More
24 Oct 2018 13:09 #119334 by andypugh
An inelegant workaround is to give the include directive a relative path from the temp file location.

github.com/LinuxCNC/linuxcnc/blob/master...s/mesa_uart.comp#L38

For an example.

I agree that it would be better if halcompile made a copy of the include file in the temp file location. (or modified the path)

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

More
24 Oct 2018 14:43 #119338 by oro06
thanks for the update

for the record, there is also a an hidden option "extra_compile_args"
not in the doc here linuxcnc.org/docs/html/hal/comp.html#_options
but looking at the source here
github.com/LinuxCNC/linuxcnc/blob/master...l/utils/halcompile.g
line 715

i just tried to add this in the declaration of the .comp file
option extra_compile_args "-I/home/linuxcnc/dev/linuxcnc-oro06.git/src/hal/user_comps/wj200_vfd/";
and that did the trick but it's not a relative path, not sure it's nice for a
future pull request to come !

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

More
24 Oct 2018 14:54 #119340 by oro06
still this was usefull with modbus.h which is not in the path

option extra_compile_args "-I/home/linuxcnc/dev/linuxcnc-oro06.git/src/hal/user_comps/wj200_vfd;-I/usr/include/modbus";

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

More
24 Oct 2018 15:05 #119341 by oro06
typo
option extra_compile_args "-I/home/linuxcnc/dev/linuxcnc-oro06.git/src/hal/user_comps/wj200_vfd -I/usr/include/modbus -std=c99";

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

More
26 Oct 2018 19:18 #119477 by andypugh
I have looked at this some more, and I am not actually sure what the problem is. I made a test .comp that required a .h file, and it compiled fine with both 2.7 and master when placed in my root folder. (ie, out-of-tree).

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

More
27 Oct 2018 04:21 - 27 Oct 2018 04:24 #119500 by Grotius
Hi,

It can be Orinaudo has used the include statement not the right way.

In Andy's example, in my case nothing will be found with : include "../../../hal/drivers/mesa-hostmot2/hostmot2.h";
Even if the file exist's.
So i suspect mr. Orinaudo can have typed a wrong include argument for a component .comp file to halcompile.

For example, this works, it find's it :
#include "/opt/etherlab/include/special.h"
( if the file exist's B) )
Last edit: 27 Oct 2018 04:24 by Grotius.

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

More
27 Oct 2018 08:53 #119503 by oro06
hi,
sorry to my unclear question,
but the interest was also in not polluting .comp sources
with pathfilename dependant on where code source tree is located
as a concrete example, of out-of-tree compiling component, with the current master
, speaking of the wj200_vfd.comp located (in my case)
~/linuxcnc/dev/linuxcnc/src/hal/user_comps/wj200_vfd
cd ~/linuxcnc/dev/linuxcnc/src/hal/user_comps/wj200_vfd
halcompile --compile wj200_vfd.comp
wj200_vfd.comp:43:19: fatal error: modbus.h: No such file or directory
compilation terminated.
make: *** [wj200_vfd] Error 1
then to fix this, a possibility is to add in the comp file, in the declaration section (before the ";;")
option extra_compile_args "-I/usr/include/modbus -std=c99";
option extra_link_args "-lmodbus";
this should succeed, i find it clean because modbus is a std lib located in a std place

now if one want to use an additionnal include file wj200_vfd.h, located in the same directory as the comp
updating the corresponding .comp file like this
...
option userspace;
option userinit yes;
include <wj200_vfd.h>; 
option extra_compile_args "-I/usr/include/modbus -std=c99";
option extra_link_args "-lmodbus";
license "GPLv2 or greater";
;;
then compiling...
halcompile --compile wj200_vfd.comp
/tmp/tmp2r2Nhr/wj200_vfd.c:13:23: fatal error: wj200_vfd.h: No such file or directory
replacing
include <wj200_vfd.h>; 
by
include "~/linuxcnc/dev/linuxcnc/src/hal/user_comps/wj200_vfd/wj200_vfd.h"; 
will compile fine on my system,
but this will not compile properly on another system located elsewhere in the fs

this is why i proposed
github.com/LinuxCNC/linuxcnc/pull/515

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

Time to create page: 0.115 seconds
Powered by Kunena Forum