Recent

Author Topic: SOLVED: OpenSSL  (Read 20219 times)

rtusrghsdfhsfdhsdfhsfdhs

  • Full Member
  • ***
  • Posts: 162
SOLVED: OpenSSL
« on: January 02, 2015, 12:11:19 pm »
Possible to statically link OpenSSL with GCC for FPC? Windows ofcourse.
« Last Edit: January 02, 2015, 07:38:28 pm by Fiji »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: OpenSSL
« Reply #1 on: January 02, 2015, 02:43:05 pm »
it should be possible. I presume some people tried.
You'd need to compile openssl for static linking. Thus it should result with .o (or .a) files. In your FPC program you should link the file(s) .o (or .a)  with $linklib directive.

rtusrghsdfhsfdhsdfhsfdhs

  • Full Member
  • ***
  • Posts: 162
Re: OpenSSL
« Reply #2 on: January 02, 2015, 02:50:07 pm »
For example I would like to use it with Synapse or Indy..

But I don't know how to compile it with GCC..  ::)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: OpenSSL
« Reply #3 on: January 02, 2015, 02:55:26 pm »
But I don't know how to compile it with GCC..  ::)
I believe you'll need MinGW for that (don't use cygwin - it's too easy and too GPL). Guideliness. They're on Qt site, but they're not Qt specific.
You might also look at windows binary distributions, they might have precompiled static binaries.
« Last Edit: January 02, 2015, 02:58:20 pm by skalogryz »

rtusrghsdfhsfdhsdfhsfdhs

  • Full Member
  • ***
  • Posts: 162
Re: OpenSSL
« Reply #4 on: January 02, 2015, 04:38:02 pm »
I have compiled it here.. https://mega.co.nz/#!HdswXCDb!2ZHaPSug-e0E9mBOaxUr4x6qXZ8Fj3F3J78dgXwjePs

However when I try this I get some missing functions. Also I cannot link it with Delphi XE7.
Seems it is not COFF?

Code: [Select]
program project1;

{$mode delphi}
{$linklib libcrypto.a}
{$linklib libssl.a}
uses
  Classes;

procedure OpenSSL_add_all_ciphers; cdecl; external;

begin
  OpenSSL_add_all_ciphers;
end.


Quote
Compile Project, Target: project1.exe: Exit code 1, Errors: 50
project1.lpr(13,1) Error: Undefined symbol: _strcmp
project1.lpr(13,1) Error: Undefined symbol: _qsort
project1.lpr(13,1) Error: Undefined symbol: _memcmp
project1.lpr(13,1) Error: Undefined symbol: _memmove
project1.lpr(13,1) Error: Undefined symbol: __imp____mb_cur_max
project1.lpr(13,1) Error: Undefined symbol: __imp___pctype
project1.lpr(13,1) Error: Undefined symbol: _strlen
project1.lpr(13,1) Error: Undefined symbol: __isctype
project1.lpr(13,1) Error: Undefined symbol: _strcpy
project1.lpr(13,1) Error: Undefined symbol: _free
project1.lpr(13,1) Error: Undefined symbol: _malloc
project1.lpr(13,1) Error: Undefined symbol: _realloc
project1.lpr(13,1) Error: Undefined symbol: _localtime
project1.lpr(13,1) Error: Undefined symbol: _time
project1.lpr(13,1) Error: Undefined symbol: _strerror
project1.lpr(13,1) Error: Undefined symbol: _strncpy
project1.lpr(13,1) Error: Undefined symbol: _strchr
project1.lpr(13,1) Error: Undefined symbol: ___chkstk_ms
project1.lpr(13,1) Error: Undefined symbol: __imp___iob
project1.lpr(13,1) Error: Undefined symbol: _GetCurrentThreadId@0
project1.lpr(13,1) Error: Undefined symbol: _getenv
project1.lpr(13,1) Error: Undefined symbol: _sscanf
project1.lpr(13,1) Error: Undefined symbol: _strtoul
project1.lpr(13,1) Error: Undefined symbol: _GetModuleHandleA@4
project1.lpr(13,1) Error: Undefined symbol: _GetProcAddress@8
project1.lpr(13,1) Error: Undefined symbol: _GetDesktopWindow@0
project1.lpr(13,1) Error: Undefined symbol: _GetProcessWindowStation@0
project1.lpr(13,1) Error: Undefined symbol: _GetUserObjectInformationW@20
project1.lpr(13,1) Error: Undefined symbol: _GetLastError@0
project1.lpr(13,1) Error: Undefined symbol: _wcsstr
project1.lpr(13,1) Error: Undefined symbol: _GetStdHandle@4
project1.lpr(13,1) Error: Undefined symbol: _GetFileType@4
project1.lpr(13,1) Error: Undefined symbol: __vsnprintf
project1.lpr(13,1) Error: Undefined symbol: _GetVersion@0
project1.lpr(13,1) Error: Undefined symbol: _RegisterEventSourceA@8
project1.lpr(13,1) Error: Undefined symbol: _ReportEventA@36
project1.lpr(13,1) Error: Undefined symbol: _DeregisterEventSource@4
project1.lpr(13,1) Error: Undefined symbol: _MessageBoxA@16
project1.lpr(13,1) Error: Undefined symbol: _vfprintf
project1.lpr(13,1) Error: Undefined symbol: _raise
project1.lpr(13,1) Error: Undefined symbol: __exit
project1.lpr(13,1) Error: Undefined symbol: ___umoddi3
project1.lpr(13,1) Error: Undefined symbol: ___udivdi3
project1.lpr(13,1) Error: Undefined symbol: _fgets
project1.lpr(13,1) Error: Undefined symbol: _fclose
project1.lpr(13,1) Error: Undefined symbol: _fread
project1.lpr(13,1) Error: Undefined symbol: _fwrite
project1.lpr(13,1) Error: Undefined symbol: __setmode
project1.lpr(13,1) Error: Undefined symbol: _fopen
project1.lpr(13,1) Error: Undefined symbol: _fflush
« Last Edit: January 02, 2015, 04:46:13 pm by Fiji »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: OpenSSL
« Reply #5 on: January 02, 2015, 05:00:16 pm »
Well no. For delphi you'll need to compile it with Borland Embarcadero C++.
Delphi doesn't support GCC obj files. I doubt it supports MSVS C++ static libraries as well.
Fallback option - always use .dlls for Delphi and static libraries for FPC.

rtusrghsdfhsfdhsdfhsfdhs

  • Full Member
  • ***
  • Posts: 162
Re: OpenSSL
« Reply #6 on: January 02, 2015, 05:01:56 pm »
Hmmm no newer Delphi can link MSVC obj files. So this is false. It can link COFF.

http://www.codeproject.com/Articles/264103/Using-COFF-C-object-files-with-Delphi-X
« Last Edit: January 02, 2015, 05:08:06 pm by Fiji »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: OpenSSL
« Reply #7 on: January 02, 2015, 05:08:10 pm »
In your FPC program you should link the file(s) .o (or .a)  with $linklib directive.
However when I try this I get some missing functions. Also I cannot link it with Delphi XE7.
Seems it is not COFF?
Not that simple. Static libraries are not the same with dynamic libraries, which are usually self contained. Static libraries still refer to runtime library symbols which resides in .o or .a supplied by the compiler, proven from undefined references in linking error above. It's not about COFF vs not COFF, if it is, the linker will issue a different message.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: OpenSSL
« Reply #8 on: January 02, 2015, 05:11:59 pm »
Hmmm no newer Delphi can link MSVC obj files. So this is false. It can link COFF.
I won't be using abbreviation to define an object file.  Because every organization claims their format is the true one.

But here how it works:

Historically FPC is designed to be compatible with GNU build tools. Thus it would be able to use GCC object files.

Borland has started its own set of tool and object formats. Thus Delphi  could always use any .obj file compiled by Borland C++. It could never work with MS C++ or GCC. However I'd expect Delphi to work with Apple binaries for OSX only (that's a step forward towards GCC compatibility, until Apple breaks it :) ). Anyways, I wouldn't expect it to be the case for Windows OS.

Microsoft has always been living in its own world of binaries.

Trying to merry these 3 mutually-hating worlds of specifications and binaries together - is a nice attempt, but only if you can make it work.

Libraries that are trying to be cross-compiler FPC/Delphi and that are relying on external object files (i.e. zlib, pngs and jpges) are typically providing both binaries BCB and GCC object binaries, if a linking instruction like this
Code: [Select]
{$ifdef fpc}
{$linklib sometlib.o} // gcc compiler
{$else}
{$linklib sometlib.obj} // borland c++ compiled
{$endif}


rtusrghsdfhsfdhsdfhsfdhs

  • Full Member
  • ***
  • Posts: 162
Re: OpenSSL
« Reply #9 on: January 02, 2015, 05:12:35 pm »
In your FPC program you should link the file(s) .o (or .a)  with $linklib directive.
However when I try this I get some missing functions. Also I cannot link it with Delphi XE7.
Seems it is not COFF?
Not that simple. Static libraries are not the same with dynamic libraries, which are usually self contained. Static libraries still refer to runtime library symbols which resides in .o or .a supplied by the compiler, proven from undefined references in linking error above. It's not about COFF vs not COFF, if it is, the linker will issue a different message.

Delphi has System.Win.Crtl which has most of these missing functions? So whats your point.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: OpenSSL
« Reply #10 on: January 02, 2015, 05:14:47 pm »
Fiji, please do not create a bug-tracking issue that "Delphi cannot link .o files" - it's delphi's issue that they could overcome easily (i'd think, since they should already be doing that for OSX).

also, please do not create a bug-tracking issue that "FPC cannot link borlands object files" :)


But, you should google for "compiling OpenSSL with Borland/Embarcadero C++" that should give you binaries consumable by Delphi.


rtusrghsdfhsfdhsdfhsfdhs

  • Full Member
  • ***
  • Posts: 162
Re: OpenSSL
« Reply #11 on: January 02, 2015, 05:16:52 pm »
I already compiled it. So I already HAVE binaries.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: OpenSSL
« Reply #12 on: January 02, 2015, 05:17:23 pm »
I already compiled it. So I already HAVE binaries.
You compiled OpenSSL with what?

rtusrghsdfhsfdhsdfhsfdhs

  • Full Member
  • ***
  • Posts: 162
Re: OpenSSL
« Reply #13 on: January 02, 2015, 05:20:20 pm »
With MingW... it is COFF format.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: OpenSSL
« Reply #14 on: January 02, 2015, 05:21:55 pm »
With GCC ... it is COFF format.
ah... so the errors about not found functions references are coming from FPC.

Well then you should probably link with libc library.

nah... try to link with libkernel32.a - which is also part of mingW - it should provide the reference for some of the functions...
and libgcc.a...
« Last Edit: January 02, 2015, 05:24:33 pm by skalogryz »

 

TinyPortal © 2005-2018