How to link .a lib in my hal comp ?

More
05 Nov 2014 17:12 #52802 by andypugh
Does the library have to be linked through a compiler option? Is there any way to #include it?
<google>
Hmm, it appears that you may need to do both.

For reference there is an undocumented "include" command in comp/halcompile:
git.linuxcnc.org/gitweb?p=linuxcnc.git;a...dadca732;hb=HEAD#l56
The following user(s) said Thank You: ArcEye

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

More
05 Nov 2014 17:51 - 05 Nov 2014 17:52 #52805 by ArcEye

In fact i saw the makefile in the linuxcnc/src , but it's too complex for me (a fresher) . attached the makefile ,


That is the makefile to build Linuxcnc, nothing to do with comp.

i installed the system from live CD and linuxcnc-dev


You initially said that you had 10.04 installed with linuxcnc-dev package
but now you are saying you have the sources?

What is it exactly you are doing and are you using a RIP or the installed system?

There is huge scope for error if you try building components for a RIP without setting the environment first and thus end up building against the installed system.

If that is not the case you will need to attach the sources you are trying to compile.
I suspect they were never a .comp, thus don't even know if the file is in a format that will build a module in the first place.

regards
Last edit: 05 Nov 2014 17:52 by ArcEye.

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

More
05 Nov 2014 17:57 #52806 by ArcEye
Andy Pugh wrote:

For reference there is an undocumented "include" command in comp/halcompile:
git.linuxcnc.org/gitweb?p=linuxcnc.git;a...dadca732;hb=HEAD#l56


Had not noticed that before.

However the more I think about it the less useful it becomes.
A rt module will have a very limited amount of possible includes and you can include whatever you like into a userspace comp file anyway.

Will have to file it away at the back of my head for poss future use.

regards

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

More
05 Nov 2014 17:59 #52807 by andypugh

However the more I think about it the less useful it becomes.
A rt module will have a very limited amount of possible includes and you can include whatever you like into a userspace comp file anyway.


You can #include in the C-code section of a comp too, but the "include ...;" command in the comp headers can be useful when you need a variable of a type that is defined in a header.

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

More
05 Nov 2014 18:32 #52809 by ArcEye

You can #include in the C-code section of a comp too, but the "include ...;" command in the comp headers can be useful when you need a variable of a type that is defined in a header.


It could have its uses.
I have always sidestepped the issue in the past by generating a .c file, modifying that to include whatever is required and then compiling that.

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

More
05 Nov 2014 18:51 - 05 Nov 2014 19:04 #52810 by blightxdm1

In fact i saw the makefile in the linuxcnc/src , but it's too complex for me (a fresher) . attached the makefile ,


That is the makefile to build Linuxcnc, nothing to do with comp.

i installed the system from live CD and linuxcnc-dev


You initially said that you had 10.04 installed with linuxcnc-dev package
but now you are saying you have the sources?

What is it exactly you are doing and are you using a RIP or the installed system?

There is huge scope for error if you try building components for a RIP without setting the environment first and thus end up building against the installed system.

If that is not the case you will need to attach the sources you are trying to compile.
I suspect they were never a .comp, thus don't even know if the file is in a format that will build a module in the first place.

regards


Hi ArcEye , sorry made you confused .
In fact i have both system .one is from live-cd ,and another from srouces compiled . Of course in the second system ,before use comp command , i ran RIP script first . But the result are the same .What ever i can't get the respone as you show : gcc ....
the total response i got as below:
blight@blight-desktop:~/MEI$ comp --compile mei.c
make KBUILD_EXTRA_SYMBOLS=/usr/realtime-2.6.32-122-rtai/modules/linuxcnc/Module.symvers -C /usr/src/linux-headers-2.6.32-122-rtai SUBDIRS=`pwd` CC=gcc V=0 modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-122-rtai'
  CC [M]  /tmp/tmplIlsZG/mei.o
In file included from /MEI/MPI/include/stdmpi.h:42,
                 from /tmp/tmplIlsZG/mei.c:28:
/MEI/MPI/include/path.h:175: warning: function declaration isn’t a prototype
/tmp/tmplIlsZG/mei.c: In function ‘set_timeouts’:
/tmp/tmplIlsZG/mei.c:425: warning: unused variable ‘temp’
/tmp/tmplIlsZG/mei.c: At top level:
/MEI/XMP/include/stdmei.h:825: warning: ‘MEIFilterGainTypePID’ defined but not used
/MEI/XMP/include/stdmei.h:922: warning: ‘MEIFilterGainTypePIV’ defined but not used
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "mpiMotionCreate" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiAxisConfigSet" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiMotorValidate" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiControlInitVerify" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiFilterValidate" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiControlValidate" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiAxisCommandPositionGet" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiAxisConfigGet" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiAxisValidate" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiMotorConfigSet" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiAxisCreate" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiFilterCreate" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiFilterConfigSet" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiMotorCreate" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiMotionValidate" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiFilterConfigGet" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiControlCreate" [/tmp/tmplIlsZG/mei.ko] undefined!
WARNING: "mpiMotorConfigGet" [/tmp/tmplIlsZG/mei.ko] undefined!
  CC      /tmp/tmplIlsZG/mei.mod.o
  LD [M]  /tmp/tmplIlsZG/mei.ko
Last edit: 05 Nov 2014 19:04 by blightxdm1.

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

More
05 Nov 2014 20:16 #52813 by ArcEye
The module is building but with all the functions from the library undefined.

You can either try to hack comp from about line 920, to include the lib you want, or attach the source and lib and I will try to build it and come up with a command line gcc script.

The previous one would work, you just need to sort out the relative paths.

I have dug out the corresponding script from my backup of 10.04

Save this as buildmod, and chmod -755 buildmod to make it executable

command will be ./buildmod mei meixmp assuming the source and lib are the same as previously given
# !/bin/bash

gcc -Os -g -I. -I/usr/realtime-2.6.32-122-rtai/include -I. -I/usr/realtime-2.6.32-122-rtai/include -D_FORTIFY_SOURCE=0 \
	-mhard-float -DRTAI=3 -fno-fast-math -mieee-fp -fno-unsafe-math-optimizations -DRTAPI -D_GNU_SOURCE -Drealtime \
	-D_FORTIFY_SOURCE=0 -D__MODULE__ -I/usr/include/emc2 -Wframe-larger-than=2560 -URTAPI -U__MODULE__ -DULAPI -Os \
        -o $2 $2.c -Wl,-rpath,/lib -L/lib -llinuxcncini -llinuxcnchal -lnml -llinuxcnc -lposemath -l$3

This should just work so long as the .c file is in the PWD, the lib is somewhere on the lib path and any headers where they can be found too
(suggest just /usr/lib and /usr/include to start with)

regards

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

More
05 Nov 2014 21:09 #52814 by andypugh

You can either try to hack comp from about line 920, to include the lib you want


Do you mean 920? the build_rt def is 660.

The best idea might be to add a "library ... ;" command to halcompile, then append that to the compile flags. Then we can see about adding it to the main builds.

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

More
05 Nov 2014 21:16 #52816 by ArcEye

You can either try to hack comp from about line 920, to include the lib you want


Do you mean 920? the build_rt def is 660.

The best idea might be to add a "library ... ;" command to halcompile, then append that to the compile flags. Then we can see about adding it to the main builds.


It is at 920 on the Machinekit build on this partition.

Yes, that would be the easiest way, I will pull the master this afternoon and have a look at it.

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

More
05 Nov 2014 23:38 #52824 by ArcEye

You can either try to hack comp from about line 920, to include the lib you want


Do you mean 920? the build_rt def is 660.


It all starts at 920 in linuxcnc too, not sure what you were viewing.

The build_rt reference prompts me however to go back to blightxdm1 and say, 'tell us exactly what you are doing and share the code'

rt builds and userspace ones are dealt with differently in comp / halcompile and we don't even know which it is.

I assumed all along that we were talking about a userspace module. The likelihood of having a staticly linked realtime library seemed remote.

However this shows we have actually been told nothing about what he is doing, save a question from which we make assumptions.

Over to you blightxdm1

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

Time to create page: 0.124 seconds
Powered by Kunena Forum