Jump to content
OMRON Forums

Errors when using _PPScriptMode_


windell747

Recommended Posts

Hi,

 

I'm making a modification to a set of working code by defining a few extra "globals" in global definitions.pmh and putting #define _PPScriptMode_. When I compile I get the following errors

 

Error : tcspmac.o: In function `SetEnumGlobalVar':
Error :  multiple definition of `SetEnumGlobalVar' 
Error :  first defined here 
Error : tcspmac.o: In function `GetEnumGlobalVar':
Error :  multiple definition of `GetEnumGlobalVar' 
Error :  first defined here 
Error : tcspmac.o: In function `SetEnumGlobalArrayVar':
Error :  multiple definition of `SetEnumGlobalArrayVar' 
Error :  first defined here 
Error : tcspmac.o: In function `GetEnumGlobalArrayVar':
Error :  multiple definition of `GetEnumGlobalArrayVar' 
Error :  first defined here 
Error : tcspmac.o: In function `SetEnumCSGlobalVar':
Error :  multiple definition of `SetEnumCSGlobalVar' 
Error :  first defined here 
Error : tcspmac.o: In function `GetEnumCSGlobalVar':
Error :  multiple definition of `GetEnumCSGlobalVar' 
Error :  first defined here 
Error : tcspmac.o: In function `SetEnumCSGlobalArrayVar':
Error :  multiple definition of `SetEnumCSGlobalArrayVar' 
Error :  first defined here 
Error : tcspmac.o: In function `GetEnumCSGlobalArrayVar':
Error :  multiple definition of `GetEnumCSGlobalArrayVar' 
Error :  first defined here 
Error : tcspmac.o: In function `SetEnumPtrVar':
Error :  multiple definition of `SetEnumPtrVar' 
Error :  first defined here 
Error : tcspmac.o: In function `GetEnumPtrVar':
Error :  multiple definition of `GetEnumPtrVar' 
Error :  first defined here 
Error : tcspmac.o: In function `SetEnumPtrArrayVar':
Error :  multiple definition of `SetEnumPtrArrayVar' 
Error :  first defined here 
Error : tcspmac.o: In function `GetEnumPtrArrayVar':
Error :  multiple definition of `GetEnumPtrArrayVar' 
Error :  first defined here 
CError : collect2: ld returned 1 exit status

 

From the looks of it, I have something doubly defined somewhere, however I certianly only have one instance of "#define _PPScriptMode_" in the file. I've successfully used this in other C files in the working code and everything is fine, however, when I try to implement using the globals in this file I get these compile errors. I know the issue is one my side, but I'm not quite sure about how to approach finding the bug.

 

I've attached two files for reference:

tcspmac.c (doesn't compile)

tcsctrl.c(compiles fine)

 

Any suggestions?

tcspmac.c

tcsctrl.c

Link to comment
Share on other sites

  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

Windell,

 

Taking a look at your "tcspmac.c" file, I observe a few issues.

 

1. You are in fact putting two #include gplib.h.

2. You are including RtGpShm.h as well.

 

Please remove the include of RtGpShm (you do not need to include it with gplib, as gplib includes it already). Also, please remove the first gplib.h include, include gplib.h only once, and make sure it is included at the end of your string of #includes.

 

Please let me know if that fixes it for you.

Link to comment
Share on other sites

In my previous reply (now deleted due to false information), I said that it compiled fine after removing the duplicate #include entries. It appears that I was wrong and probably compiled my code with the #define _PPScriptMode_ commented out by mistake because it no longer compiles and generates the same duplicate entry issues.

 

I've attached my project for you to take a look. The file that is causing the issue is tcspmac.c. You'll see that there is another file that uses _PPScriptMode_ and it is tcsctrl.c.

 

With the dulpicate header files entries removed its no logner obvious as to what the issue could be.

 

Does anyone have a suggestions?

 

Thanks,

windell

 

Windell,

 

Taking a look at your "tcspmac.c" file, I observe a few issues.

 

1. You are in fact putting two #include gplib.h.

2. You are including RtGpShm.h as well.

 

Please remove the include of RtGpShm (you do not need to include it with gplib, as gplib includes it already). Also, please remove the first gplib.h include, include gplib.h only once, and make sure it is included at the end of your string of #includes.

 

Please let me know if that fixes it for you.

PowerPMACProject.zip

Link to comment
Share on other sites

Please list specifically what errors you are getting.

 

Also, where are you getting all of these C files? Are you using Simulink to generate them?

 

Try using the "divide and conquer" approach. Build one file at a time. Comment things out until something starts working and work backward from there.

 

Also, the Output window in the IDE should show you the line number containing the error. You can enable line numbers by clicking Tools-->Options-->Text Editor-->C Language, and then check "Line Numbers."

Link to comment
Share on other sites

Hi Charles,

 

My apologies for being unclear. The errors I am getting are the same as in the original post. These files are part of a working project in which I have made a few modifications too. The project is code for the PMAC acting as a server to receiving commands from a host computer and moving our telescope. You will see the overall structure in tcsmain.c. They aren't generated by simulink.

 

Leaving out a few files will not work since the main function calls all of the other functions in the other files that are necessary. The compile goes through fine without defining _PPScriptMode_ in tcspmac.c. However, when I define _PPScriptMode_ in tcspmac.c the doubly defined errors come out. In your previous reply, you claimed that the errors were possibly from doubly including glib.h and for including RtGpShm.h unnecessarily. I have since taken those out, but the compile errors are still there when _PPScriptMode_ is defined.

 

I have looked up the locations of the errors an they are contained in pp_proj.h automatically generated header file. Here is the text

 

I know its something that I am doing, but with the provided documentation, I do not know what about _PPScriptMode_ that I am not understanding.

 

Thanks for your patience!

windell

 

C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\PowerPMACProject.ppproj(326,5): Error : tcspmac.o: In function `SetEnumGlobalVar':
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\..\..\Include\pp_proj.h(134,0): Error :  multiple definition of `SetEnumGlobalVar' 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\tcsctrl.o:..\..\Include\pp_proj.h(134,0): Error :  first defined here 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\PowerPMACProject.ppproj(326,5): Error : tcspmac.o: In function `GetEnumGlobalVar':
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\..\..\Include\pp_proj.h(139,0): Error :  multiple definition of `GetEnumGlobalVar' 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\tcsctrl.o:..\..\Include\pp_proj.h(139,0): Error :  first defined here 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\PowerPMACProject.ppproj(326,5): Error : tcspmac.o: In function `SetEnumGlobalArrayVar':
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\..\..\Include\pp_proj.h(144,0): Error :  multiple definition of `SetEnumGlobalArrayVar' 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\tcsctrl.o:..\..\Include\pp_proj.h(144,0): Error :  first defined here 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\PowerPMACProject.ppproj(326,5): Error : tcspmac.o: In function `GetEnumGlobalArrayVar':
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\..\..\Include\pp_proj.h(149,0): Error :  multiple definition of `GetEnumGlobalArrayVar' 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\tcsctrl.o:..\..\Include\pp_proj.h(149,0): Error :  first defined here 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\PowerPMACProject.ppproj(326,5): Error : tcspmac.o: In function `SetEnumCSGlobalVar':
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\..\..\Include\pp_proj.h(154,0): Error :  multiple definition of `SetEnumCSGlobalVar' 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\tcsctrl.o:..\..\Include\pp_proj.h(154,0): Error :  first defined here 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\PowerPMACProject.ppproj(326,5): Error : tcspmac.o: In function `GetEnumCSGlobalVar':
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\..\..\Include\pp_proj.h(159,0): Error :  multiple definition of `GetEnumCSGlobalVar' 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\tcsctrl.o:..\..\Include\pp_proj.h(159,0): Error :  first defined here 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\PowerPMACProject.ppproj(326,5): Error : tcspmac.o: In function `SetEnumCSGlobalArrayVar':
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\..\..\Include\pp_proj.h(164,0): Error :  multiple definition of `SetEnumCSGlobalArrayVar' 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\tcsctrl.o:..\..\Include\pp_proj.h(164,0): Error :  first defined here 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\PowerPMACProject.ppproj(326,5): Error : tcspmac.o: In function `GetEnumCSGlobalArrayVar':
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\..\..\Include\pp_proj.h(169,0): Error :  multiple definition of `GetEnumCSGlobalArrayVar' 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\tcsctrl.o:..\..\Include\pp_proj.h(169,0): Error :  first defined here 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\PowerPMACProject.ppproj(326,5): Error : tcspmac.o: In function `SetEnumPtrVar':
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\..\..\Include\pp_proj.h(174,0): Error :  multiple definition of `SetEnumPtrVar' 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\tcsctrl.o:..\..\Include\pp_proj.h(174,0): Error :  first defined here 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\PowerPMACProject.ppproj(326,5): Error : tcspmac.o: In function `GetEnumPtrVar':
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\..\..\Include\pp_proj.h(179,0): Error :  multiple definition of `GetEnumPtrVar' 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\tcsctrl.o:..\..\Include\pp_proj.h(179,0): Error :  first defined here 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\PowerPMACProject.ppproj(326,5): Error : tcspmac.o: In function `SetEnumPtrArrayVar':
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\..\..\Include\pp_proj.h(184,0): Error :  multiple definition of `SetEnumPtrArrayVar' 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\tcsctrl.o:..\..\Include\pp_proj.h(184,0): Error :  first defined here 
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\PowerPMACProject.ppproj(326,5): Error : tcspmac.o: In function `GetEnumPtrArrayVar':
C:\Documents and Settings\cleanroom\Desktop\TCS_SVN\Software\PowerPMACProject\C Language\Background Programs\TCSserv\..\..\Include\pp_proj.h(189,0): Error :  multiple definition of `GetEnumPtrArrayVar' 

Link to comment
Share on other sites

This is to do with the way DT have function definitions in the pp_proj.h file.

 

(These functions are only present in the _PPScriptMode_ and _EnumMode_ states)

 

Your TCSserv app has multiple c files with '#include "../../Include/pp_proj.h"'. This means the function definitions get compiled into multiple .o files. The linker then tries to link these together but there are multiple definitions of the same function.

 

(This can easily be demonstrated with a blank project adding a new c file to capp1 then make both c files have '#define _PPScriptMode_')

 

I think you have a few of options (maybe someone else can think of more).

 

1) Could you restructure your project to have, say, tcsmain and tcspmac as separate libraries in the Libraries folder?

 

2) It might be possible to restructure your background app to just have one C file which contains all the PPMAC interaction (basically some sort of abstraction). Then you can include pp_proj.h in only one file. This may be a lot of work for you.

 

3) You can build the file manually. I have managed to do this on your files (maybe someone knows a better way to do it, I just made it up!). It is not very convenient and I may have not explained it in enough detail!

 

Open a command prompt (as administrator maybe).

Type "path=C:\DeltaTau\Power PMAC IDE\compilers\bin;C:\DeltaTau\Power PMAC IDE\compilers\usr\local\bin"

Change to your TSCserv folder with e.g. "cd \blahblah\Background Programs\TCSserv"

Edit pp_proj.h (you will need to do this every time the IDE regenerates it)

Change the functions to be of the form:

"static void __attribute__ ((unused)) SetEnumGlobalVar(enum globalP var, double data)", this keeps the function 'private' to each .o file (and suppresses warnings about any unused functions).

In the command prompt type "make -f TCSserv_debug.mak"

This should build "PowerPMACProject\bin\Debug\TCSserv.out"

You then need to FTP this to PPMAC (after IDE build and download excluding TCSserv).

 

It will take quite a bit of manual fiddling each download.

 

4) Persuade DT to re-engineer the pp_proj.h file... :)

Link to comment
Share on other sites

Windell,

 

One of the software engineers here just told me this is actually a known bug and they will fix it. Here is his current suggested workaround until it is fixed:

 

 

#define _PPScriptMode_ // uncomment for Pmac Script type access

#define _PP_PROJ_HDR_

#include "../../Include/pp_proj.h"

 

Basically just add that second #define right after the _PPScriptMode_ define

Link to comment
Share on other sites

Charles, not wanting to speak for the OP, and not knowing for sure what firmware he has, I would like to comment:

 

The _PP_PROJ_HDR_ feature looks a little like the re-engineering I was hinting at. It certainly looks interesting and I would love some details of how it works. Plus it seems simpler than my suggestions!

 

However a quick try on the released firmware 2.0.2.14 shows no sign of the _PP_PROJ_HDR_ sections in pp_proj.h and indeed your suggestion doesn't work. I can see them in my pre-release 2.0.2.235 firmware and it does seem to compile with your suggestion.

 

The pp_proj.h Windell supplied shows no sign either, so I don't hold out much hope.

Link to comment
Share on other sites

Much Mahalos Charles and Dave for looking so deeply into this. I see what you are saying Dave about the pp_prog.h being included in multiple files. I'm happy to hear that you were able to compile my code my modifying the pp_prog.h and that is promising. I am open to any suggestions that will help make my code work easier with the way DT wants to do things.

 

The firmware version that I am running is 1.5.8.0 and the IDE build is 1.6.0.109.

 

 

 

 

 

I am not yet terribly certain which firmware build/IDE build will support this as the software engineers are having an internal discussion regarding the best way to fix this while maintaining backward compatibility.

Link to comment
Share on other sites

  • 2 weeks later...

Aloha DT,

 

Has there been any progress towards a solution to this? If not, could you suggest an alternative way to write to a global P variable and access it on the motion program without using _PPScriptMode_. I really need to make some headway on this issue.

 

thanks,

windell

Link to comment
Share on other sites

The following should work in the Cfile.c you added to a Background C Application when using “#define _PPScriptMode_” in both the main C App and the added C file:

 

#define _PPScriptMode_ // uncomment for Pmac Script type access

 

#define _PP_PROJ_HDR_ //*** THIS IS WHAT NEEDS TO BE ADDED HERE *** for the second use of _PPScriptMOde_

 

#include "../../Include/pp_proj.h"

 

You will need this for each instance.

 

Note that the above is just as easy though.

Link to comment
Share on other sites

Thanks Steve and Charles! I will try soon and will let you know.

 

 

 

The following should work in the Cfile.c you added to a Background C Application when using “#define _PPScriptMode_” in both the main C App and the added C file:

 

#define _PPScriptMode_ // uncomment for Pmac Script type access

 

#define _PP_PROJ_HDR_ //*** THIS IS WHAT NEEDS TO BE ADDED HERE *** for the second use of _PPScriptMOde_

 

#include "../../Include/pp_proj.h"

 

You will need this for each instance.

 

Note that the above is just as easy though.

Link to comment
Share on other sites

Hi Steve,

 

I just tried your suggestion and I'm still getting the same errors as the OP. Looks like I'll have to try the alternative methods that you suggest.

 

thanks,

windell

 

 

 

The following should work in the Cfile.c you added to a Background C Application when using “#define _PPScriptMode_” in both the main C App and the added C file:

 

#define _PPScriptMode_ // uncomment for Pmac Script type access

 

#define _PP_PROJ_HDR_ //*** THIS IS WHAT NEEDS TO BE ADDED HERE *** for the second use of _PPScriptMOde_

 

#include "../../Include/pp_proj.h"

 

You will need this for each instance.

 

Note that the above is just as easy though.

Link to comment
Share on other sites

Hi Steve

 

As I said to Charles in message #8 released firmware 2.0.2.14 shows no sign of the _PP_PROJ_HDR_ sections in pp_proj.h and doesn't work. I can see them in my pre-release 2.0.2.235 firmware and it does seem to compile with your suggestion.

 

Are you saying this should work in the released f/w? I too would love it if it did!

 

#define _PP_PROJ_HDR_ //*** THIS IS WHAT NEEDS TO BE ADDED HERE *** for the second use of _PPScriptMOde_

 

#include "../../Include/pp_proj.h"

Link to comment
Share on other sites

Hi Charles,

 

Unfortunately, our class ran behind enough that we just brushed over this. So I apologize for not knowing more about this before asking. Also in the training slides, where the _EnumMode_ and _PPScriptMode_ preprocessor directive are mentioned, there is no mention of the syntax to use to access the same P-variable variable on the motion program side.

 

1) I understand for _PPScriptMode_ you would use just the variable name (training slides don't mention this), but what about for _EnumMode_?

 

Thank you,

Windell

 

 

 

 

No updates yet, but you can always access P-Variables using #define _EnumMode_

 

For example, a global named "MyGlobal" can be accessed like:

 

pshm->P[MyGlobal]

 

just like explained in the training class.

Link to comment
Share on other sites

Motion programs are always written in Script and the way of accessing globals never changes in Script, regardless of whether your C programs use PPScriptMode or EnumMode. They are two completely separate programming environments. Just use the name of the global as defined on the Script side.

 

Example:

 

In global definitions.pmh:

 

global MyGlobal;

 

Script PLC:

 

open plc 1

MyGlobal++

close

 

C app:

int main(void)

{

InitLibrary()

pshm->P[MyGlobal]++;

CloseLibrary();

}

Link to comment
Share on other sites

I just tried your _EnumMode_ suggestion and I come up with the same errors as the OP. Both modes share the same set of function definitions so this is why I cannot use the _EnumMode_ either until the new firmware is released for the PMAC. So right now it seems that my only option is to read and write to these P variables manually. That is unless I want to restructure my project which does not make much sense to do.

 

Do you have any suggestions?

 

thanks,

windell

 

Motion programs are always written in Script and the way of accessing globals never changes in Script, regardless of whether your C programs use PPScriptMode or EnumMode. They are two completely separate programming environments. Just use the name of the global as defined on the Script side.

 

Example:

 

In global definitions.pmh:

 

global MyGlobal;

 

Script PLC:

 

open plc 1

MyGlobal++

close

 

C app:

int main(void)

{

InitLibrary()

pshm->P[MyGlobal]++;

CloseLibrary();

}

Link to comment
Share on other sites

Hi Steve,

 

1) Per our conversation on Friday, you said that a firmware isn't needed for your suggestion to work. Since my compile wasn't working. I did a sanity check and I went into my preprocessed pp_proj.h file looking for the _PP_PROJ_HDR_ #ifndef section that would make your suggestion work and I don't see one. However I do see a _PP_PROJ_H_ section that is essentially around the entire file. Perhaps this is what you really mean?

 

My IDE version is: 1.6.0.109

My firmware version is: 1.5.8

 

2) Also discussed on Friday, do I need to upgrade my IDE or firmware so that the automatically generated pp_proj.h file has the PP_PROJ_HDR? Or if _PP_PROJ_H_ is really what you mean, then an upgrade isn't necessary right?

 

thanks,

windell

 

 

The following should work in the Cfile.c you added to a Background C Application when using “#define _PPScriptMode_” in both the main C App and the added C file:

 

#define _PPScriptMode_ // uncomment for Pmac Script type access

 

#define _PP_PROJ_HDR_ //*** THIS IS WHAT NEEDS TO BE ADDED HERE *** for the second use of _PPScriptMOde_

 

#include "../../Include/pp_proj.h"

 

You will need this for each instance.

 

Note that the above is just as easy though.

Link to comment
Share on other sites

I have verified with the firmware engineers this feature is firmware dependent and did not exist until later 1.6.x.x versions - I believe 1.6.1.1 will have it. The required headers are uploaded from PMAC during compilation and will not be found during a "static" search of the IDE directories.
Link to comment
Share on other sites

Thanks Steve. I really appreciate you looking so deeply into this. I think this is a worthy reason to upgrade our firmware. In case the new firmware doesn't work, is there a repository of old firmware versions so that I can revert back to 1.5.8 if I need to?

 

thanks,

windell

 

 

Actually its not until a later 2.x.x.x version.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...