I'm using Borland 5.5 to compile this script:
1 | #include <stdlib.h> |
2 | #include <allegro.h> |
3 | #include <winalleg.h> |
4 | |
5 | int main(int argc, char *argv[]) { |
6 | allegro_init(); |
7 | install_keyboard(); |
8 | set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0); |
9 | clear_to_color(screen, makecol(0,0,0)); |
10 | text_mode(-1); |
11 | textprintf(screen,font,0,0,makecol(255,255,255),"Hello world"); |
12 | |
13 | readkey(); |
14 | |
15 | allegro_exit(); |
16 | return 0; |
17 | } |
18 | END_OF_MAIN(); |
And I get an error...
Error: Unresolved external '_main' referenced from C:\BORLAND\BCC55\LIB\C0X32.OBJ
I thought I knew how to fix this, but after an hour, I'm still clueless
You don't need the semicolon after END_OF_MAIN(). Also, are you sure you have the IDE linking against Allegro? In addition to that, why are you including winalleg.h? As far as I can tell, with the code you have there, you don't need to include it. I may be wrong though. I've never used Borland to compiled anything in regards to Allegro.
hmm.... you did include liballeg? That's the only thing I can think of.
I think you have to COMMENT OUT the "#include <winalleg.h>", which is more for if the allegro stuff is just a module in a larger windows prog?
why borland? Try mingw?
BAF, have you ever used the Turbo Debugger? I like it way better than any other debugger including gdb. Once you get it working then back to mingw! (Some small tests I did had Borland anywhere as fast as mingw on the "good" end to 20 percent slower on the "bad" end, and LCC was 70 percent slower! Although asm beat them all by 20 percent) (mandelbrot set)
_main is used by DOS and console projects. When you create a Win32 project, it will try to use _WinMain. So, you built a console project. Try adding #define ALLEGRO_USE_CONSOLE before including Allegro, or create a Win32 project instead of a console one.
I've tried everything suggested here, (except for ReyBrujo's suggestion to make a win32 project,) and none of them work. Borland doesnt use projects (as far as i know), so how would I go about building this program as a Win32 project... I tried #define ALLEGRO_USE_CONSOLE but still got the same error >.<
[edit]
Ok, adding the -tW switch builds it as a win32 program. Now I'm getting almost the same error, but windowsafied -- Unresolved external 'WinMain' referenced from C:\BORLAND\BCC55\LIB\C0W32.OBJ.
If I include the winalleg.h, it gives me a list of errors --
Error: Unresolved external '_install_allegro' referenced from C:\BORLAND\BCC55\BIN\MAIN.OBJ Error: Unresolved external '_install_keyboard' referenced from C:\BORLAND\BCC55\BIN\MAIN.OBJ Error: Unresolved external '_set_gfx_mode' referenced from C:\BORLAND\BCC55\BIN\MAIN.OBJ Error: Unresolved external '_text_mode' referenced from C:\BORLAND\BCC55\BIN\MAIN.OBJ Error: Unresolved external '_makecol' referenced from C:\BORLAND\BCC55\BIN\MAIN.OBJ Error: Unresolved external '_font' referenced from C:\BORLAND\BCC55\BIN\MAIN.OBJ Error: Unresolved external '_screen' referenced from C:\BORLAND\BCC55\BIN\MAIN.OBJ Error: Unresolved external '_textprintf' referenced from C:\BORLAND\BCC55\BIN\MAIN.OBJ Error: Unresolved external '_readkey' referenced from C:\BORLAND\BCC55\BIN\MAIN.OBJ Error: Unresolved external '_allegro_exit' referenced from C:\BORLAND\BCC55\BIN\MAIN.OBJ Error: Unresolved external '__WinMain' referenced from C:\BORLAND\BCC55\BIN\MAIN.OBJ
Now all your errors are linking errors, so you forgot to link against Allegro library. Which command line you used? You forgot to put alleg.lib somewhere.
I've tried
bcc32 -IC:\borland\bcc55\include -LC:\borland\bcc55\lib -LC:\borland\bcc55\lib\alleg.lib -tW main.cpp //same WinMain error
and
bcc32 -IC:\borland\bcc55\include -LC:\borland\bcc55\lib\alleg.lib -tW main.cpp //unable to open C0W32.obj
figure out cow32..
Try #define ALLEGRO_NO_MAGIC_MAIN too.
w00t! I finally got it -- even though my program crashes.. Hehehe...
At least it compiles!
Ok, so what I finally had to do was only include stdlib.h and allegro.h.
For my command line use
bcc32 -IC:\borland\bcc55\include -LC:\borland\bcc55\lib -tW main.cpp
I thought I had tried this before -- apparently it liked me this time and let me compile... Now I have to figure out why its crashing
Thanks so very much guys!
[edit]
So basically...from what I've tested, my compiler doesnt compile win32 applications correctly. [?] =/ Umm... I tried to compile a simple program like this:
It crashes too... Its nothing that has to do width Allegro -- sence I compiled this dependant of Allegro. I compiled it without the -tW switch, and it works fine.
What does -tW do?
compiles as a win32 application.
[edit]
That was a close one, tobi (msg below) xD
BAF:
Ok, adding the -tW switch builds it as a win32 program.
EDIT: beaten
After 12 hours...Still no luck xD
Check makefile.bcc, there is the command line used to compile with Borland BCC. Search for the ilink command.
Make config files:
Bcc32.cfg
-DWINVER=0x0400
-D_WIN32_WINNT=0x0400
-I"c:\Borland\Bcc55\include"
-L"c:\Borland\Bcc55\lib"
Ilink32.cfg
-L"c:\Borland\Bcc55\lib"
Options:
-DWINVER=0x0400
-D_WIN32_WINNT=0x0400
are undocumented but they are necessary for winXP.
And "-tW" option is for WINAPI programs and for allegro, I think, you need command line window program (both types are WIN programs, command line isn't DOS program ).
[url]
http://www.webnotes.org/bcc55eng.htm
[/url]
(Copy and paste this link as text into your browser, it doesn't work directly, I don't know why...)
COX32.obj is run time library, I had problem with it at start of manual compiling and linking. If you first create *.obj and next you want link *.obj files you have to add to linker command line switches run time libraries explicite. So the best way is to compile and link at once.
I have found it, the best link, you have everything about manual linking here:
[url]
http://www.winprog.org/tutorial/bcpp.html
[/url]
(Copy and paste this link as text into your browser, it doesn't work directly, I don't know why...)
I used bcc5.5 but I have checked that gcc (devc++ or with cygwin) under winXP gives much faster code.
COX32.obj is run time library, I had problem with it at start of manual compiling and linking. If you first create *.obj and next you want link *.obj files you have to add to linker command line switches run time libraries explicite. So the best way is to compile and link at once.
How do I go about doing this?
:borland n00b:
...Sorry about takin so long to reply; was on vacation.
and for allegro, I think, you need command line window program
No, you want a windowed application, even if your program runs full screen
Could you write, once again, command line you actually use.
Did you make Bcc32.cfg and Ilink32.cfg files?
Did you read /allegro-x.x.x/docs/build/bcc32.txt file (section Using Allegro) ?
Could you write, once again, command line you actually use.
I change it up all the time...but its something like
bcc32 -Lc:\borland\bcc55\lib -Ic:\borland\bcc55\lib -tW main.cpp
Did you make Bcc32.cfg and Ilink32.cfg files?
Did you read /allegro-x.x.x/docs/build/bcc32.txt file (section Using Allegro)?
Yes.
bcc32 -Lc:\borland\bcc55\lib -Ic:\borland\bcc55\lib -tW main.cpp
( -Ic:\borland\bcc55\lib )
"-I" switch is path to include folder not to lib folder
------------------------------------
bcc32 -Lc:\borland\bcc55\lib -Ic:\borland\bcc55\lib -tW main.cpp
-------------------
Did you make Bcc32.cfg and Ilink32.cfg files?
Yes.
-------------------
So you don't need in command line "-L" and "-I" switches because you have it in Bcc32.cfg file.
-------------------
Do you have allegro.lib file in:
c:\borland\bcc55\lib
Do you have allegro headers in:
c:\borland\bcc55\include
Do you have allegro.dll in system folder?
bcc32 -Lc:\borland\bcc55\lib -Ic:\borland\bcc55\lib -tW main.cpp
main.cpp is:
allegro program or
"hello world" command line program or
"hello world" WINAPI program?
If it's allegro program you have to add to command line allegro.lib file that has information about functions in allegro.dll (*.lib is export library for *.dll dynamic library)
If it's only "hello ..." command line program "-tW" option is bad.
If it's "hello ..." GUI program "-tW" option is necessary but you need code for creating example windows window (calling WINAPI functions) (about one page of code), not simply "hello ..." code with main() function.
********************************************
EDIT:
HA HA HA HA HA HA HA HA HA.......;D
---------------------------------------------------------------
E:\E\src\allegro\examples>bcc32 exhello.c alleg.lib -tW
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
exhello.c:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_main' referenced from C:\BORLAND\BCC55\LIB\C0X32.OBJ
E:\E\src\allegro\examples>
---------------------------------------------------------------
E:\E\src\allegro\examples>bcc32 -tW exhello.c alleg.lib
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
exhello.c:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
E:\E\src\allegro\examples>
----------------------------------------------------------------
Do you see the difference !!!
HA HA HA, 5 days, HA HA HA ......
********************************************
ROTFL! but theres still a problem...
Um... when i try to run my program -- it crashes... I have the dlls in the folder, and not using any other outside sources...
Two words:
1. mingw
2. gdb
Um... when i try to run my program -- it crashes... I have the dlls in the folder, and not using any other outside sources...
Did you try compile hello world allegro program "exhello.c" form examples directory. I have compiled it, and it runs without problems.
I have used precompiled allegro library for bcc32 from allegro home download page.
Try compile "exhello.c" !
I'm using Borland 5.5 to compile this script:
I have compiled and run successfully your test program.
If you set everything as I said, and you use command:
bcc -tW myProg.c alleg.lib
(-tW switch at first place, as I have shown)
It should works. It works for me.
(use precompiled library)
Two words:...
I hate them both compared to borland xD
Still no. check out my attatchment ;]
It looks not good...
Do you use win98 ?
I have made everything under winXP.
Yeah I used 98... =/
I'll try to compile it on my brother's comp when i get back from vacation (monday...) He runs XP.
[EDIT]
Still nothing... >.<