Thread: Linker Error has completely thrown me. Any help hugely appreciated.

  1. #1
    Registered User
    Join Date
    Apr 2012
    Location
    West London
    Posts
    8

    Linker Error has completely thrown me. Any help hugely appreciated.

    I'm a student with a project on C (not C+ or ++), with a piece of code which should work. I am very new to the language, and only have a very basic grasp of it (at best).

    When all legit errors have been removed it comes up with:

    Linker Error (Severity 255)
    Trouble Opening "|:\\acfs5\dt10gak\my documents\level 2\c code\floor plan.lss" for output

    Compile done. Errors: 3, Warnings: 0

    I don't understand why it does this, as even a basic 3-line program comes up with the same error.

    As I said i'm very new to this, so if i'm being a total idiot please tell me, and help me to fix it.

    Many thanks,

    George

  2. #2
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    Not sure about this particular error, but if "even a basic 3-line program comes up with the same error" then look at the C compiler installation.
    Perhaps the install of the C compiler on your box was erroneous. Can you try it on another machine in your lab and see if the error goes away?

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    .lss files are not some universal standard part of every build process for a C application. What compiler are you using? Are you using an IDE or are you compiling command line? Please copy paste the commands used to compile and link your program (the IDE should show this if you're using one), and all 3 errors exactly as they appear in your output.

  4. #4
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by stumped_student View Post
    Trouble Opening "|:\\acfs5\dt10gak\my documents\level 2\c code\floor plan.lss" for output
    That red character is the "pipe" character (aka "vertical bar", "polon", etc). Should it be an uppercase I instead, or a lowercase L? It is certainly not a valid drive letter. And you have a double \ after the colon.

  5. #5
    Registered User
    Join Date
    Apr 2012
    Location
    West London
    Posts
    8
    The compiler is CC386 IDE, I've used it throughout the year to learn C and it has never come up with that message (typically the deadline now looms).

    I have tried it on a couple of different PCs in the Uni Labs, as well as restarting mine.

    anduril462: Thanks very much for getting back to me, but I'm afraid I don't know what you're asking me to paste :\ I'm a total newbie and don't know which commands you're referring to.
    It doesn't tell me which 3 errors, all it is showing is what I pasted originally.

    The 'pipe' character is what is used in the error, it may be because it is a network storage space, rather than a local one (being Uni labs, I can't access the local drive)

  6. #6
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by stumped_student View Post
    The compiler is CC386 IDE, I've used it throughout the year to learn C and it has never come up with that message (typically the deadline now looms).
    I don't know much about that, except some guy wrote it, presumably all/mostly on his own. It sounds like there is a problem with some settings in your project for the IDE. Maybe make a new project and hope that works.

    Can you email your professor and/or TA for help? Does your class have a discussion forum? Maybe somebody there had a same/similar problem and knows a fix. If there is a deadline really soon, inform your professor/TA that you are having trouble with the build process, and maybe offer to show him your code as a gesture of good faith that you did most of the work, but can't finalize/test it. It may buy you time.

    Also, you are probably not doing anything that is compiler specific, so there is no real reason you can't download a different, free compiler/IDE. Use that to actually write and debug your code until it all works. Then you can submit that code and be reasonably sure it works.

    anduril462: Thanks very much for getting back to me, but I'm afraid I don't know what you're asking me to paste :\ I'm a total newbie and don't know which commands you're referring to.
    It doesn't tell me which 3 errors, all it is showing is what I pasted originally.
    Well, what you posted stated there were 3 errors, but you only gave us one. The other two must exist somewhere. Usually in an IDE, there is a window/box that shows the commands being run, which is probably where you got the above error from. Can you scroll up in that window and copy-paste everything in it?

    The 'pipe' character is what is used in the error, it may be because it is a network storage space, rather than a local one (being Uni labs, I can't access the local drive)
    It was a long shot anyway. Maybe there are network drive access errors? Can you access the folder \\acfs5\dt10gak\my documents\level 2\c code\ from explorer? Another long shot, but maybe the compiler is confused by a space in the file name (floor plan.lss).
    Last edited by anduril462; 04-26-2012 at 02:31 PM.

  7. #7
    Registered User
    Join Date
    Apr 2012
    Location
    West London
    Posts
    8
    Wow, pretty dumb of me not to scroll up. That's how much of a rooky I am with this lol

    You're right, there is more description in the output pane, it reads:

    -----------------------------------------------------------------

    Compiling...
    ;============ Linking ============

    Linker Error (Severity 4)
    No matching files for file specification:
    "|:\\acfs5\dt10gak\my documents\level 2\c code\floor plan.obj"
    Error: Unresolved External "_main" in Module "C:\tools\cc\clibs\platform\WIN32\pe\c0.c"

    Linker Error (Severity 255)
    Trouble Opening "|:\\acfs5\dt10gak\my documents\level 2\c code\floor plan.lss" for output

    Compile done. Errors: 3, Warnings: 0

    -----------------------------------------------------------------

    I've also tried restarting from scratch a couple of times, even after rebooting the PC and using different machines.

    I can easily access the folder and all other files work and open perfectly, but that file does not exist, I assume the program is supposed to create it while compiling?

    Is there a free compiler you could recommend that is easy to use, so I could try it on a different bit of software?

  8. #8
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    In this day and age with many free C compilers available, what kind of professor encourages the use of some obscure compiler written by some (apparent) nobody and hosted on a tripod.com page? Is this David Lindauer your professor? That's the only reasonable explanation for such oddity.

    In any event, Google for Pelles C.

  9. #9
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by stumped_student View Post
    Compiling...
    ;============ Linking ============

    Linker Error (Severity 4)
    No matching files for file specification:
    "|:\\acfs5\dt10gak\my documents\level 2\c code\floor plan.obj"
    Error: Unresolved External "_main" in Module "C:\tools\cc\clibs\platform\WIN32\pe\c0.c"

    Linker Error (Severity 255)
    Trouble Opening "|:\\acfs5\dt10gak\my documents\level 2\c code\floor plan.lss" for output

    Compile done. Errors: 3, Warnings: 0
    Post your code for floor plan.c. It looks like maybe you don't have a main function, or it's not named properly. I know that Visual C++ sometimes produces "main" funcitons that are named something other than "main", like "_tmain". Perhaps your compiler/IDE is expecting something similar.

    Also, look in the IDE settings for "compiler options" and "linker options", or similar. That will help tell you exactly what command(s) are being run when you build this. Post the commands/options here, or perhaps attach a screenshot of the settings screen.

  10. #10
    Registered User
    Join Date
    Apr 2012
    Location
    West London
    Posts
    8
    Here is the code;

    --------------------------------------------------

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    typedef struct {
        char Name[70];
        char Description1[70];            //gives the first line of descriptions, up to 70 characters
        char Description2[70];            
        char Description3[70];            
        int Exit[4];                    //makes a possible of 4 different exits (N/S/E/W)
    }Room;
    
    Room House[9];                      //there are 9 rooms in the house
    
    void DescribeRoom (int RoomNumber)
    {
        // Show Current Room Name
        printf("ROOM:\n    %s\n", House[RoomNumber].Name);
        
        // Show Current Room Description
        printf("A BRIEF DESCRIPTION:\n    %s\n    %s\n    %s\n",  House[RoomNumber].Description1, House[RoomNumber].Description2,  House[RoomNumber].Description3);
        
        // Show available exists for current room
        printf("AVAILABLE DOOORS:\n");
        if (House[RoomNumber].Exit[0] != -1)
            
        {    
        //using printf to print the room number onto the screen
            printf("    North to %s\n", House[House[RoomNumber].Exit[0]].Name);    
        }
        if (House[RoomNumber].Exit[1] != -1)
        {
            printf("    South to %s\n", House[House[RoomNumber].Exit[1]].Name);
        }
        if (House[RoomNumber].Exit[2] != -1)
        {
            printf("    East to %s\n", House[House[RoomNumber].Exit[2]].Name);
        }
        if (House[RoomNumber].Exit[3] != -1)
        {
            printf("    West to %s\n", House[House[RoomNumber].Exit[3]].Name);
        }
    }
    
    int MoveRoom (int RoomNumber)
    {
        char Direction[2];
        char NotUsed;
        int ExitNumber;
        
        // Give the user a choice of direction to move
        printf("\nChoose a direction (N, S, E or W) or press esc to leave:\n");
        
        scanf ("%s", &Direction);    //scanf to see what direction user has inputted
        
        // Check to see if exit number has been pressed (0)
        if(strcmp(Direction, "0") == 0)
        {
            printf("Come back whenever. We'll put the kettle on.");
            exit(0);
        } 
        
        // Converting direction choice in the exit number
        if (strcmp(Direction, "n") == 0 || strcmp(Direction, "N") == 0)
        {
            ExitNumber = 0;
        }
        else if (strcmp(Direction, "s") == 0 || strcmp(Direction, "S") == 0)
        {
            ExitNumber = 1;
        }
        else if (strcmp(Direction, "e") == 0 || strcmp(Direction, "E") == 0)
        {
            ExitNumber = 2;
        }
        else if (strcmp(Direction, "w") == 0 || strcmp(Direction, "W") == 0)
        {
            ExitNumber = 3;
        }
        
        // If valid change Room direction has been input Describe new Room
        if (House[RoomNumber].Exit[ExitNumber] == -1)
        {                            
        //error code,if no exit avalible
            printf("\You just walked into a wall. Try the door.\n");        
            system("hold for just one moment please");
            return RoomNumber;
        }
        else
        {
            return House[RoomNumber].Exit[ExitNumber];
        }
    }
    //room names and discriptions
    void SetupRooms ()              
    {
        int Location = 1;
                                    
        // Setup Room; West Hallway
        strcpy(House[1].Name, "West Hallway");
        strcpy(House[1].Description1, "Welcome to the house");
        strcpy(House[1].Description2, "You're stood in the Hallway.");
        strcpy(House[1].Description3, "You can leave again if you press 0");
        House[1].Exit[0] = 0;
        House[1].Exit[1] = 3;
        House[1].Exit[2] = 2;
        House[1].Exit[3] = 8;
        
        // Setup Room; Office
        strcpy(House[2].Name, "Office");
        strcpy(House[2].Description1, "This is where the work is done");
        strcpy(House[2].Description2, "It's also the technical hub of the house, with the printer and wireless router");
        House[2].Exit[0] = 0;
        House[2].Exit[1] = 0;
        House[2].Exit[2] = 0;
        House[2].Exit[3] = 1;
        
        // Setup Room; Downstairs Toilet
        strcpy(House[3].Name, "Downstairs Toilet");
        strcpy(House[3].Description1, "Not an overly exciting room; there's a toilet and a sink");
        strcpy(House[3].Description2, "There's also an 'Encyclopedia of Everything' on the windowsill");
        House[3].Exit[0] = 1;
        House[3].Exit[1] = 0;
        House[3].Exit[2] = 0;
        House[3].Exit[3] = 0;
        
        // Setup Room; Kitchen & Dining Room
        strcpy(House[4].Name, "Kitchen & Dining Room");
        strcpy(House[4].Description1, "Welcome to the heart of the home");
        strcpy(House[4].Description2, "Large open-plan room seperated by a kitchen counter");
        strcpy(House[4].Description3, "My baby brother's playpen is in the corner, by the dining table");
        House[4].Exit[0] = 0;
        House[4].Exit[1] = 8;
        House[4].Exit[2] = 9;
        House[4].Exit[3] = 0;
        
        // Setup Room; Bathroom
        strcpy(House[5].Name, "Bathroom");
        strcpy(House[5].Description1, "You are now in the Bathroom");
        strcpy(House[5].Description2, "A really nice powerful shower is in  the corner, with the bath itself directly in front of you");
        House[5].Exit[0] = 8;
        House[5].Exit[1] = 0;
        House[5].Exit[2] = 0;
        House[5].Exit[3] = 0;
        
        // Setup Room; Small Living Room
        strcpy(House[6].Name, "Small Living room");
        strcpy(House[6].Description1, "Now you're in the original living room");
        strcpy(House[6].Description2, "This was the main living room before we had the extension");
        strcpy(House[6].Description3, "Now the fireplace has been knocked  through on both sides, and you can see into the Large living room  through the fire =- it's awesome");
        House[6].Exit[0] = 8;
        House[6].Exit[1] = 7;
        House[6].Exit[2] = 0;
        House[6].Exit[3] = 0;
        
        // Setup Room; Big Living Room 
        strcpy(House[7].Name, "Big Living Room");
        strcpy(House[7].Description1, "You've left the Small Living room, and now you're in the Big Living room");
        strcpy(House[7].Description2, "This is where the TV lives, as well as the comfiest sofa in the known Universe");
        strcpy(House[7].Description3, "A huge floor-to-ceiling bookcase covers one wall, rammed full of books, CDs and DVDs");
        House[7].Exit[0] = 6;
        House[7].Exit[1] = 0;
        House[7].Exit[2] = 0;
        House[7].Exit[3] = 0;
        
        
        // Setup Room; East Hallway
        strcpy(House[8].Name, "East Hallway");
        strcpy(House[8].Description1, "Now you're in the East Hallway");
        strcpy(House[8].Description2, "It forms the second part of an internal ring around the house");
        strcpy(House[8].Description3, "The 8-year old cousins love to do laps of it");
        House[8].Exit[0] = 5;
        House[8].Exit[1] = 6;
        House[8].Exit[2] = 0;
        House[8].Exit[3] = 1;
        
        // Setup Room; Utility Room
        strcpy(House[8].Name, "Utility Room");
        strcpy(House[8].Description1, "Welcome to the Utility room");
        strcpy(House[8].Description2, "Originally a cow shed, this is where the booze fridge and the washing machine live");
        strcpy(House[8].Description3, "It is entirely sepearte from the main house, but an important part nonetheless");
        House[8].Exit[0] = 0;
        House[8].Exit[1] = 0;
        House[8].Exit[2] = 0;
        House[8].Exit[3] = 5;
        
        while(1)
        {
        // Clear Screen
            system("cls");
            
        // Discription of current room
            DescribeRoom(Location);
            
        // Go to a new room
            Location = MoveRoom(Location);
        }
    }
    
    void main ()
    {
        system("cls");
        SetupRooms();
    }
    --------------------------------------------------

    I'm not sure it works, as I've said, but I'm hoping it's ok.
    If there are any glaring errors, I'd really appreciate it if they could be pointed out and explained?

    I've had a look through the settings of the compiler, the most relevant screen is below, but I have no idea how useful it is, or what it changes - hopefully i'm just being thick again, but if you could help that would be great

    --------------------------------------------------

    http://cboard.cprogramming.com/image...AooooAKKKKAP/Z
    --------------------------------------------------

    Thanks again for all your help, it's much appreciated

  11. #11
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909

  12. #12
    Registered User
    Join Date
    Apr 2012
    Location
    West London
    Posts
    8
    So....I need to change
    Code:
    void main (){
    , to
    Code:
    int main (void){
    ?
    I'm so new to this I don't understand the significance of the difference, and can't tell if it is helping because I can't get around the linker error, which happens whatever code i'm trying to run.

    Even code as basic as this doesn't work:

    Code:
    #include<stdio.h>
    
    void main (){
    printf("test");
    }
    It just comes up with exactly the same errors.

    I tried changing the Main phrasing but it makes no difference

  13. #13
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Oh, forgot to mention, your attachment wouldn't work for me, so I couldn't see the screen shot.
    Quote Originally Posted by stumped_student View Post
    So....I need to change
    Code:
    void main (){
    , to
    Code:
    int main (void){
    ?
    Yes, that is what the link was saying, and that's the change I wanted you to make.
    I'm so new to this I don't understand the significance of the difference, and can't tell if it is helping because I can't get around the linker error, which happens whatever code i'm trying to run.
    The difference is that void main does not comply with the official standard. In the old days, there was no standard, and many compilers accepted that, but nowadays, it's not acceptable. Some compilers warn you about this, others silently let it compile, but it does weird things. The compiler you're using does not seem to be very good or standards-compliant, so who knows how it handles void main.

    Basically, if you compile/run your program on a computer with a regular OS like Windows/Linux (officially called a "hosted environment" by the standard), then the OS needs to know whether your program "worked". To pass back that information to the OS (really, to the shell, like bash in Linux, or explorer or command prompt in Windows), C returns an integer value from the main function. Returning 0 from main usually means success, anything else is some sort of error code. Since main is just a function, if you wish to return an integer, it must be declared to do so, hence int main(void). The void in the parentheses is just a way to explicitly state that main does not accept any parameters. You can use int main(int argc, char **argv) if you with your program to accept command line parameters, such as "my_program parameter1 parameter2".

    In an embedded system, or any system without a regular OS/shell (officially called an "unhosted environment" in the standard), you don't have anything to pass back the status of your program to, so void main may be acceptable.

    Even code as basic as this doesn't work:

    Code:
    #include<stdio.h>
    
    void main (){
    printf("test");
    }
    It just comes up with exactly the same errors.

    I tried changing the Main phrasing but it makes no difference
    Then I'm about out of ideas for the time being. You'll have to check with your prof/TA/fellow students, or find a forum dedicated to that compiler/IDE. Sorry.
    Last edited by anduril462; 04-26-2012 at 05:12 PM. Reason: minor additions

  14. #14
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675

  15. #15
    Registered User
    Join Date
    Apr 2012
    Location
    West London
    Posts
    8
    Hmm....just tried my exact code on a mate's user profile signed into the same machine and it worked first time.

    I guess the installation of the IDE is just screwed on my user.

    Thanks for all your help man, it's much appreciated

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Where the exception was thrown?
    By Mortissus in forum C++ Programming
    Replies: 2
    Last Post: 07-10-2007, 12:53 PM
  2. Linker Errors, Help Appreciated
    By burntheart in forum Windows Programming
    Replies: 3
    Last Post: 03-27-2006, 07:13 AM
  3. linker error
    By floxn in forum C++ Programming
    Replies: 4
    Last Post: 09-15-2005, 01:06 AM
  4. Linker Error
    By Renegade in forum C++ Programming
    Replies: 5
    Last Post: 07-28-2005, 11:23 AM
  5. Linker error using Dev-C++
    By boontune in forum C++ Programming
    Replies: 10
    Last Post: 12-17-2002, 05:47 AM

Tags for this Thread