Error - Main function is not defined

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
albon
Posts: 1
Joined: 28 Sep 2009 04:12

Error - Main function is not defined

#1 Post by albon » 28 Sep 2009 04:24

I am trying a very simple program just to test proraming a 16F628A
Here is the program as typed in the compiler editor:
program gencontrol
main:
' Main program
TRISB = 0
eloop:
PORTB = $FF
Delay_ms(1000)
PORTB = 0
Delay_ms(1000)
goto eloop
end.

I click on Project>Build

It returns with following error messages:
357 main function is not defined
452 Unsucessful linking 'GENCONTROL.mbppi'
102 Finished (with errors)

Project manager has the following files listed:
Sources>
gencontrol.mbas
Output Files>
gencontrol.asm

no hex file nothing else.

I have tried searchig if someone had a similar problem but no luck.

PLEASE HELP

Colin
Posts: 738
Joined: 15 Oct 2007 08:53
Location: Australia

#2 Post by Colin » 28 Sep 2009 10:20

The program compiles fine and without errors on my system :?:

User avatar
mileta.miletic
mikroElektronika team
Posts: 493
Joined: 05 Jun 2009 14:46
Location: Belgrade, Serbia
Contact:

Re: Error - Main function is not defined

#3 Post by mileta.miletic » 30 Sep 2009 15:32

Hi,

please send your project (project folder with all files in it) to support desk http://www.mikroe.com/en/support/
Regards,
Mileta

vbcoder
Posts: 52
Joined: 20 Nov 2008 18:23
Location: 6 October City, Egypt
Contact:

#4 Post by vbcoder » 02 Oct 2009 19:30

Hi Albon,
It happened to me once. Copy your code to a new project and it shall work fine.
--------------------------------
Kind Regards,
Waleed El-Badry
Teaching Assistant
Mechatronics Engineering Department
Misr University for Science & Technology

pierred35
Posts: 13
Joined: 15 Nov 2009 10:56

452 Unsucessful linking 'boot_test.mbppi'

#5 Post by pierred35 » 15 Nov 2009 11:06

I have exactly the same problem with the code comming from mikroElektronika:
C:\Logiciels\MikroBasic\Examples\Other\Bootloader\P18\32K\boot_test.mbppi

It returns with following error messages:
452 Unsucessful linking 'GENCONTROL.mbppi'
102 Finished (with errors)

I tried to copy the code in a new project as explain here:
http://www.mikroe.com/forum/viewtopic.p ... ul+linking
but the problem is still here.

Does it exist a solution?
Thanks for your help.

vbcoder
Posts: 52
Joined: 20 Nov 2008 18:23
Location: 6 October City, Egypt
Contact:

#6 Post by vbcoder » 15 Nov 2009 11:30

Did you check your project search paths?

Go to Project> Edit Search paths and make sure they point to the correct folder.

I compiled the example mentioned and it works fine.

Image
--------------------------------
Kind Regards,
Waleed El-Badry
Teaching Assistant
Mechatronics Engineering Department
Misr University for Science & Technology

pierred35
Posts: 13
Joined: 15 Nov 2009 10:56

#7 Post by pierred35 » 15 Nov 2009 12:02

My MikroBasic Pro is installed here : C:\Logiciels\MikroBasic\

In the Project> Edit Search, I have :
C:\Logiciels\MikroBasic\Defs\
C:\Logiciels\MikroBasic\Uses\P18\
C:\Logiciels\MikroBasic\Examples\Other\Bootloader\P18\32K\

I tried to build project with a Pic 18F4550, anf I have put these files in the project:
boot_test.mbas
boot18_32K.mbas
and P18F4550.mbas from C:\Logiciels\MikroBasic\Defs\ but the result is the same with or without this file.

Thanks for your help

pierred35
Posts: 13
Joined: 15 Nov 2009 10:56

#8 Post by pierred35 » 15 Nov 2009 12:23

So I reinstalled mikroBasic Pro exactly in the same location, I tried to open the boot_test.mbppi and to build it without any code modification ans it works perfectly now! I don't understand.
Thanks

vbcoder
Posts: 52
Joined: 20 Nov 2008 18:23
Location: 6 October City, Egypt
Contact:

#9 Post by vbcoder » 15 Nov 2009 18:14

You might have unchecked few necessary files in the Library managers. When you reinstalled the compiler, you got back the original setting.

It is only a speculation :roll:

Glad your problem is solved.
--------------------------------
Kind Regards,
Waleed El-Badry
Teaching Assistant
Mechatronics Engineering Department
Misr University for Science & Technology

roys29
Posts: 106
Joined: 13 Oct 2009 15:09

#10 Post by roys29 » 16 Nov 2009 12:14

I've had the same problem; here's how to fix it:

Click on Project Manager on the right side of your screen.

Click on the plus sign (+) to the left of your program name. There should be a plus sign (+) to the left of the Sources folder.

Click on the plus sign (+) to the left of the Sources folder. This should be the name of your program.

If there is no plus sign (+) to the left of the Sources folder, you will get the error you have described. To fix this, RIGHT click on the Sources folder, then click on Add File to Project... Locate your program file, click on it, then click the Open button. This will fix the problem. :wink:

NuMcA
Posts: 37
Joined: 24 Dec 2009 17:08
Location: Athens, Greece
Contact:

Re:

#11 Post by NuMcA » 07 May 2010 01:24

roys29 wrote:I've had the same problem; here's how to fix it:

Click on Project Manager on the right side of your screen.

Click on the plus sign (+) to the left of your program name. There should be a plus sign (+) to the left of the Sources folder.

Click on the plus sign (+) to the left of the Sources folder. This should be the name of your program.

If there is no plus sign (+) to the left of the Sources folder, you will get the error you have described. To fix this, RIGHT click on the Sources folder, then click on Add File to Project... Locate your program file, click on it, then click the Open button. This will fix the problem. :wink:
Had the same problem,
SOLVED by your answer!
THANK YOU!
My simulation cockpit and other projects: www.numca.grImage

ilferrari
Posts: 195
Joined: 18 Nov 2013 09:09

Re: Error - Main function is not defined

#12 Post by ilferrari » 20 Jan 2016 09:43

I sometimes have the same issue, it is caused when the project file loses the entry for the main module. You can also edit the project file as follows:

Code: Select all

[FILES]
Count=1
File0=mainmodule.mbas

jacktaylor
Posts: 12
Joined: 28 Aug 2017 23:20

Re: Error - Main function is not defined

#13 Post by jacktaylor » 30 Apr 2018 19:52

I've had the same problem; here's how to fix it:

Click on Project Manager on the right side of your screen.

Click on the plus sign (+) to the left of your program name. There should be a plus sign (+) to the left of the Sources folder.

Click on the plus sign (+) to the left of the Sources folder. This should be the name of your program.

If there is no plus sign (+) to the left of the Sources folder, you will get the error you have described. To fix this, RIGHT click on the Sources folder, then click on Add File to Project... Locate your program file, click on it, then click the Open button. This will fix the problem. :wink:

/*Excellent observation and help in error correction. The strange thing is that I had compiled without any problem the program a day ago and the next day came this error. But you can fix it by reinserting the .c file*/

Thank you my friend.

wlaksahan@gmail.com
Posts: 1
Joined: 10 Dec 2023 09:22

Re: Error - Main function is not defined

#14 Post by wlaksahan@gmail.com » 10 Dec 2023 09:26

You can see your project Manager window at right side. when you see under Source, maybe there no any source files are linked to your current project. so first thing you have to do is Right click on Source and add new or add exiting source files. :D :)

Post Reply

Return to “mikroBasic PRO for PIC General”