Thread: Linking Error while passing arrays

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    2

    Linking Error while passing arrays

    I haven't done much with passing array's around in C++ in a while and things were going fine until just recently when I started getting the following error:

    1>Sort_Comparison.obj : error LNK2001: unresolved external symbol "int * x" (?x@@3PAHA)
    1>Sort_Comparison.obj : error LNK2001: unresolved external symbol "int * temp" (?temp@@3PAHA)

    Any help at all would be much appreciated in resolving the problem

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    pointers ("arrays" in your case, i guess) are built into the language, so you shouldnt have a problem just because your using pointers. if im correct, it looks like your programming with some library but you arent linking to it. do you know what compile and link arguments your passing to the compiler? a little more detail as to what files you have, which library your using, etc., might help too.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    I don't think it'll be a missing library. You get a linker error like that if you provide some extern definitions for a variable but don't actually declare that variable anywhere. Usually the header file has the extern definition and the cpp file has the actual declaration.

    Post the code that you think is the declaration of the above two variables.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Registered User
    Join Date
    Sep 2009
    Posts
    2
    I declare them with:

    int x[100000];
    int temp[100000];


    and later change the size of the arrays in a series of if statements

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If you declare them like that, you can't "later change the size" of those arrays.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Arghh passing 2D arrays to a func gives errors
    By bryce in forum C Programming
    Replies: 8
    Last Post: 09-12-2009, 11:24 AM
  2. Passing Arrays to Functions...
    By txcs in forum C++ Programming
    Replies: 4
    Last Post: 04-22-2009, 10:36 AM
  3. Replies: 4
    Last Post: 11-05-2001, 02:35 PM
  4. passing arrays
    By Sarah in forum C++ Programming
    Replies: 4
    Last Post: 10-25-2001, 02:50 PM
  5. passing arrays
    By Sarah in forum C Programming
    Replies: 1
    Last Post: 10-24-2001, 08:02 PM