compilation error

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

compilation error

Amir Reda
/usr/bin/ld: cannot find -lopenssl
this is the error when i have tried to compile the code i attached below i install the openssl lib in ubuntu 12.10 i use eclipse and add at the linker setting openssl usr/include/openssl
i don't know how to solve this problem please help

--
Warmest regards and best wishes for a good health,urs sincerely
mero

certificate.cpp (726 bytes) Download Attachment
client.cc (1K) Download Attachment
client.h (902 bytes) Download Attachment
server.cc (2K) Download Attachment
server.h (808 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: compilation error

Scott Neugroschl-2

It’s -lssl, not -lopenssl.

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Amir Reda
Sent: Thursday, September 18, 2014 1:33 PM
To: [hidden email]
Subject: compilation error

 

/usr/bin/ld: cannot find -lopenssl

this is the error when i have tried to compile the code i attached below i install the openssl lib in ubuntu 12.10 i use eclipse and add at the linker setting openssl usr/include/openssl

i don't know how to solve this problem please help


--

Warmest regards and best wishes for a good health,urs sincerely
mero

Reply | Threaded
Open this post in threaded view
|

Re: compilation error

Amir Reda
thx allot for quick reply
i have modified the library name to ssl but i have the same problem with the linker

error is

Building file: ../src/certificate.cpp
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/certificate.d" -MT"src/certificate.d" -o "src/certificate.o" "../src/certificate.cpp"
Finished building: ../src/certificate.cpp
 
Building file: ../src/client.cc
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/client.d" -MT"src/client.d" -o "src/client.o" "../src/client.cc"
Finished building: ../src/client.cc
 
Building target: certificate
Invoking: Cross G++ Linker
g++ -L/usr/include/openssl -o "certificate"  ./src/certificate.o ./src/client.o ./src/server.o   -lssl
./src/client.o: In function `Client::Client()':
/home/amirale32/workspace/certificate/Debug/../src/client.cc:12: undefined reference to `X509_REQ_new'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:13: undefined reference to `X509_new'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:14: undefined reference to `X509_NAME_new'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:15: undefined reference to `RSA_new'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:16: undefined reference to `EVP_PKEY_new'
./src/client.o: In function `Client::~Client()':
/home/amirale32/workspace/certificate/Debug/../src/client.cc:24: undefined reference to `X509_REQ_free'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:25: undefined reference to `X509_free'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:26: undefined reference to `X509_NAME_free'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:27: undefined reference to `RSA_free'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:28: undefined reference to `EVP_PKEY_free'
./src/client.o: In function `Client::GenerateRSAKeyPair()':
/home/amirale32/workspace/certificate/Debug/../src/client.cc:34: undefined reference to `RSA_generate_key'
./src/client.o: In function `Client::SetPublicKey()':
/home/amirale32/workspace/certificate/Debug/../src/client.cc:40: undefined reference to `EVP_PKEY_assign'
./src/client.o: In function `Client::MakeSignedCertReq(int, int, int)':
/home/amirale32/workspace/certificate/Debug/../src/client.cc:46: undefined reference to `X509_REQ_set_pubkey'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:50: undefined reference to `EVP_md5'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:50: undefined reference to `X509_REQ_sign'
./src/server.o: In function `Server::Server()':
/home/amirale32/workspace/certificate/Debug/../src/server.cc:5: undefined reference to `X509_new'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:6: undefined reference to `RSA_new'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:7: undefined reference to `EVP_PKEY_new'
./src/server.o: In function `Server::~Server()':
/home/amirale32/workspace/certificate/Debug/../src/server.cc:15: undefined reference to `X509_free'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:16: undefined reference to `RSA_free'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:17: undefined reference to `EVP_PKEY_free'
./src/server.o: In function `Server::CreateCertificate(X509_req_st*)':
/home/amirale32/workspace/certificate/Debug/../src/server.cc:24: undefined reference to `X509_new'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:27: undefined reference to `X509_get_subject_name'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:28: undefined reference to `X509_set_issuer_name'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:30: undefined reference to `X509_set_subject_name'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:31: undefined reference to `X509_REQ_get_pubkey'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:33: undefined reference to `X509_gmtime_adj'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:34: undefined reference to `X509_gmtime_adj'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:35: undefined reference to `EVP_md5'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:35: undefined reference to `X509_sign'
./src/server.o: In function `Server::CreateMyCertificate()':
/home/amirale32/workspace/certificate/Debug/../src/server.cc:42: undefined reference to `EVP_PKEY_assign'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:43: undefined reference to `X509_get_serialNumber'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:43: undefined reference to `ASN1_INTEGER_set'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:44: undefined reference to `X509_gmtime_adj'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:45: undefined reference to `X509_gmtime_adj'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:46: undefined reference to `X509_set_pubkey'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:48: undefined reference to `X509_get_subject_name'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:49: undefined reference to `X509_set_issuer_name'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:50: undefined reference to `EVP_md5'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:50: undefined reference to `X509_sign'
./src/server.o: In function `Server::GenerateMyKeyPairs()':
/home/amirale32/workspace/certificate/Debug/../src/server.cc:56: undefined reference to `RSA_generate_key'
./src/server.o: In function `Server::SetPublicKey()':
/home/amirale32/workspace/certificate/Debug/../src/server.cc:62: undefined reference to `EVP_PKEY_assign'
collect2: error: ld returned 1 exit status
make: *** [certificate] Error 1

Note

i have followed the steps for that links

http://amgadmadkour.blogspot.com/2011/09/compiling-open-ssl-programs-in-eclipse.html
http://askubuntu.com/questions/211038/cant-find-openssl
http://stackoverflow.com/questions/7860657/undefined-reference-to-eclipse-c

but i failed  please hellllllllllllllllllpppppppppppppp

On Thu, Sep 18, 2014 at 11:46 PM, Scott Neugroschl <[hidden email]> wrote:

It’s -lssl, not -lopenssl.

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Amir Reda
Sent: Thursday, September 18, 2014 1:33 PM
To: [hidden email]
Subject: compilation error

 

/usr/bin/ld: cannot find -lopenssl

this is the error when i have tried to compile the code i attached below i install the openssl lib in ubuntu 12.10 i use eclipse and add at the linker setting openssl usr/include/openssl

i don't know how to solve this problem please help


--

Warmest regards and best wishes for a good health,urs sincerely
mero




--
Warmest regards and best wishes for a good health,urs sincerely
mero
Reply | Threaded
Open this post in threaded view
|

RE: compilation error

Scott Neugroschl-2

You also need –lcrypto

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Amir Reda
Sent: Friday, September 19, 2014 12:33 AM
To: [hidden email]
Subject: Re: compilation error

 

thx allot for quick reply

i have modified the library name to ssl but i have the same problem with the linker

error is

Building file: ../src/certificate.cpp
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/certificate.d" -MT"src/certificate.d" -o "src/certificate.o" "../src/certificate.cpp"
Finished building: ../src/certificate.cpp
 
Building file: ../src/client.cc
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/client.d" -MT"src/client.d" -o "src/client.o" "../src/client.cc"
Finished building: ../src/client.cc
 
Building target: certificate
Invoking: Cross G++ Linker
g++ -L/usr/include/openssl -o "certificate"  ./src/certificate.o ./src/client.o ./src/server.o   -lssl
./src/client.o: In function `Client::Client()':
/home/amirale32/workspace/certificate/Debug/../src/client.cc:12: undefined reference to `X509_REQ_new'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:13: undefined reference to `X509_new'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:14: undefined reference to `X509_NAME_new'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:15: undefined reference to `RSA_new'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:16: undefined reference to `EVP_PKEY_new'
./src/client.o: In function `Client::~Client()':
/home/amirale32/workspace/certificate/Debug/../src/client.cc:24: undefined reference to `X509_REQ_free'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:25: undefined reference to `X509_free'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:26: undefined reference to `X509_NAME_free'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:27: undefined reference to `RSA_free'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:28: undefined reference to `EVP_PKEY_free'
./src/client.o: In function `Client::GenerateRSAKeyPair()':
/home/amirale32/workspace/certificate/Debug/../src/client.cc:34: undefined reference to `RSA_generate_key'
./src/client.o: In function `Client::SetPublicKey()':
/home/amirale32/workspace/certificate/Debug/../src/client.cc:40: undefined reference to `EVP_PKEY_assign'
./src/client.o: In function `Client::MakeSignedCertReq(int, int, int)':
/home/amirale32/workspace/certificate/Debug/../src/client.cc:46: undefined reference to `X509_REQ_set_pubkey'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:50: undefined reference to `EVP_md5'
/home/amirale32/workspace/certificate/Debug/../src/client.cc:50: undefined reference to `X509_REQ_sign'
./src/server.o: In function `Server::Server()':
/home/amirale32/workspace/certificate/Debug/../src/server.cc:5: undefined reference to `X509_new'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:6: undefined reference to `RSA_new'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:7: undefined reference to `EVP_PKEY_new'
./src/server.o: In function `Server::~Server()':
/home/amirale32/workspace/certificate/Debug/../src/server.cc:15: undefined reference to `X509_free'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:16: undefined reference to `RSA_free'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:17: undefined reference to `EVP_PKEY_free'
./src/server.o: In function `Server::CreateCertificate(X509_req_st*)':
/home/amirale32/workspace/certificate/Debug/../src/server.cc:24: undefined reference to `X509_new'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:27: undefined reference to `X509_get_subject_name'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:28: undefined reference to `X509_set_issuer_name'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:30: undefined reference to `X509_set_subject_name'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:31: undefined reference to `X509_REQ_get_pubkey'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:33: undefined reference to `X509_gmtime_adj'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:34: undefined reference to `X509_gmtime_adj'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:35: undefined reference to `EVP_md5'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:35: undefined reference to `X509_sign'
./src/server.o: In function `Server::CreateMyCertificate()':
/home/amirale32/workspace/certificate/Debug/../src/server.cc:42: undefined reference to `EVP_PKEY_assign'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:43: undefined reference to `X509_get_serialNumber'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:43: undefined reference to `ASN1_INTEGER_set'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:44: undefined reference to `X509_gmtime_adj'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:45: undefined reference to `X509_gmtime_adj'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:46: undefined reference to `X509_set_pubkey'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:48: undefined reference to `X509_get_subject_name'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:49: undefined reference to `X509_set_issuer_name'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:50: undefined reference to `EVP_md5'
/home/amirale32/workspace/certificate/Debug/../src/server.cc:50: undefined reference to `X509_sign'
./src/server.o: In function `Server::GenerateMyKeyPairs()':
/home/amirale32/workspace/certificate/Debug/../src/server.cc:56: undefined reference to `RSA_generate_key'
./src/server.o: In function `Server::SetPublicKey()':
/home/amirale32/workspace/certificate/Debug/../src/server.cc:62: undefined reference to `EVP_PKEY_assign'
collect2: error: ld returned 1 exit status
make: *** [certificate] Error 1

Note

i have followed the steps for that links

http://amgadmadkour.blogspot.com/2011/09/compiling-open-ssl-programs-in-eclipse.html
http://askubuntu.com/questions/211038/cant-find-openssl
http://stackoverflow.com/questions/7860657/undefined-reference-to-eclipse-c

but i failed  please hellllllllllllllllllpppppppppppppp

 

On Thu, Sep 18, 2014 at 11:46 PM, Scott Neugroschl <[hidden email]> wrote:

It’s -lssl, not -lopenssl.

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Amir Reda
Sent: Thursday, September 18, 2014 1:33 PM
To: [hidden email]
Subject: compilation error

 

/usr/bin/ld: cannot find -lopenssl

this is the error when i have tried to compile the code i attached below i install the openssl lib in ubuntu 12.10 i use eclipse and add at the linker setting openssl usr/include/openssl

i don't know how to solve this problem please help


--

Warmest regards and best wishes for a good health,urs sincerely
mero




--

Warmest regards and best wishes for a good health,urs sincerely
mero

Reply | Threaded
Open this post in threaded view
|

Re: compilation error

Jeffrey Walton-3
In reply to this post by Amir Reda
On Fri, Sep 19, 2014 at 3:33 AM, Amir Reda <[hidden email]> wrote:

> thx allot for quick reply
> i have modified the library name to ssl but i have the same problem with the
> linker
>
> error is
>
> Building file: ../src/certificate.cpp
> Invoking: Cross G++ Compiler
> g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/certificate.d"
> -MT"src/certificate.d" -o "src/certificate.o" "../src/certificate.cpp"
> Finished building: ../src/certificate.cpp
>
> Building file: ../src/client.cc
> Invoking: Cross G++ Compiler
> g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/client.d"
> -MT"src/client.d" -o "src/client.o" "../src/client.cc"
> Finished building: ../src/client.cc
>
> Building target: certificate
> Invoking: Cross G++ Linker
> g++ -L/usr/include/openssl -o "certificate"  ./src/certificate.o
> ./src/client.o ./src/server.o   -lssl
> ./src/client.o: In function `Client::Client()':
> /home/amirale32/workspace/certificate/Debug/../src/client.cc:12: undefined
> reference to `X509_REQ_new'
> ...

I believe that should be:

    g++ -L/usr/lib

'-L' is for library paths, not include paths.

Additionally, you need to include both libraries in your linker
invocation. So it should be:

    g++ *.o -o myprogr.exe -L/usr/lib -lssl -lcrypto

'ld' is a single pass linker, so the order of '-lss -lcrypto' matters.

See the ld(1) man page for details. http://linux.die.net/man/1/ld.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: compilation error

Amir Reda
thx allot for reply
i have looked at the directory usr/lib i found the folder ssl but i couldn't find the folder of crypto
so what can i do????

On Fri, Sep 19, 2014 at 7:46 PM, Jeffrey Walton <[hidden email]> wrote:
On Fri, Sep 19, 2014 at 3:33 AM, Amir Reda <[hidden email]> wrote:
> thx allot for quick reply
> i have modified the library name to ssl but i have the same problem with the
> linker
>
> error is
>
> Building file: ../src/certificate.cpp
> Invoking: Cross G++ Compiler
> g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/certificate.d"
> -MT"src/certificate.d" -o "src/certificate.o" "../src/certificate.cpp"
> Finished building: ../src/certificate.cpp
>
> Building file: ../src/client.cc
> Invoking: Cross G++ Compiler
> g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/client.d"
> -MT"src/client.d" -o "src/client.o" "../src/client.cc"
> Finished building: ../src/client.cc
>
> Building target: certificate
> Invoking: Cross G++ Linker
> g++ -L/usr/include/openssl -o "certificate"  ./src/certificate.o
> ./src/client.o ./src/server.o   -lssl
> ./src/client.o: In function `Client::Client()':
> /home/amirale32/workspace/certificate/Debug/../src/client.cc:12: undefined
> reference to `X509_REQ_new'
> ...

I believe that should be:

    g++ -L/usr/lib

'-L' is for library paths, not include paths.

Additionally, you need to include both libraries in your linker
invocation. So it should be:

    g++ *.o -o myprogr.exe -L/usr/lib -lssl -lcrypto

'ld' is a single pass linker, so the order of '-lss -lcrypto' matters.

See the ld(1) man page for details. http://linux.die.net/man/1/ld.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]



--
Warmest regards and best wishes for a good health,urs sincerely
mero
Reply | Threaded
Open this post in threaded view
|

Re: compilation error

Amir Reda
amirale32@amir-master:~$ cd ..
amirale32@amir-master:/home$ cd ..
amirale32@amir-master:/$ sudo dpkg -L crypto
dpkg-query: package 'crypto' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.

amirale32@amir-master:/$ pkg-config --list-all | grep crypto
openssl                        OpenSSL - Secure Sockets Layer and cryptography libraries and tools
libssl                         OpenSSL - Secure Sockets Layer and cryptography libraries
libcrypto++                    libcrypto++ - General purpose cryptographic shared library
libcrypto                      OpenSSL-libcrypto - OpenSSL cryptography library
amirale32@amir-master:/$

On Fri, Sep 19, 2014 at 8:50 PM, Amir Reda <[hidden email]> wrote:
thx allot for reply
i have looked at the directory usr/lib i found the folder ssl but i couldn't find the folder of crypto
so what can i do????

On Fri, Sep 19, 2014 at 7:46 PM, Jeffrey Walton <[hidden email]> wrote:
On Fri, Sep 19, 2014 at 3:33 AM, Amir Reda <[hidden email]> wrote:
> thx allot for quick reply
> i have modified the library name to ssl but i have the same problem with the
> linker
>
> error is
>
> Building file: ../src/certificate.cpp
> Invoking: Cross G++ Compiler
> g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/certificate.d"
> -MT"src/certificate.d" -o "src/certificate.o" "../src/certificate.cpp"
> Finished building: ../src/certificate.cpp
>
> Building file: ../src/client.cc
> Invoking: Cross G++ Compiler
> g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/client.d"
> -MT"src/client.d" -o "src/client.o" "../src/client.cc"
> Finished building: ../src/client.cc
>
> Building target: certificate
> Invoking: Cross G++ Linker
> g++ -L/usr/include/openssl -o "certificate"  ./src/certificate.o
> ./src/client.o ./src/server.o   -lssl
> ./src/client.o: In function `Client::Client()':
> /home/amirale32/workspace/certificate/Debug/../src/client.cc:12: undefined
> reference to `X509_REQ_new'
> ...

I believe that should be:

    g++ -L/usr/lib

'-L' is for library paths, not include paths.

Additionally, you need to include both libraries in your linker
invocation. So it should be:

    g++ *.o -o myprogr.exe -L/usr/lib -lssl -lcrypto

'ld' is a single pass linker, so the order of '-lss -lcrypto' matters.

See the ld(1) man page for details. http://linux.die.net/man/1/ld.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]



--
Warmest regards and best wishes for a good health,urs sincerely
mero



--
Warmest regards and best wishes for a good health,urs sincerely
mero