Creating library file and reference it

 

Hello Everyone,

I am traying to create my own library and referring to it from my EA code

under MQL4\Libraries I have my amrBungees.mq4 and the ex4 which include my functions 

under \MQL4\Include I have amrBungees.mqh 

#import "amrBungees.ex4"

short yellowBungee();
short greenBungee();
short blueBungee();
short redBungee();
short purpleBungee();
short blackBungee();

#import

In my EA code at the top I have this line of code 

#include <amrBungees.mqh>

Later in my EA code I call one of the library functions as follows

 putValue((string)yellowBungee(),"adsfwedee",400,500-60);

the putValue is just function which how text on the chart

When I run my EA I got the following errors:

2022.04.25 04:52:35.720 2009.03.16 00:00:00  Cannot find 'yellowBungee' in 'amrBungees.ex4'

2022.04.25 04:52:35.720 2009.03.16 00:00:00  My EA,M1: unresolved import function call

Any help will be appreciated 

Thank you


 
MOHAMED AMR MOHAMED OSAMA I ABDELWAHAB:

2022.04.25 04:52:35.720 2009.03.16 00:00:00  Cannot find 'yellowBungee' in 'amrBungees.ex4'

Your code and structure looks correct, so I'd double check the existence of yellowBungee (along with correct spelling and return type) in amrBungees.mq4. Also, make sure to compile the mq4 file.

 
MOHAMED AMR MOHAMED OSAMA I ABDELWAHAB:

Hello Everyone,

I am traying to create my own library and referring to it from my EA code

under MQL4\Libraries I have my amrBungees.mq4 and the ex4 which include my functions 

under \MQL4\Include I have amrBungees.mqh 

In my EA code at the top I have this line of code 

Later in my EA code I call one of the library functions as follows

the putValue is just function which how text on the chart

When I run my EA I got the following errors:

2022.04.25 04:52:35.720 2009.03.16 00:00:00  Cannot find 'yellowBungee' in 'amrBungees.ex4'

2022.04.25 04:52:35.720 2009.03.16 00:00:00  My EA,M1: unresolved import function call

Any help will be appreciated 

Thank you


Did you use the export postmodifier in the library file at the function declaration? 

 
Alexander Martinez #:

Your code and structure looks correct, so I'd double check the existence of yellowBungee (along with correct spelling and return type) in amrBungees.mq4. Also, make sure to compile the mq4 file.

As Laszlo said, I wasn't using export postmodifier, this was my problem,

Thank you

 
Laszlo Tormasi #:

Did you use the export postmodifier in the library file at the function declaration? 

int Function() export
  {
  }


I didn't now and this is fixed it, thank you sooooooo much 

 

Perhaps you should read the manual. Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference

Constant Type Description
library   A library; no start function is assigned, functions with the export modifier can be imported in other MQL4-programs