Undefined reference to t1sl_steup_key_block when linking OpenSSL
Asked Answered
P

2

4

I got a problem of linking an OpenSSL library into an existing project. Where I do get it wrong?

Below are the steps I have followed.

I have downloaded the SSL library, configured and installed it. It gets installed in /usr/local/ssl.

2) I have copied libcrypto.a and libssl.a from /usr/local/ssl/lib into my project, something like /mnt/linux/bla/bla/lib.

3) Then I edit the make file and added path of libssl libcrpto there. The path added is one that is in project like /mnt/linux/bla /bla

3) make

4) build project via slick edit

When it builds I get a long error chain, like

../lib/libssl.a(t1_enc.o) :In function 't1sl_steup_key_block: undefined ref

Now, I guess copying .a files into project could be problem. Is there is any alternative for that or should I use ln -s to link .a files form /usr/local/openssl/lib into my project library folder? Below is the error.

   Debug/FC5/m2pa.o  -ldl -lpthread -ltdapi ../septel/gctlib.lib ../lib/libpq.a ../asn1/lib/libasn1per.a ../mysql/lib/libmysqlclient.a     -L../lib ../asn1/lib/libasn1rt.a -lm -lcrypt -lcrypto -lssl  -rdynamic
../lib/libssl.a(ssl_lib.o): In function `SSL_set_quiet_shutdown':ssl_lib.c:(.text+0x670): multiple definition of `SSL_set_quiet_shutdown'
../mysql/lib/libmysqlclient.a(ssl.o):ssl.cpp:(.text+0x125c): first defined here
/usr/bin/ld: Warning: size of symbol `SSL_set_quiet_shutdown' changed from 45 in ../mysql/lib/libmysqlclient.a(ssl.o) to 12 in ../lib/libssl.a(ssl_lib.o)
../lib/libssl.a(ssl_lib.o): In function `SSL_get_quiet_shutdown':ssl_lib.c:(.text+0x680): multiple definition of `SSL_get_quiet_shutdown'
../mysql/lib/libmysqlclient.a(ssl.o):ssl.cpp:(.text+0x12down' changed from 35 in ../mysql/lib/libmysqlclient.a(ssl.o) to 8 in ../lib/libssl.a(ssl_lib.o)
../lib/libssl.a(ssl_err2.o): In function `SSL_load_error_strings':ssl_err2.c:(.text+0x4): undefined reference to `ERR_load_crypto_strings'
../lib/libssl.a(ssl_algs.o): In function `SSL_library_init':ssl_algs.c:(.text+0x4): undefined reference to `EVP_des_cbc'
:ssl_algs.c:(.text+0xc): undefined reference to `EVP_add_cipher'
:ssl_algs.c:(.text+0x11): undefined reference to `EVP_des_ede3_cbc'
:ssl_algs.c:(.text+0x19): undefined reference to `EVP_add_cipher'
:ssl_algs.c:(.text+0x1e): undefined reference to `EVP_idea_cbc'
Philippa answered 18/4, 2011 at 9:0 Comment(17)
Need more information. But, I have libssl.a libcrypto.o in my build (I am building cross platform and need target specifc builds) and just link normally. Do you have -lm -ldl in the link line? I would need to see what symbols are missing to be able to guess what you are not linking in.Capitulum
@PAntonie .. Thanks for reply . My first doubt is " do you think its correct procedure to just copy libcrypto.a and libssl.a from /usr/local/ssl/lib into my project lib folder? OR do i need to to do soft link like ln -sPhilippa
this is my line of addition in make file italic bold '# Common libraries COM_LIB=-ldl -lpthread -ltdapi ../septel/gctlib.lib ../lib/libpq.a \ ../asn1/lib/libasn1per.a \ ../mysql/lib/libmysqlclient.a ../lib/libcrypto.a ../lib/libssl.a\ ../asn1/lib/libasn1rt.a -lm -lcrypt -lcrypto -lssl 'Philippa
Ok, your build line you are including libssl and libcrypto twice. Once explicitly (../lib/libssl.a and later -ssl - same for libcrypto) you should do -L ../lib and then -lssl. That might be your problem if you are using gcc. Else, you might try -Wl, start-group <your library list> -Wl, end-group around the list of libraries so GCC looks up the symbols correctly. I do need to see your errors, the undefined symbols maybe telling you what libs you are missing.Capitulum
PS: You do not need to have libssl.a libcrypto.a in your build tree. Unless you are doing cross-platform stuff then you should have the correct version in your tree (or better get the SSL source and build it for your target).Capitulum
I changed the make file and just included -lssl -lcrypto and _L../lib . The files libcrypto.a and libssl.a are in my lib folder of my project. When I build , it still throws undefined error . DO u think that since header files are in /usr/local/openssl/include , it might causing problem?Philippa
No. You are linking, include files are for compilation. I need to see the undefined symbols error. That will tell you what is wrong. You are missing a binary symbol during the link, or the link order is wrong. Have you tried the -Wl,start-group and -Wl,end-group ?Capitulum
@PAntonie .. I have added few of the error in my posted message.Philippa
First check your version of libcrypto.a is built properly. `nm ../libCapitulum
First check your version of libcrypto.a is built properly. nm ../lib/libcrypto.a | grep EVP_add (you should get 4 items - cipher and digest). Also, mysqlclient.a and openssl.a are clashing as you have duplicate symbols. Do you need to use the openssl libraries? Is this already built into libmysqlclient.a?Capitulum
PS: try this: -Wl,start-group -ldl -lpthread -ltdapi ../septel/gctlib.lib ../lib/libpq.a ../asn1/lib/libasn1per.a ../mysql/lib/libmysqlclient.a -L../lib ../asn1/lib/libasn1rt.a -lm -lcrypt -lcrypto -lssl -rdynamic -Wl,end-group it fixes library search order problems.Capitulum
@PAntonie when i did nm ../lib/libcrypto.a | grep EVP_add. I got 6 items instead of 4Philippa
I tried -Wl option in make file and it failed to recognise start-group. when i just did -lssl without -L ../lib it complies fine BUT AT RUNTIME it throws error something like failed to load libssl.so.6 \;shared object etcPhilippa
nm ../lib/libcrypto.a | grep EVP_add 00000330 T EVP_add_cipher 00000260 T EVP_add_digest U EVP_add_cipher U EVP_add_digest U EVP_add_cipher U EVP_add_digest I am bit worried about U sign , which i guess mean undefinedPhilippa
Ok. If you take out the -L you are using the system library. You need to find libssl.so.6 (try find / -name libssl.so.6) and then set up export LD_LIBRARY_PATH += <the path to the file you found>. This also means you are loading the shared version, which I guess is the one you want. The T means it has been found. Looks like you have two different versions of libssl. What compiler are you using and what is the link line?Capitulum
sorry it should be: -Wl,--start-group and -Wi,--end-group.Capitulum
@PAnotnie -> I guess the issue has been solved( may be temporary). I did ldd of my exceutable file and found that it could find /lib/libcrypto.so.6 and /lib/libssl.so.6 . while in /lib directory there are version of crypto and ssl but not 6 . so I created the softlink like ln-s libcrypto.so.6 libcrypto.so.0.9.8g .simalrily for libssl . And it seem to work.Philippa
S
2

Have you tried using the libssl and libcrypto already installed in your /usr/lib directory (assuming you've installed the dev packages for both)? Once that compiles and runs without error using the default install, you can build your new libssl/libcrypto(?) from source, install to usr/local, and rebuild using the usr/local versions of the libraries.

Sacramentalism answered 19/4, 2011 at 14:52 Comment(1)
I guess the issue has been solved( may be temporary). I did ldd of my exceutable file and found that it could find /lib/libcrypto.so.6 and /lib/libssl.so.6 . while in /lib directory there are version of crypto and ssl but not 6 . so I created the softlink like ln-s libcrypto.so.6 libcrypto.so.0.9.8g .simalrily for libssl . And it seem to work.Philippa
B
2

You need to add the flag -lssl and -lcrypto in your makefile'

For example:

gcc somefile.c -o someprogram -lssl -lcrypto
Bevatron answered 18/4, 2011 at 12:40 Comment(1)
i actually did that . In my make file I added -lssl and bang it complies without any error . But at runtime it throws me error like failed to load libssl.so.6 . bla blaPhilippa
S
2

Have you tried using the libssl and libcrypto already installed in your /usr/lib directory (assuming you've installed the dev packages for both)? Once that compiles and runs without error using the default install, you can build your new libssl/libcrypto(?) from source, install to usr/local, and rebuild using the usr/local versions of the libraries.

Sacramentalism answered 19/4, 2011 at 14:52 Comment(1)
I guess the issue has been solved( may be temporary). I did ldd of my exceutable file and found that it could find /lib/libcrypto.so.6 and /lib/libssl.so.6 . while in /lib directory there are version of crypto and ssl but not 6 . so I created the softlink like ln-s libcrypto.so.6 libcrypto.so.0.9.8g .simalrily for libssl . And it seem to work.Philippa

© 2022 - 2024 — McMap. All rights reserved.