Page 1 of 1

Build error, Can't open header file. What am I missing?

Posted: 20 Dec 2014 02:01
by Edward1
I'm new to MikroC Pro for 8051, and before I purchase it I just wanted to test some of my own basic code.
The included example codes, without header file references, do work perfectly. I want to use code created in Keil, with header files, in MikroC.

But when I Build projects, I receive "1 304 error: Can't open include file " 8051.h", and no Hex file is created.
(Same problem with reg51.h, reg52.h, several others.)

I have the header file listed in the Project Manager under Header Files.
The error message log contents are:

0 122 Compilation Started __Lib_Delays.c
418 123 Compiled Successfully __Lib_Delays.c
0 122 Compilation Started __Lib_GlcdFonts.c
496 123 Compiled Successfully __Lib_GlcdFonts.c
1 304 error: Can't open include file " 8051.h" #include< 8051.h> 1 error in preprocessor. C:\Documents and Settings\Ed.XPWS02\Desktop\BlinkLED5\BlinkLED5.c
0 122 Compilation Started BlinkLED5.c
2 325 Too many initializers BlinkLED5.c
0 102 Finished (with errors): 21 Dec 2014, 09:34:49 BlinkLED5.mcp51

Any guidance appreciated.
How can I correct this?

Re: Build error, Can't open header file. What am I missing?

Posted: 22 Dec 2014 09:35
by filip
Hi,

Please, can you attach your project here so I can test it ?

Regards
Filip.

Re: Build error, Can't open header file. What am I missing?

Posted: 23 Dec 2014 03:50
by Edward1
Project and header file attached.

I hope we can resolve this, no project I have with a header file will work.

Re: Build error, Can't open header file. What am I missing?

Posted: 23 Dec 2014 09:53
by filip
Hi,

I don't see the C source file, so I cannot compile the project, but by looking at the REG51.H file,
I see that it contains register definitions that are also present in the AT89C52.C definition file, located in the Uses folder of the compiler.

So, the compiler complains of the redefinition because the same registers are defined twice in the same project.

The solution is not to include REG51.H, as the definition file is already automatically included in the project from the start.

Regards,
Filip.

Re: Build error, Can't open header file. What am I missing?

Posted: 23 Dec 2014 10:44
by croket_2512
Edward1 wrote:Project and header file attached.

I hope we can resolve this, no project I have with a header file will work.
You should attach all files in your project folder. The mikroC compiler needn't REG51.H like KeilC.

Best regards.

Re: Build error, Can't open header file. What am I missing?

Posted: 24 Dec 2014 04:53
by Edward1
Sorry
This should be complete.
See attached.

Re: Build error, Can't open header file. What am I missing?

Posted: 25 Dec 2014 03:13
by croket_2512
As I said, you needn't REG51.H, because mikroC for 8051 has already it, inside mikroC, you can't see it. If you use it, the compiler will show error Identifier redifinition. Next, you needn't write delay function, because mikroC also has it. They are: Delay_us(number), Delay_ms(number), Vdelay_ms(number), Delay_Cyc(number), see in Help to know more. I also attached your project below.

Re: Build error, Can't open header file. What am I missing?

Posted: 25 Dec 2014 16:58
by Edward1
Thank you.