Thread: Really ambiguous linker error

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    180

    Question Really ambiguous linker error

    I"m using Borland Builder 6. when I compile i get this:

    [Linker Fatal Error] Fatal: Expected a file name:

    I'm just reusing some of my old code, so it can't be that, and the only new thing i'm using is a new TCanvas.

    Code:
    TCanvas *workCanvas = new TCanvas;
    TImage *backgroundImage = new TImage(Form1);
    
    ...
    
    backgroundImage->Picture->LoadFromFile("Stars.bmp");
    
    
        //Set up workCanvas
      HDC workdc = CreateCompatibleDC(Canvas->Handle);
        HBITMAP  bmp = CreateCompatibleBitmap(Canvas->Handle, ClientWidth, ClientHeight);
        SelectObject(workdc, bmp);
        SelectPalette(workdc, backgroundImage->Picture->Bitmap->Palette, false);
        workCanvas->Handle = workdc;
    This and a new TRect object are all thats new. Can anyone see anything thats funny or odd with this code?

    Cheers

  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    I have gotten an error like that when I forgot to put something after a #include

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Better paste your compiler / linker command line / makefile
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    Quote Originally Posted by skorman00
    I have gotten an error like that when I forgot to put something after a #include

    nope. Didn't work. Do you have anyidea what you forgot to put?

    Quote Originally Posted by Salem
    Better paste your compiler / linker command line / makefile
    How?

  5. #5
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Quote Originally Posted by Death_Wraith
    nope. Didn't work. Do you have anyidea what you forgot to put?



    How?
    you should know what compiler you have, and you can find your linker command line somewhere under tools>options or something similar. Do about 5 minutes of looking, you'll find it.

    It may also be something like a missed semicolon after a class definition.

  6. #6
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    I stil havn't figured this error out, and I looked, but can't find out how to do whatr was mentioned above. Any suggestions?

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Things to try
    - delete all the object files, or do a 'clean' build which should delete them for you
    - do a 'rebuild all' to recreate everything from source
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    Quote Originally Posted by Salem
    Things to try
    - delete all the object files, or do a 'clean' build which should delete them for you
    - do a 'rebuild all' to recreate everything from source
    thx. Unfortunatly the error is still there. any other ideas?

  9. #9
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    By 'new class', do you mean you're defining a new class, or declaring a new object of the class? If you're defining a new class, i.e. in another header, chances are the problem's with that. Post the code for the TCanvas or whatever it was that you added.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  10. #10
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    Alright, here is everything...

    main.cpp
    Code:
    //---------------------------------------------------------------------------
    
    #include <vcl.h>
    #pragma hdrstop
    
    #include "Main.h"
    
    #include "Enemies.h"
    #include "Ship1.h"
    #include "Global_Var.h"
    #include "Draw.h"
    #include "Lvl1.h"
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
            : TForm(Owner)
    {
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
          TShiftState Shift)
    {
    
          if(Key == VK_UP)   //move up
        {
          //;
        }
    
        if(Key == VK_DOWN)   //rotate right
        {
          //;
        }
        if(Key == VK_RIGHT) //move piece right
        {
         // ;
        }
        if(Key == VK_LEFT)  //move piece left
        {
          //;
        }
    
    }
    
    //---------------------------------------------------------------------------
    
    void __fastcall TForm1::UpTimer(TObject *Sender)
    {
     static float i;
     int k;
    
    
    if ((Enemy[1]->y1) < ClientHeight)
    {
    
    i=5;
    //sets ship coords
    
    for(k=0;k<5;k++)
    {
    Enemy[k]->y1 = Enemy[k]->y1 +i;
    }
    /*
    Enemy[2]->y1 = Enemy[2]->y1+i;
    
    Enemy[3]->y1 = Enemy[3]->y1+i;
    
    Enemy4->x1 = Enemy4->x1;
    Enemy4->y1 = Enemy4->y1+i;
    
    Enemy5->x1 = Enemy5->x1;
    Enemy5->y1 = Enemy5->y1+i;
    */
    Draw();
    
    }
    else
    {
    
    Right->Enabled = true;
    Up->Enabled = false;
    }
    
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::LeftTimer(TObject *Sender)
    {
    
    static int i;
    int k;
    
    if ((Enemy[1]->x1) < 0)
    {
    
    i = 5;
    //sets ship coords
    
    for(k=0;k<5;k++)
    {
    Enemy[k]->x1 = Enemy[k]->x1 -i;
    }
    
    /*
    Enemy2->x1 = Enemy2->x1-i;
    Enemy2->y1 = Enemy2->y1;
    
    Enemy3->x1 = Enemy3->x1-i;
    Enemy3->y1 = Enemy3->y1;
    
    Enemy4->x1 = Enemy4->x1-i;
    Enemy4->y1 = Enemy4->y1;
    
    Enemy5->x1 = Enemy5->x1-i;
    Enemy5->y1 = Enemy5->y1;
    */
    
    Draw();
    }
    else
    {
    Up->Enabled = true;
    Left->Enabled = false;
    }
    }
    
    //----------------------------------------------------------------------------
    void __fastcall TForm1::RightTimer(TObject *Sender)
    {
    static float i;
    int k;
    
    if ((Enemy[1]->x1) < ClientWidth)
    {
    
    i=5;
    //sets ship coords
    
    for(k=0;k<5;k++)
    {
    Enemy[k]->x1 = Enemy[k]->x1 +i;
    }
    
    /*
    Enemy2->x1 = Enemy2->x1+i;
    Enemy2->y1 = Enemy2->y1;
    
    Enemy3->x1 = Enemy3->x1+i;
    Enemy3->y1 = Enemy3->y1;
    
    Enemy4->x1 = Enemy4->x1+i;
    Enemy4->y1 = Enemy4->y1;
    
    Enemy5->x1 = Enemy5->x1+i;
    Enemy5->y1 = Enemy5->y1;
    */
    
    Draw();
    }
    else
    {
    Down->Enabled = true;
    Right->Enabled = false;
    
    }
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::DownTimer(TObject *Sender)
    {
    static float i;
    int k;
    
    if ((Enemy[1]->x1) < 50)
    {
    
    i=5;
    //sets ship coords
    
    for(k=0;k<5;k++)
    {
    Enemy[k]->y1 = Enemy[k]->y1+i ;
    }
    /*
    Enemy2->y1 = Enemy2->y1 +i;
    Enemy3->y1 = Enemy3->y1 +i;
    Enemy4->y1 = Enemy4->y1 +i;
    Enemy5->y1 = Enemy5->y1 +i;
    */
    
    Draw();
    }
    else
    {
    
    Right->Enabled = true;
    Up->Enabled = false;
    }
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::FormCreate(TObject *Sender)
    {
    
    TCanvas *workCanvas = new TCanvas;
    TImage *backgroundImage = new TImage(Form1);
    TRect BackRect;
    
    
    BackRect.Top=0;
    BackRect.Left = 0;
    BackRect.Right = ClientWidth ;
    BackRect.Bottom = ClientHeight;
    
    backgroundImage->Picture->LoadFromFile("Stars.bmp");
    
    
        //Set up workCanvas
        HDC workdc = CreateCompatibleDC(Canvas->Handle);
        HBITMAP  bmp = CreateCompatibleBitmap(Canvas->Handle, ClientWidth, ClientHeight);
        SelectObject(workdc, bmp);
        SelectPalette(workdc, backgroundImage->Picture->Bitmap->Palette, false);
        workCanvas->Handle = workdc; 
    
        lvl1();
    }
    //---------------------------------------------------------------------------
    main.h
    Code:
    //---------------------------------------------------------------------------
    
    #ifndef MainH
    #define MainH
    //---------------------------------------------------------------------------
    #include <Classes.hpp>
    #include <Controls.hpp>
    #include <StdCtrls.hpp>
    #include <Forms.hpp>
    #include <ExtCtrls.hpp>
    //---------------------------------------------------------------------------
    class TForm1 : public TForm
    {
    __published:	// IDE-managed Components
            TTimer *Down;
            TTimer *Left;
            TTimer *Up;
            TTimer *Right;
            void __fastcall UpTimer(TObject *Sender);
            void __fastcall LeftTimer(TObject *Sender);
            void __fastcall RightTimer(TObject *Sender);
            void __fastcall DownTimer(TObject *Sender);
            void __fastcall FormCreate(TObject *Sender);
            
    private:	// User declarations
    public:		// User declarations
            __fastcall TForm1(TComponent* Owner);
            void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
            TShiftState Shift);
    
            /*Ship_1  *User_Ship;
            Enemy_1 *Enemy1;
            Enemy_1 *Enemy2;
            Enemy_1 *Enemy3;
            Enemy_1 *Enemy4;
            Enemy_1 *Enemy5;
    
            TImage *Ship_sprite;
            TImage *Enemy1_Sprite;
            TImage *Enemy2_Sprite;
            TImage *Enemy3_Sprite;
            TImage *Enemy4_Sprite;
            TImage *Enemy5_Sprite; */
    
            TCanvas *workCanvas;
            TRect	*BackRect;
            TImage *backgroundImage;
            
    };
    //---------------------------------------------------------------------------
    extern PACKAGE TForm1 *Form1;
    //---------------------------------------------------------------------------
    #endif
    my classes note: they are all in their separate header files, i'e just condensed them down atm for ezeir posting


    Code:
    //Ship1
    
    class Ship_1
    {
    public:
            TImage *User_Ship_sprite;
            int *health;
            int x1;
            int y1;
            //move_ship_right();
            //move_ship_left();
    
    };
    
    //enemy1
    
    class Enemy_1
    {
      public:
      //ship image
      TImage *Enemy1_Sprite;
      //health
      int *Health;
      //x1 y1 for graphics
      int x1;
      int y1;
    
      private:
        //constructor
        //Enemy_1();
        //destructor
        //~Enemy_1();
    };
    global_vars.h
    Code:
    #ifndef GLOBAL_VAR_H
    #define GLOBAL_VAR_H
    extern        Ship_1 *User_Ship;
    
    extern        Enemy_1 *Enemy[];
    
    extern        TCanvas *workCanvas;
    
    extern        TRect  BackRect;
    
    extern        TImage *backgroundImage;
    
    #endif
    then the draw routines

    Code:
    #ifndef DRAW_H
    #define DRAW_H
    
    void Draw()
    {
    int i;
    
    Form1->Repaint();
    
    for(i=0;i<5;i++)
    {
    Form1->workCanvas->Draw(Enemy[i]->x1,Enemy[i]->y1,Enemy[i]->Enemy1_Sprite->Picture->Graphic );
    Form1->workCanvas->Draw(User_Ship->x1,User_Ship->y1,User_Ship->User_Ship_sprite->Picture->Graphic);
    }
    Form1->Canvas->CopyRect(BackRect,workCanvas,BackRect);
    
    i=0;
    
    for(i=0;i<5;i++)
    {
    Form1->Canvas->Draw(Enemy[i]->x1,Enemy[i]->y1,Enemy[i]->Enemy1_Sprite->Picture->Graphic );
    Form1->Canvas->Draw(User_Ship->x1,User_Ship->y1,User_Ship->User_Ship_sprite->Picture->Graphic);
    }
    
    }
    
    #endif
    thx for the help. I've been stuck on this for the past month! And its due in 2 months!

  11. #11
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Can't you attach it as a zip to make it easier to download.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  12. #12
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Note, keyword: everything that you added... Also, it looks to me like you're overdoing the preprocessor and special keyword stuff.

    Why is Draw() defined in a separate header?
    Also, looks to me like your public and private sections in your Enemy_1 class are backward... private constructor and public member variables = generally bad, unless you're doing a Singleton (which you're not, since you have no 'getPointer()' function).
    What's with the million #pragma's and __fastcall's anyways? lol... I sure hope you are a very experienced coder, because the whole thing looks pretty obfuscated to me

    I'll leave the serious bug-hunting to Salem and the other gurus around here

    P.S. Wow, the whole thing looks incredibly similar to a visual basic program to me now that I look at it
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  13. #13
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    If I was experianced, would I be having this issue!?

    I'm using BCB 6, so all the __Fastcall #paragma etc are BCB's work and not mine.

    Draw() is in a seperate header because I like it that way! I love headers and try to split my code up between them so its ezier to work on section by section.


    and yess all those __Fastcalls and everthing do look brutal, i've just started to ignore them!

    Cheers

  14. #14
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>If I was experianced, would I be having this issue!?
    Probably. Looks pretty scary to me, by any standards Although, of course, that's probably because I didn't write it myself. What do you mean by all the stuff being "BCB's work"? I mean, how does BCB write a game for you... lol
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  15. #15
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    BCB6 == Borland C++ Builder 6

    When you create a button or somthing, it puts out the code for you.

    Code:
    void __fastcall TForm1::LeftTimer(TObject *Sender)
    {
    
    }
    Also, this is what the help file says about my error.
    "Fatal error. There’s a problem with your linker command specifications on the command line, ILINK32.CFG file, or response file."

    anyone know what this means?

    Cheers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  5. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM