Compile via makefile?

This is a discussion on Compile via makefile? within the C++ Programming forums, part of the General Programming Boards category; A makefile, for a kde project of the same name, that is an empty project nothing added to it is ...

  1. #16
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    A makefile, for a kde project of the same name, that is an empty project nothing added to it is even more complex than the first one I posted. It's 785 lines long.

    the "defaults" for a kde application do include dcom, and a base gui for the application though. [ menu, toolbars, the sockets and events. ]
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  2. #17
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Hmm, I deleted my other compiler, heres my error:

    Code:
    C:\Borland\BCC55\Bin>make -f C:\make.mak
    MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
            C:\Borland\BCC55\Bin\..\BIN\ilink32 @MAKE0000.@@@
    Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
    Fatal: Unable to open file 'VCL.BPI'
    
    ** error 2 ** deleting forgers.exe
    
    C:\Borland\BCC55\Bin>C:\borland\bcc55\bin\make -f C:\make.mak
    MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
            C:\borland\bcc55\bin\..\BIN\ilink32 @MAKE0000.@@@
    Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
    Fatal: Unable to open file 'VCL.BPI'
    
    ** error 2 ** deleting forgers.exe
    I just get more and more lost >.>. You said the code you gave me will compile a blank windows application? But, my window app isint blank :/.

    Heres my forgers.cpp code if it helps:
    Code:
    #include "forgers.h"
    #include <windows.h>
    #pragma resource "forgers.res"
    
    const char g_szClassName[] = "myWindowClass";
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
     switch(msg){
    
      case WM_LBUTTONDOWN: {
       char szFileName[MAX_PATH];
       HINSTANCE hInstance = GetModuleHandle(NULL);
    
       GetModuleFileName(hInstance, szFileName, MAX_PATH);
       MessageBox(hwnd, szFileName, "This program is:", MB_OK | MB_ICONINFORMATION);
      }
      break;
            
      case WM_CLOSE:
       DestroyWindow(hwnd);
       break;
    
      case WM_DESTROY:
       PostQuitMessage(0);
       break;
      default:
       return DefWindowProc(hwnd, msg, wParam, lParam);
     }
     return 0;
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
     WNDCLASSEX wc;
     HWND hwnd;
     MSG Msg;
    
     wc.cbSize        = sizeof(WNDCLASSEX);
     wc.style         = 0;
     wc.lpfnWndProc   = WndProc;
     wc.cbClsExtra    = 0;
     wc.cbWndExtra    = 0;
     wc.hInstance     = hInstance;
     wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
     wc.lpszMenuName  = NULL;
     wc.lpszClassName = g_szClassName;
     wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
    
     if(!RegisterClassEx(&wc)) {
      MessageBox(NULL, "Window Registration Failed!", "Error!",
      MB_ICONEXCLAMATION | MB_OK);
      return 0;
     }
    
     hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, g_szClassName, 
            "The title of my window", WS_OVERLAPPEDWINDOW, 
            CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
            NULL, NULL, hInstance, NULL);
    
     if(hwnd == NULL) {
      MessageBox(NULL, "Window Creation Failed!", "Error!",
      MB_ICONEXCLAMATION | MB_OK);
      return 0;
     }
    
     ShowWindow(hwnd, nCmdShow);
     UpdateWindow(hwnd);
    
     while(GetMessage(&Msg, NULL, 0, 0) > 0) {
      TranslateMessage(&Msg);
      DispatchMessage(&Msg);
     }
     return Msg.wParam;
    }
    I'm lost with all theyse definitions >.>. So, how do I fix this VCl.bpi problem? (Once again when I delete it from packages, it does nothing, the next package in line becomes the problematic one.

    Sorry for being so thick :/.
    Last edited by Blackroot; 01-20-2006 at 08:11 PM.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  3. #18
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Quote Originally Posted by Blackroot
    have been stumped for a few days how to add a .rc or .res file
    The simplest way is to compile the source with bcc32, compile any resource scripts with brcc32 and then link those objects with ilink32.

    By way of illustration here's a quick example that creates a modal dialogbox from a resource; first the source file:
    Code:
    //winmain.cpp
    #include <windows.h>
    #include "resources.h"
    
    INT_PTR CALLBACK DlgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM)
    {
    switch (uMsg)
      {
      case WM_COMMAND:
        {
        WORD wID=LOWORD(wParam);
        
        if (wID==IDOK || wID==IDCANCEL)
          {
          EndDialog(hwnd,wID);
          }
        return 0;
        }
      default:
        return 0;
      }
    }
    
    int WINAPI WinMain(HINSTANCE hInst,HINSTANCE,LPSTR,int)
    {
    return DialogBox(hInst,MAKEINTRESOURCE(IDD_DLG),0,DlgProc);
    }
    then the resource script
    Code:
    //script.rc
    #include "resources.h"
    
    IDD_DLG DIALOG  0, 0, 222, 144
    STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | 
        WS_CAPTION | WS_SYSMENU
    CAPTION "BCC55 Cmd Line Tools: Resources"
    FONT 8, "MS Sans Serif"
      {
      DEFPUSHBUTTON   "OK",IDOK,80,110,51,15
      }
    and, finally, the resource header
    Code:
    //resources.h
    #define IDD_DLG 1000
    So, from the command line you would compile and link each in turn as follows:
    Code:
    bcc32 -c winmain.cpp
    brcc32 script.rc
    ilink32 -aa c0w32.obj winmain.obj,test.exe,,import32.lib cw32.lib,,script.res
    The same can be achieved with a makefile. I've used the original one you posted but trimmed it down so that there's very little to it but I've replaced some of the macro names to correspond more to the bcc55 documentation on ilink32 which you should refer to:
    Code:
    #makefile.mak
    CFLAGS=-c
    LFLAGS=-aa
    STARTUPOBJS=c0w32.obj 
    LIBS=import32.lib cw32.lib
    MYOBJS=winmain.obj
    RESOBJS=script.res
    EXENAME=test.exe
    
    $(EXENAME): $(MYOBJS) $(RESOBJS)
    	ilink32 $(LFLAGS) $(STARTUPOBJS) $(MYOBJS),$(EXENAME),,$(LIBS),,$(RESOBJS)
    This would be invoked from the command line with:
    Code:
    make -f makefile.mak
    Note that ilink32 will invoke the compiler and resource compiler to resolve dependencies. Note also that some macros, such as 'CFLAGS' and 'LFLAGS' are 'known' to the build process; defining them just lets you override default settings. The makefile only has one rule '$(EXENAME)', which has been defined as 'test.exe, and it has two dependencies, namely '$(MYOBJS)', defined as 'winmain.obj' which the source file will be compiled into and '$(RESOBJS)', (defined as 'script.res' which script.rc will be compiled into) ie. in order to build 'test.exe' both 'winmain.obj and script.res must be present. The last line invokes the linker using the normal syntax expected for ilink32 (see bcc55 docs).

    I hope that is of some use to you.

    *****************
    # ---------------------------------------------------------------------------
    # MAKE SECTION
    # ---------------------------------------------------------------------------
    # This section of the project file is not used by the BCB IDE. It is for
    # the benefit of building from the command-line using the MAKE utility.
    # ---------------------------------------------------------------------------
    I've looked at this again and still don't think this auto-generated makefile will work as is. There are two reasons for this. Firstly there don't appear to be any conditionals which would cause the 'builder' stuff to be excluded (vcl, for example). Secondly, I checked it to make sure and got more or less the same errors as the OP posted earlier. I may have missed something, though, so would appreciate any explanation that anyone may care to give regarding how this makefile could be used, unmodified (except for file/object names) to build a simple, non-borland specific program.
    Last edited by Ken Fitlike; 01-20-2006 at 08:34 PM. Reason: typos
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  4. #19
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>So, how do I fix this VCl.bpi problem?<<

    If you don't have borland builder you won't have vcl. Please see my previous post and see if that helps out (sorry for not tailoring it to your own code but I hadn't noticed that you had posted until I hit the 'submit' button).
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #20
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Wow O_O! I edited your makefile a bit:
    Code:
    #make.mak
    CFLAGS=-c
    LFLAGS=-aa
    STARTUPOBJS=c0w32.obj 
    LIBS=import32.lib cw32.lib
    MYOBJS=C:\forgers.obj
    RESOBJS=C:\forgers.res
    EXENAME=C:\forgers.exe
    
    $(EXENAME): $(MYOBJS) $(RESOBJS)
    	ilink32 $(LFLAGS) $(STARTUPOBJS) $(MYOBJS),$(EXENAME),,$(LIBS),,$(RESOBJS)
    But when I use make:
    Code:
    C:\>C:\borland\bcc55\bin\make -f C:\make.mak
    MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
            bcc32  /c forgers.cpp
    'bcc32' is not recognized as an internal or external command,
    operable program or batch file.
    
    ** error 1 ** deleting C:\forgers.obj
    I know its giving me this error because it cant find bcc32's path, but how do I supply it? I'll read borlands makefile info, thanks
    ken fitlike.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  6. #21
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>because it cant find bcc32's path<<

    Just set the PATH environment variable; one way is to use a batch file, for example
    Code:
    rem build.bat
    set path=c:\bcc55\bin;%path%
    make -f makefile.mak
    where 'c:\bcc55' should be replaced with the actual installation directory of your command line tools.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  7. #22
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    OMG ITS A MERACLE!!!!

    It works!! Thank you so much!!!
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile Problem: None rule to make target
    By chris24300 in forum Linux Programming
    Replies: 25
    Last Post: 06-17-2009, 09:45 AM
  2. makefile
    By twans in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2005, 12:16 AM
  3. using a makefile / gdb info
    By dinjas in forum C Programming
    Replies: 2
    Last Post: 02-22-2005, 05:42 PM
  4. about Makefile and Macro
    By tom_mk in forum C++ Programming
    Replies: 1
    Last Post: 09-18-2003, 01:07 PM
  5. makefile woes
    By Grifftt in forum C Programming
    Replies: 2
    Last Post: 12-06-2002, 03:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21