1

I'm trying to build a statically linked OpenSSL + LibCurl console application with CodeBlocks. However, I can't get it to work. I keep getting these errors:

||=== Build: Debug in Filer (compiler: GNU GCC Compiler) ===|
C:\MinGW\msys\1.0\local\lib\libcurl.a(libcurl_la-openssl.o)|| undefined reference to `SSL_get0_alpn_selected'|
C:\MinGW\msys\1.0\local\lib\libcurl.a(libcurl_la-openssl.o)|| undefined reference to `SSL_CTX_set_alpn_protos'|
C:\MinGW\msys\1.0\local\lib\libcurl.a(libcurl_la-openssl.o)|| undefined reference to `SSL_CTX_set_next_proto_select_cb'|
C:\MinGW\msys\1.0\local\lib\libcurl.a(libcurl_la-openssl.o)|| undefined reference to `SSL_CTX_set_srp_username'|
C:\MinGW\msys\1.0\local\lib\libcurl.a(libcurl_la-openssl.o)|| undefined reference to `SSL_CTX_set_srp_password'|
C:\MinGW\msys\1.0\local\lib\libcurl.a(libcurl_la-openssl.o)|| undefined reference to `SSL_COMP_free_compression_methods'|
||=== Build failed: 6 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

This is the build log:

mingw32-g++.exe  -o bin\Debug\Filer.exe "obj\Debug\MinGW Sources\BASE64\base64.o
" "obj\Debug\MinGW Sources\SQLite\sqlite3.o" obj\Debug\Users\thoma\Desktop\Filer
\main.o  -static  -lcurl -lrtmp -lidn -lssl -lssh2 -lcrypto -lz -lwldap32 -lws2_
32 -lwinmm -lgdi32 C:\MinGW\msys\1.0\local\lib\libcrypto.dll.a C:\MinGW\msys\1.0
\local\lib\libcurl.a C:\MinGW\msys\1.0\local\lib\libcurl.dll.a C:\MinGW\msys\1.0
\local\lib\libssl.a C:\MinGW\msys\1.0\local\lib\libssl.dll.a C:\MinGW\msys\1.0\l
ocal\lib\libwxjpeg-3.0.a C:\MinGW\msys\1.0\local\lib\libwxpng-3.0.a C:\MinGW\msy
s\1.0\local\lib\libwxscintilla-3.0.a C:\MinGW\msys\1.0\local\lib\libwxtiff-3.0.a
 C:\MinGW\msys\1.0\local\lib\libz.a C:\MinGW\msys\1.0\local\lib\libz.dll.a

I have used the set-up which is outlined here.

Some pictures of my setup:

enter image description here enter image description here enter image description hereenter image description hereenter image description here

jww
  • 97,681
  • 90
  • 411
  • 885
TVA van Hesteren
  • 1,031
  • 3
  • 20
  • 47
  • Does your command line have a `-L`? – user4581301 May 30 '17 at 16:50
  • @user4581301, no not that I can find? I have added the build log and some pictures of the set-up – TVA van Hesteren May 30 '17 at 16:53
  • Command line looks a bit odd. `-lcurl` says link in curl, but without a `-L` to tell the linker where to find it game over. See if there is anything on the Search Directories tab that will allow you to specify the Linker search directories. On the other hand, you've specified the exact location of what looks like the linking information for the shared library version. Since you want static linking I think you can live without that. – user4581301 May 30 '17 at 17:00
  • Also be certain that you have static libraries. Last time I played with cURL and SSL under mingw (a few years ago, mind you) I had to build the suckers. – user4581301 May 30 '17 at 17:07
  • @user4581301, I have build the static libs? like libcurl.a and libssl.a? – TVA van Hesteren May 30 '17 at 17:09
  • @user4581301 see last new 2 photo's for my search directory settings? – TVA van Hesteren May 30 '17 at 17:12
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/145485/discussion-between-tva-van-hesteren-and-user4581301). – TVA van Hesteren May 30 '17 at 17:20
  • @user4581301, I have added the default lib directory to the linker search directories, which shortens the error list, see updated list above – TVA van Hesteren May 30 '17 at 17:20
  • Looks good. All you need to do now is track down those hold out libraries and add their paths to the Search Directories list. I won't be much help to you from here on in, though. I have no idea where you will find them if they aren't in with the rest of the libraries and I'm not familiar enough with them to provide building instructions. – user4581301 May 30 '17 at 17:27
  • @user4581301, alright, so do you have any idea what these files have to be names at all? – TVA van Hesteren May 30 '17 at 17:42
  • @user4581301, I got one step further again, I now get this error list, see updated question – TVA van Hesteren May 30 '17 at 17:57
  • @TVAvanHesteren - Please edit the question, and add the output of `cat "C:\MinGW\msys\1.0\local\include\opensslconf.h"`. The output of `egrep '(COMP|ALPN|SRP)' "C:\MinGW\msys\1.0\local\include\opensslconf.h"`, may be helpful, too (but the same information is available in the `cat`). – jww May 30 '17 at 22:12

1 Answers1

0

You have a mismatch between your OpenSSL version and the OpenSSL version used by libcurl.

arboreal84
  • 2,086
  • 18
  • 21
  • Alright, that seems relevant. How can I fix this issue and how can I validate both used versions ? – TVA van Hesteren May 30 '17 at 18:46
  • You want me to rebuild my setup? – TVA van Hesteren May 30 '17 at 20:10
  • 1
    Solving it is actually very tricky and you will likely have to recompile `libcurl` itself. – arboreal84 May 30 '17 at 20:17
  • Oke, I can of course re-compile lib curl, however how do I delete the old version of libcurl and OpenSSL in it's entire? – TVA van Hesteren May 30 '17 at 20:22
  • That would be another question. – arboreal84 May 30 '17 at 20:25
  • Because just deleting the dirs in \lib won't be enough I guess – TVA van Hesteren May 30 '17 at 20:26
  • `SSL_get_alpn_selected_cb`, `SSL_get0_alpn_selected` and friends are available in OpenSSL 1.0.2 and OpenSSL 1.1.0. Its not clear to me how you are arriving at the mismatched versions conclusion. You should probably explain your position. My guess (and its just a guess), is OpenSSL was configured with `no-alpn`, `no-srp` and others in one library, but they are missing from another one. – jww May 30 '17 at 21:48
  • @jww, currently I'm starting from scratch. Trying to build zlib as a start, but it returns met the error in msys: `cp: cannot create regular file '/usr/local/bin': No such file or directory`. I'm following [this tutorial](http://www.gaia-gis.it/spatialite-3.0.0-BETA/mingw64_how_to.html#libz). BTW, the patch is not working for me, returns me: `make: x86_64-w64-mingw32-gcc: Command not found` but without the patch it runs? – TVA van Hesteren May 30 '17 at 23:06
  • @TVAvanHesteren - MinGW is not my specialty (I'm an OpenSSL guy). I've had so much trouble in the past with MinGW I don't want to be near it. I no longer test any libraries on it. Luckily for me, MinGW was abandoned by its authors some time ago, so it was not hard to justify the position. – jww May 31 '17 at 00:21
  • You might consider using Cygwin. Cygwin is still actively maintained. You might also consider creating a script to manually build the libraries from the command line. You can find a couple to get you started at [Build-Scripts](https://github.com/noloader/Build-Scripts). The Git build script builds about 10 libraries needed by Git, including OpenSSL and cURL. – jww May 31 '17 at 00:24
  • @jww, Yea I know, however I need to be able to build against Linux, Windows but also against Mac. Which is not supported by Cygwin? – TVA van Hesteren May 31 '17 at 07:00
  • @TVAvanHesteren - Which platform are you missing from Linux, Windows and Mac? MACs are closer to the BSDs. Use NetBSD to simulate a Mac. Use Clang on Linux to simulate the Apple Clang compiler. In the past, I used [Hackintosh](http://www.hackintosh.com/) to provide an OS X virtual machine (before I bought a Mac Book). You will need a copy of OS X to do it, though. – jww May 31 '17 at 07:16