Menu

#1 Code won't compile as is...

open
nobody
None
5
2003-03-17
2003-03-17
Anonymous
No

This code won't compile as-is on a stock RedHat 7.2
box. It seems to use some C++ conventions. For example:

VOID ChessInit(CHAR color)
{
INT i,j,count=0;
CHAR * t;
CHAR chess[]="res/b_x.bmp";
if(color=='b')chess[4]='r';
CHAR * map[10]={
"zmxsjsxmz",
"000000000",
...

You'll get an error on the "CHAR * map[10]={" because
put it after an "if" statement. This is not legal C code.

I tried to clean it up, and got something to compile
and run, but it had some problems freeing things that
it should have. So when I click on one of the buttons
on the main screen it crashes. I could post more
details later once I can compile without making edits.

Discussion

  • RuXu W.

    RuXu W. - 2003-04-12

    Logged In: YES
    user_id=591607

    i think you should download the lastest SDL library,and compile
    again .my environment is redhat 8.0 with SDL-1.2.3

     
  • Nobody/Anonymous

    Logged In: NO

    I also have difficulty in compiling the source code via
    Dev-CPP 4.9.9.2 on windows.
    I have downloaded SDL library and put SDL.lib,SDL_mixer.lib,
    SDLmain.lib on the same directory as SDL_demo.dev
    the absolute path of SDL_mixer.lib is also updated in
    SDL_demo.dev
    Now I have the following error:
    Compiler: Default compiler
    Building Makefile: "D:\Onega\test\cchess\Makefile.win"
    Executing make...
    make.exe -f "D:\Onega\test\cchess\Makefile.win" all
    gcc.exe main.o token.o button.o chess.o combox.o edit.o
    font.o game.o map.o obj_list.o pvsp.o rules.o selimg.o
    block.o window.o trace.o audio.o -o "cchess.exe"
    -L"d:/apps/Dev-Cpp/lib" -mwindows -lwsock32 -lmingw32
    -lSDLmain -lSDL -mwindows
    "D:/Onega/test/cchess/SDL_mixer.lib" -lobjc

    d:\apps\Dev-Cpp\Bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe:
    cannot find -lSDLmain
    collect2: ld returned 1 exit status

    make.exe: *** [cchess.exe] Error 1

    Execution terminated

    I am an experienced Visual C++ programmer but not good at
    Dev-CPP. Your help is appreciated.

     
  • Nobody/Anonymous

    Logged In: NO

    steps to compile the source code with Dev-CPP
    Download
    http://www2.tw.freebsd.org/cygwin/release/gcc-mingw/gcc-mingw-objc/gcc-mingw-objc-20050522-1.tar.bz2
    and unzip libobjc.a to D:\Apps\Dev-Cpp\lib\libobjc.a
    Edit D:\Onega\test\cchess\SDL_demo.dev
    remove "-lSDLmain -lSDL" from the following line
    Linker=-lwsock32 -lmingw32 -lSDLmain -lSDL -mwindows
    "D:\Onega\test\cchess\SDL_mixer.lib"_@@_
    Build SDL library with VC++ 6.0, copy sdl.lib and
    sdlmain.lib to
    D:\Onega\test\cchess\SDL.a
    D:\Onega\test\cchess\SDLmain.a
    Add sdl.a and sdlmain.a to Dev-CPP project options
    ->parameters: linker
    Modify D:\Onega\test\cchess\main.c
    int APIENTRY WinMain( HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
    )
    /*INT main(INT argc,CHAR * argv[])*/
    {
    GlobalInit();
    Game_UIMain();
    Game_Exec();
    }

    The build problem is fixed by phoenix96_2000(eXMe). He also
    faced undefined references to '_alloca_probe' problem and
    fixed it via adding winmm library -lwinmm

     

Log in to post a comment.

MongoDB Logo MongoDB