Discussion:
compilation error
Amir Reda
2014-09-18 20:32:38 UTC
Permalink
/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*
Scott Neugroschl
2014-09-18 20:46:57 UTC
Permalink
It’s -lssl, not -lopenssl.


From: owner-openssl-***@openssl.org [mailto:owner-openssl-***@openssl.org] On Behalf Of Amir Reda
Sent: Thursday, September 18, 2014 1:33 PM
To: openssl-***@openssl.org
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
Amir Reda
2014-09-19 07:33:16 UTC
Permalink
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
Post by Scott Neugroschl
It’s -lssl, not -lopenssl.
*Sent:* Thursday, September 18, 2014 1:33 PM
*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*
Scott Neugroschl
2014-09-19 15:40:43 UTC
Permalink
You also need –lcrypto

From: owner-openssl-***@openssl.org [mailto:owner-openssl-***@openssl.org] On Behalf Of Amir Reda
Sent: Friday, September 19, 2014 12:33 AM
To: openssl-***@openssl.org
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 <***@xypro.com<mailto:***@xypro.com>> wrote:
It’s -lssl, not -lopenssl.


From: owner-openssl-***@openssl.org<mailto:owner-openssl-***@openssl.org> [mailto:owner-openssl-***@openssl.org<mailto:owner-openssl-***@openssl.org>] On Behalf Of Amir Reda
Sent: Thursday, September 18, 2014 1:33 PM
To: openssl-***@openssl.org<mailto:openssl-***@openssl.org>
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
Jeffrey Walton
2014-09-19 16:46:36 UTC
Permalink
Post by 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
/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 openssl-users-MCmKBN63+***@public.gmane.org
Automated List Manager majordomo-MCmKBN63+***@public.gmane.org
Amir Reda
2014-09-19 17:50:52 UTC
Permalink
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????
Post by Amir Reda
Post by Amir Reda
thx allot for quick reply
i have modified the library name to ssl but i have the same problem with
the
Post by Amir Reda
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
undefined
Post by Amir Reda
reference to `X509_REQ_new'
...
g++ -L/usr/lib
'-L' is for library paths, not include paths.
Additionally, you need to include both libraries in your linker
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
--
Warmest regards and best wishes for a good health,*urs sincerely *
*mero*
Amir Reda
2014-09-19 17:55:06 UTC
Permalink
***@amir-master:~$ cd ..
***@amir-master:/home$ cd ..
***@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.

***@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
Post by 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????
Post by Scott Neugroschl
Post by Amir Reda
thx allot for quick reply
i have modified the library name to ssl but i have the same problem
with the
Post by Amir Reda
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
undefined
Post by Amir Reda
reference to `X509_REQ_new'
...
g++ -L/usr/lib
'-L' is for library paths, not include paths.
Additionally, you need to include both libraries in your linker
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
--
Warmest regards and best wishes for a good health,*urs sincerely *
*mero*
--
Warmest regards and best wishes for a good health,*urs sincerely *
*mero*
Loading...