Re: MSVC Application linked against static openssl libs is crashing

2005-06-07 Thread Aleksey Sanin

While it is pretty hard to say what exactly is the problem
in your case due to the lack of details, I would try to
guess that the likely reason is MSVC runtime incompatibility.

One of the worst surprises of Microsoft Windows is that it has
several C runtime libraries *incompatible* with each other. Thus
if you compile a library against one runtime (say, single-threaded
runtime) and then link it to an application compiled against
another runtime (say, multi-threaded dll runtime) then the
application has a very good chance of crashing as soon as it
tries to open file, free memory allocated in the library (or
vice versa), etc.

Thus, it is always a good idea to make sure that all your libraries
and application use *exactly* the same MSVC runtime. If it is not
the case, MSVC linker prints an innocent looking warning LNK4098
which is usually mistakenly ignored by most of the people.


Best,
Aleksey Sanin
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]


MSVC Application linked against static openssl libs is crashing

2005-06-06 Thread Qadeer Baig
Hi All,

I am facing a problem in an application (a dll) created in MSVC which
links against static libeay32.lib and ssleay32.lib. Problem is that
when I use this application and openssl function is called, app
crashes.
But when I link this application against the dlls of openssl (using
the .libs which are created when we compile openssl with ntdll.mak) it
works fine.
What I have noticed is that when I link my application into the static
openssl libraries its size is much smaller than the size of the libs.
Linker pulls only that code form openssl libs which it thinks is being
used in the application (this perhaps is called dead code striping).
But I think there are certain methods which are used by the
application (perhaps indirectly) which linker does not include in the
resulting app, this results in a crash when app is executed. Or there
is some other reason?

In GCC on MacOSX we have a linker option -all_load which includes
all the code of a static library in the application. And hence the
size of the app is greater than the size of the libs put together.

Is my above understanding correct, or something else is wrong?
Has anyone else run into this problem?
How can I use openssl static libraries in an app developed in MSVC or
CodeWarrior so that I do not need to have openssl dlls on the machine?

Great thanks in advance,

Regards,
---
Qadeer Baig
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]


RE: MSVC Application linked against static openssl libs is crashing

2005-06-06 Thread Aftab Alam
Hi Qadeer,
It seems that you have to use the switch /MTd (for debug) or /MT (for
release)

If you are using VS2003 you should go to code generation and set the run
time library accordingly.

Regards,
Muhammad Aftab Alam.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Qadeer Baig
Sent: Monday, June 06, 2005 11:30 AM
To: openssl-users@openssl.org
Subject: MSVC Application linked against static openssl libs is crashing

Hi All,

I am facing a problem in an application (a dll) created in MSVC which
links against static libeay32.lib and ssleay32.lib. Problem is that
when I use this application and openssl function is called, app
crashes.
But when I link this application against the dlls of openssl (using
the .libs which are created when we compile openssl with ntdll.mak) it
works fine.
What I have noticed is that when I link my application into the static
openssl libraries its size is much smaller than the size of the libs.
Linker pulls only that code form openssl libs which it thinks is being
used in the application (this perhaps is called dead code striping).
But I think there are certain methods which are used by the
application (perhaps indirectly) which linker does not include in the
resulting app, this results in a crash when app is executed. Or there
is some other reason?

In GCC on MacOSX we have a linker option -all_load which includes
all the code of a static library in the application. And hence the
size of the app is greater than the size of the libs put together.

Is my above understanding correct, or something else is wrong?
Has anyone else run into this problem?
How can I use openssl static libraries in an app developed in MSVC or
CodeWarrior so that I do not need to have openssl dlls on the machine?

Great thanks in advance,

Regards,
---
Qadeer Baig
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]


smime.p7s
Description: S/MIME cryptographic signature


Re: MSVC Application linked against static openssl libs is crashing

2005-06-06 Thread Qadeer Baig
Hi Aftab,

Thanks for the reply,

If you are referring to compiling openssl with /MT switch then, yes, I
have compiled openssl with /MT switch (thanks to Rush he had pointed
this out).
But because I need static library of openss so I used nt.mak file for
openssl compilation.

But if you mean that /MT should be used in MSVC while compiling the
app which is using openssl libraries, then I have just confirmed that
in c/c++ tab of project settings /MT is already spcified (because the
dll which I am creating is multithread).

I am using MSVC6.0

Any other idea?

Thaks and regards,

--
Qadeer Baig

On 6/6/05, Aftab Alam [EMAIL PROTECTED] wrote:
 Hi Qadeer,
 It seems that you have to use the switch /MTd (for debug) or /MT (for
 release)
 
 If you are using VS2003 you should go to code generation and set the run
 time library accordingly.
 
 Regards,
 Muhammad Aftab Alam.

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]


RE: MSVC Application linked against static openssl libs is crashing

2005-06-06 Thread Brant Thomsen
I have had problems getting OpenSSL to link correctly if MFC is being used.
Try switching from static to dynamic loading of the MFC libraries and see if
that solves the problem.

Brant Thomsen

 -Original Message-
 Hi Aftab,

 Thanks for the reply,

 If you are referring to compiling openssl with /MT switch then, yes, I
 have compiled openssl with /MT switch (thanks to Rush he had pointed
 this out).
 But because I need static library of openss so I used nt.mak file for
 openssl compilation.

 But if you mean that /MT should be used in MSVC while compiling the
 app which is using openssl libraries, then I have just confirmed that
 in c/c++ tab of project settings /MT is already spcified (because the
 dll which I am creating is multithread).

 I am using MSVC6.0

 Any other idea?

 Thaks and regards,

 --
 Qadeer Baig

 On 6/6/05, Aftab Alam [EMAIL PROTECTED] wrote:
  Hi Qadeer,
  It seems that you have to use the switch /MTd (for debug) or /MT (for
  release)
 
  If you are using VS2003 you should go to code generation and set the run
  time library accordingly.
 
  Regards,
  Muhammad Aftab Alam.
 
 __
 OpenSSL Project http://www.openssl.org
 User Support Mailing Listopenssl-users@openssl.org
 Automated List Manager   [EMAIL PROTECTED]

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]


Re: MSVC Application linked against static openssl libs is crashing

2005-06-06 Thread Qadeer Baig
Thanks Brant Thomsen for the reply,

My application is actually a Win32 Dynamic-Library with no MFC support.

Any other idea?

Thanks and regards
--
Qadeer Baig

On 6/6/05, Brant Thomsen [EMAIL PROTECTED] wrote:
 I have had problems getting OpenSSL to link correctly if MFC is being used.
 Try switching from static to dynamic loading of the MFC libraries and see if
 that solves the problem.
 
 Brant Thomsen

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]


RE: MSVC Application linked against static openssl libs is crashing

2005-06-06 Thread Steven Reddie
You said it crashes when you call OpenSSL?  Which function are you calling,
and what sort of crash is it? 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Qadeer Baig
Sent: Tuesday, 7 June 2005 2:53 PM
To: openssl-users@openssl.org
Subject: Re: MSVC Application linked against static openssl libs is crashing

Thanks Brant Thomsen for the reply,

My application is actually a Win32 Dynamic-Library with no MFC support.

Any other idea?

Thanks and regards
--
Qadeer Baig

On 6/6/05, Brant Thomsen [EMAIL PROTECTED] wrote:
 I have had problems getting OpenSSL to link correctly if MFC is being
used.
 Try switching from static to dynamic loading of the MFC libraries and 
 see if that solves the problem.
 
 Brant Thomsen

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]