cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
anom217
Level 8

Error 8014 - help!

I'm in a Basic MSI project and have several functions in my setup.rul InstallScript file. I created a separate logging.rul file to contain any custom logging related functions.


prototype writeLogFile(NUMBER, STRING);

function writeLogFile(nvFileHandle, svOutput)
STRING svDate, svTime;
NUMBER nIgnore;
begin
GetSystemInfo(DATE, nIgnore, svDate);
GetSystemInfo(TIME, nIgnore, svTime);
svOutput = svDate + svTime + " " + svOutput;
WriteLine(nvFileHandle, svOutput);
end;


But whenever I compile I get the c8014 error saying the function "writeLogFile" is defined elsewhere. I know it's not in any of the other script files, I've checked. I don't understand where this error is coming from or why it's happening?

Any help, please?
Labels (1)
0 Kudos
(13) Replies
Marwan
Level 7

does it go away if you use a different function name?
0 Kudos
anom217
Level 8

Nope. I changed the name and still the same error.
0 Kudos
anom217
Level 8

anybody know what's going wrong here? This is preventing me from doing logging.
0 Kudos
RobertDickau
Flexera Alumni

Double clicking the error in the output window should take you to a troublesome part of the script; does commenting out the prototype make any difference? If you do that, does the script compile?
0 Kudos
anom217
Level 8

I just tried commenting out the prototype declarations. But then instead I get an error saying my functions have no prototype declarations.

Here is my code. LOGFILE_PATH and LOGFILE_NAME are defined in a separate file that is included.

prototype NUMBER openLogFile();
prototype writeLogFile(NUMBER, STRING);

function NUMBER openLogFile()
NUMBER nvFileHandle;
begin
OpenFileMode(FILE_MODE_APPEND);
if(ExistsDir(LOGFILE_PATH) < 0) then
CreateDir(LOGFILE_PATH);
endif;
if(OpenFile(nvFileHandle, LOGFILE_PATH, LOGFILE_NAME) < 0) then
MessageBox("Failed to open " + LOGFILE_PATH ^ LOGFILE_NAME, 0);
endif;
return nvFileHandle;
end;

function writeLogFile(nvFileHandle, svOutput)
STRING svDate, svTime;
NUMBER nIgnore;
begin
GetSystemInfo(DATE, nIgnore, svDate);
GetSystemInfo(TIME, nIgnore, svTime);
svOutput = svDate + svTime + " " + svOutput;
WriteLine(nvFileHandle, svOutput);
end;


I really don't understand why InstallShield is giving me errors for this.
0 Kudos
anom217
Level 8

I moved the functions and declarations to another file, which also has the functions that are calling these logging functions. It compiles fine then. But for some reason it gets an already defined error when I have them in the file logging.rul. I don't understand what the problem is there, but it would be nice if someone has any idea.
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

Nothing in the code posted seems to be an issue. Likely, there is something else in the file causing this behavior, or the file is being included multiple times.

Without any additional context (such as all the .rul/.h files needed to compile this code), we can't offer any specific suggestions. You may try recreating the file that includes this code, and also verify that the file is not #include'd multiple times from other .rul files. If you can send us your script files, we may be able to provide some additional guidance.
0 Kudos
anom217
Level 8

Finally found the culprit! I missed an include statement in my main script file. But since I had already included the logging.rul in another script also being included in the main file, it was causing the problem. Thanks for the help.
0 Kudos
anom217
Level 8

I think I spoke too soon. The script was compiling fine, but now I get an undefined identifier error when I added the function call. Here is the way my script files are set up.

I have 3 script files, call them FileA, FileB, and FileC. FileC has logging functions which need to be used in all of my script files. So in FileB I include FileC, because I need access to its functions. In FileA I include FileB, because it has helper functions that get called in FileA.

If I try to include FileC in FileA, I get an error saying the functions in FileC are already defined, I assume because they are already included in FileB which is included in FileA.

But if I remove the include FileC statement from FileA and try to use those logging functions, I get an undefined identifier error for those functions when called in FileA.

So how do I get access to the functions in FileC?
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

You may want to consider moving your function prototypes to a common header file that can be included by any script that needs to call the functions. To ensure the header prototypes are only processed once, use the following pattern in your header file:


#ifndef __HEADER_NAME
#define __HEADER_NAME

// add prototypes here

#endif
0 Kudos
anom217
Level 8

Okay, so I have LoggingUtility.h which looks like this

#ifndef LoggingUtility.h
#define LoggingUtility.h
prototype NUMBER openLogFile();
prototype writeLogFile(NUMBER, STRING);
#endif


I include LoggingUtility.h and LoggingUtility.rul (containing the function definitions) in my other script files, but I'm still getting the same error. It says the functions in LoggingUtility are already defined. If I remove the .rul include statement, I get the functions are not defined error.

This still doesn't seem to be working, and I'm sure other people would have run into this problem before but I can't seem to find the solution.
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

There are a couple of things that need to be changed slightly to get the script to compile:
- The function prototypes need to use the 'external' keyword to indicate they are implemented in some other script file.
- The logging.rul file needs to be included from one other .rul file (preferably setup.rul).
- Logging.rul should #include logging.h.

Here's some code that logging.h should resemble:

#ifndef __LOGGING_H
#define __LOGGING_H

external prototype NUMBER openLogFile();
external prototype writeLogFile(NUMBER, STRING);

#endif
0 Kudos
anom217
Level 8

okay, I think I got it working. thanks!
0 Kudos