"cannot find ld"

This is a discussion on "cannot find ld" within the C++ Programming forums, part of the General Programming Boards category; Hi, I tried to compile and run this program, but I got only one error message that says "cannot find ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    15

    "cannot find ld"

    Hi,
    I tried to compile and run this program, but I got only one error message that says "cannot find ld". It didn't say which line it was, so I can't really figure out where it went wrong.

    Code:
    #include <iostream>
    using std::cin;
    using std::cout;
    using std::endl;
    const int ARRAY_SIZE = 10;
    
    void search(const int a[], int first, int last,
                        int key, bool& found, int& location);
    //Precondition: a[first] through a[last] are sorted in increasing order.
    //Postcondition: if key is not one of the values a[first] through a[last],
    //then found == false; otherwise a[location] == key and found == true.
    
    int main( )
    {
        int a[ARRAY_SIZE];
        const int finalIndex = ARRAY_SIZE - 1;
    
        int i;
        for (i = 0; i < ARRAY_SIZE; i++)
            a[i] = 3*i;
        cout << "Array conatins:\n";
        for (i = 0; i < ARRAY_SIZE; i++)
            cout << a[i] << " ";
        cout << endl;
    
        int key, location;
        bool found;
        cout << "Enter number to be located: ";
        cin >> key;
        search(a, 0, finalIndex, key, found, location);
    
        if (found)
            cout << key << " is in index location "
                 << location << endl;
        else
            cout << key << " is not in the array." << endl;
    
        return 0;
    }
    
    void search(const int a[], int first, int last,
                              int key, bool& found, int& location)
    {
        int mid;
        if (first > last)
        {
            found = false;
        }
        else
        {
            mid = (first + last)/2;
    
            if (key == a[mid])
            {
                found = true;
                location = mid;
            }
            else if (key < a[mid])
            {
                search(a, first, mid - 1, key, found, location);
            }
            else if (key > a[mid])
            {
                search(a, mid + 1, last, key, found, location);
            }
        }
    }
    Any help would be appreciated. Thanks.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,914
    ld is the linker, methinks. How are you compiling and linking the program?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    15
    Well I have no idea what the linker is, but I'm using Bloodshed to run and compile the program. Is there something i'm missing or something I need to change here?

  4. #4
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Location
    Hampton, VA
    Posts
    391
    Did you create a project of some sort or did you just start with a new source file?
    Ubuntu Desktop
    GCC/G++
    Geany (for quick projects)
    Anjuta (for larger things)

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    try putting the bin directory in the path.

  6. #6
    Registered User
    Join Date
    Jan 2008
    Posts
    15
    It's a new source file. Not sure what you mean though, Rob...it's been a while since i've done programming.

  7. #7
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Location
    Hampton, VA
    Posts
    391
    Start Menu, right click My Computer, select advanced tab, select Enviornment Variables, At the bottom half you see system variables, find Path and make sure you see something like C:\dev-cpp\bin

    I think that's what robwhit is referring to.
    Ubuntu Desktop
    GCC/G++
    Geany (for quick projects)
    Anjuta (for larger things)

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,914
    It's a new source file.
    Use a Dev-C++ project.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    Registered User
    Join Date
    Jan 2008
    Posts
    15
    Ok i've done that, but when I compile it, this is the error I get:

    C:\Dev-Cpp\Makefile.win [Build Error] [Project1.exe] Error 1

  10. #10
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Location
    Hampton, VA
    Posts
    391
    did you check to see if C:\Dev-Cpp\bin was in your "Path" Enviornment Variable like robwhit suggested?
    Ubuntu Desktop
    GCC/G++
    Geany (for quick projects)
    Anjuta (for larger things)

  11. #11
    Registered User
    Join Date
    Jan 2008
    Posts
    15
    Yes I changed it from the Java path to the Dev-cpp path as instructed but still the same error. If you were to copy the code onto your compiler, does it work properly?

  12. #12
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Location
    Hampton, VA
    Posts
    391
    it compiled no problems on my machine.

    also you wouldn't have to "change" from java path to dev-cpp path, you simply "add" C:\Dev-Cpp\bin to the end of the path list, notice how they are all separated by a semicolon.l
    Ubuntu Desktop
    GCC/G++
    Geany (for quick projects)
    Anjuta (for larger things)

  13. #13
    Registered User
    Join Date
    Jan 2008
    Posts
    15
    Ok I've uninstalled the Java compiler...still won't work.

    Since I cannot get the output, could you enter the value of 28 for the input and then copy the output onto a wordpad file for me and e-mail it to me at dxfist@yahoo.com please? Thanks for all the help you're giving me, and that includes all of you.
    Last edited by dxfist; 02-21-2008 at 10:34 AM.

  14. #14
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,914
    Rats...this is probably why I shouldn't have installed both a Java compiler and a C++ compiler. Gonna try to uninstall the Java compiler and start over...
    I have a Java compiler and two C++ compilers on my computer and compile my Java and C++ programs without a problem (other than those that are entirely my fault, hehe).

    You can add directories to your system path.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #15
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Location
    Hampton, VA
    Posts
    391
    28 produces this output:
    Code:
    28 is not in the array.
    Ubuntu Desktop
    GCC/G++
    Geany (for quick projects)
    Anjuta (for larger things)

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

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. could not find -lwsock32.lib
    By thomas_joyee in forum C++ Programming
    Replies: 8
    Last Post: 07-14-2008, 12:28 PM
  3. How to find O of threads ?
    By jabka in forum C Programming
    Replies: 3
    Last Post: 03-11-2008, 12:25 PM
  4. how do u find 2nd largest number??
    By juancardenas in forum C Programming
    Replies: 8
    Last Post: 02-14-2003, 07:28 AM
  5. Q: Recursion to find all paths of a maze
    By reti in forum C Programming
    Replies: 7
    Last Post: 11-26-2002, 08:28 AM

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