What's new

Solved Compilation error /opt/bin/ld: cannot find

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Fallujah

New Around Here
Headers and variables have been set


file.cpp
Code:
#include<iostream>
#include<gmp.h>

using namespace std;

int main (int argc, char **argv) {

    mpz_t a,b,c;
    mpz_inits(a,b,c,NULL);

    mpz_set_str(a, "1234", 10);
    mpz_set_str(b,"-5678", 10); //Decimal base

    mpz_add(c,a,b);

    cout<<"\nThe exact result is:";
    mpz_out_str(stdout, 10, c); //Stream, numerical base, var
    cout<<endl;

    mpz_abs(c, c);
    cout<<"The absolute value result is:";
    mpz_out_str(stdout, 10, c);
    cout<<endl;

    cin.get();

    return 0;
}

Code:
opkg install libgmp
Package libgmp (6.2.1-1a) installed in root is up to date.
# find /opt/lib -name libgmp.so*
/opt/lib/libgmp.so.10.4.1
/opt/lib/libgmp.so.10
# g++ -lgmp file.cpp -o file
/opt/bin/ld: cannot find -lgmp: No such file or directory
collect2: error: ld returned 1 exit status

Need help


Solved by manually creating a symbolic link
/opt/lib/libgmp.so -> /opt/lib/libgmp.so.10
 
Last edited:
Try setting the load library path explicitly.
Code:
g++ -L/opt/lib -lgmp file.cpp -o file

If that doesn't work you might need to create a soft link from /opt/lib/libgmp.so.
Code:
ln -s libgmp.so.10.4.1 /opt/lib/libgmp.so
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top