Board index » cppbuilder » Borland not like SDL? Me not get things?

Borland not like SDL? Me not get things?


2003-07-11 03:12:18 AM
cppbuilder61
I'm also having some trouble getting SDL(1.2.5) to work with Borland's
5.5 commandtools. I'm using Vide also btw and I have set up to include
the SDL include header directories, lib directories etc. but I still
can't get something as simple as this to compile:
#include "SDL.h"
int main()
{
return 0;
}//main
The error msg is coming from the linker w/ the following msg:
Quote
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
! Error: Unresolved external 'WinMain' referenced from E:\BORLAND\BCC55
\LIB\C0W32.OBJ
I have also tried a few other variations like making a console
application instead but I get this same msg only it's 'Unresolved
external 'Main' instead of WinMain. I also tried including the SDL_main.h
header file but that didn't seem to help with anything.
Finally, I have also looked at the FAQ over at
www.libsdl.org/faq.php
and included all the switchs and parameters they have specified there. It
still does not work, I keep getting errors either from my compiler or
linker or something!
Oh and one more thing, I have converted the SDL.lib and SDLmain.lib files
to the appropriate format for borland's compiler using the implib.exe and
coff2omf.exe commands so this should not be an issue either.
UGHHH! please help me!
 
 

Re:Borland not like SDL? Me not get things?

Vivi Orunitia wrote:
Quote
I'm also having some trouble getting SDL(1.2.5) to work with Borland's
5.5 commandtools. I'm using Vide also btw and I have set up to include
the SDL include header directories, lib directories etc. but I still
can't get something as simple as this to compile:
Don't know what sdl is but,
Quote
! Error: Unresolved external 'WinMain' referenced from E:\BORLAND\BCC55
\LIB\C0W32.OBJ
the linker message it appears that you're using the wrong switches to
compile your sample.
For console windows, you must have a int main() and compile it with the
-tWC switch and for Windows gui, you have a WinMain() and you compile it
with the -tW switch.
Look in the bcbtools.hlp file shipped with the free commandline tool
package for details about the switches.
Michel
--
----------------------------------------
Michel Leunen
mailto: XXXX@XXXXX.COM
www.leunen.com/cbuilder/
----------------------------------------
 

Re:Borland not like SDL? Me not get things?

Quote
I'm not sure I get how to do the earlier suggestion of compiling the
sdl_main.c into an object file. What exactly do I need to do to use the
sdl library inside my programs?

Thanks
Ok, let's see...
You should have downloaded the Win32 SDL Runtime, which you must have if
you ran implib on "SDL.dll". You should also have downloaded the SDL
Source Code "SDL-1.2.5a-win32.zip", I assume you know where you
extracted the files to. Now, go to that directory and in that directory
there should be a subdirectory: "Include". You have to options here, you
can
a) copy the contents of this directory directly into Borlands \Include
directory
b) Create a new folder in Borland's \Include directory (I named my
"SDL"), and then copy the aforementioned files into our new directory.
If you choose (b) remember to change your #include directives to...
#include <SDL/SDL.h>//notice the "SDL/"
I am going to assume you chose (b)
Ok, almost there now... Before we move on, you may as well move the
SDL.lib file you created into Borland's \Lib directory. (As well as any
other SDL*.lib files you have. )
Now, Open a DOS Prompt and go to the SDL SDK directory
"cd C:\yourPath\SDL-1.2.5"
From there we need to go to the \src\main\win32 directory so...
"cd src\main\win32"
if you type "dir" and hit Enter you should see a directory: "exports",
and a file: "SDL_main.c". Ignore the directory, we don't care about
that. So we've found SDL_main.c, you going to have to edit a couple of
the includes, so open SDL_main.c in your text editor (or whatever).
Now, go to lines 16 and 17 (You shouldn't even need to scroll ;) )...
Change the from this...
#include "SDL.h"
#include "SDL_main.h"
to this...
#include <SDL\SDL.h>
#include <SDL\SDL_main.h>
Now save, close it out and go back to the DOS prompt. Once there type...
"bcc32 -c -tW -DWIN32 SDL_main.c" and hit Enter
There should now be a a file called "SDL_main.obj" in the current
directory. You can just move this file into your projects directory, but
I recommend moving it into Borlands \Lib directory.
And you should be good to go now. ::crosses his fingers::
 

{smallsort}

Re:Borland not like SDL? Me not get things?

Ok, here's basically what I've done, maybe you can spot out something I
forgot to do.
I've downloaded the development libraries(SDL-devel-1.2.5a-VC6.zip) and I
extracted them into E:\Borland\BCC55\SDL-1.2.5. I also downloaded the
source extracted them to a temp directory.
Next I located the SDL_main.c like you said and I compiled the object
successfully. Btw, I had to include the -I and -L switches to my SDL-
1.2.5\include and SDL-1.2.5\lib directory but finally got the object file
made from it. Mind you I didn't change the 16 and 17 line in the source
file. I figured that I should be able to add the needed paths in the Vide
later on. Finally I then moved the sdl_main.obj into E:\Borland\BCC55
\SDL-1.2.5\lib.
I fired up Vide started a new project and typed this in:
#include "SDL.h"
int main()
{
return 0;
}//main
Afterwards I went to project->edit. Under the Compiler Flags field I have
these switches set: -tW -DWIN32 -y -v -c. Under Linker flags I have
these: -v -Tpe -aa -c. Under Paths->Include Paths I added $(BCCROOT)
\SDL-1.2.5\include. Under Library Paths I added $(BCCROOT)\SDL-1.2.5\lib.
Under the Library files I added SDL.lib so now the list looks like so:
SDL.lib
import32
$(BCC32RTLIB)
I finally click ok, save all, tried to compile. It gave me a linker error
saying 'Unresolved external 'WinMain. Ok so I thought to myself maybe I
need to include that sdlmain.obj I made earlier. So I went to project
edit again located files and added that in. So now the list of files past
to the compiler looks like this:
Test.cpp (my test containing the code above)
..\BCC55\SDL-1.2.5\lib\SDL_main.obj
I click ok and save all again. Goto compile and got this:
! Error: Unresolved external '_SDL_main' referenced from E:\BORLAND\BCC55
\SDL-1.2.5\LIB\SDL_MAIN.OBJ
So all in all, it feels like I'm getting close but still not quite
getting there! What else could I possibly be forgetting that's keeping
this from working?
Thanks again
 

Re:Borland not like SDL? Me not get things?

Michael < XXXX@XXXXX.COM >wrote in news:3f0e4144$1
@newsgroups.borland.com:
Quote

Well, try changing...

int main() {
return 0;
}

to

int SDL_main(int argc, char *argv[]) {
return 0;
}

And yes it is good that you linked sdl_main.obj, as I said you need to
link that with all SDL projects.


omg! it worked! thank you thank you thank you! I can't believe it
compiled finally, I thought I would never get this silly thing working :p
Ok, it looks like the real thing that needs to be included are the arc
and argv[] otherwise it doesn't seem like SDL will recognize it. So now
even this code will compile correctly(w/some warnings but it'll work)
int main(int argc, char *argv[])
{
return 0;
}
I always thought those two parameters were optional though but I guess
SDL needs em. I'm relieved, that's one problem down :)
Thanks again
 

Re:Borland not like SDL? Me not get things?

Quote
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Ok, it looks like the real thing that needs to be included are the arc
and argv[] otherwise it doesn't seem like SDL will recognize it. So now
even this code will compile correctly(w/some warnings but it'll work)
int main(int argc, char *argv[])
{
return 0;
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Yeah, the reason I say use SDL_main is I still, from time to time,
have problems with using just "main" (usually when compiling .cpp files).
Quote
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
I always thought those two parameters were optional though but I guess
SDL needs em. I'm relieved, that's one problem down
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
They are, but SDL defines them, so we have to as well. You see, our
main() isn't the real entry point of the program. Under Windows SDL uses
WinMain() and takes care of all the windows stuff, then passes
"control" to our main()
Anyway, I'm glad I could be of assistance. It took me quite some time to
get all of this working, so I'm very happy I can spread the wealth :)