Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Debugging OpenSSL with Visual Studio

761 views
Skip to first unread message

sandeep kiran p

unread,
Oct 17, 2009, 2:11:53 AM10/17/09
to
Hi,

Can someone point me to the instructions that are needed to build and debug OpenSSL using Visual Studio on windows? I want to navigate through the code for the 'openssl req' command using VS. I've built a debug version (both static and dynamic) of OpenSSL as per the instruction in INSTALL.W32 doc. I have found an earlier post on a similar topic http://www.mail-archive.com/openss...@openssl.org/msg56791.html . But it just describes building a debug variant.

The question here is, do I need to create a new VS project comprising of apps/openssl.c and link libeay32.lib and ssleay32.lib libraries that I have built earlier? When I did this, I see a lot of unresolved external symbols (_prime_main, _ocsp_main etc) when building  the solution. Is there any documented procedure for accomplishing what I intend to?

Thanks,
Sandeep


Dave Thompson

unread,
Oct 20, 2009, 9:21:16 PM10/20/09
to
> From: owner-ope...@openssl.org On Behalf Of sandeep kiran p
> Sent: Saturday, 17 October, 2009 02:12

I don't know about documented.

If you want to compile the apps/* code in VS, I think you need to
do the whole directory; openssl.c is just a dispatcher that calls
the other 'commands'. If you're using dynamic, I think you need
(a copy of?) ms\applink.c also. But remember the 'apps' mostly just
wrap the -lcrypto and/or -lssl routines, so if you need to look at
much of what is going on, you'll probably need to debug them too.
Unless you only want to look at API-level results.

The last time I did this, 0.9.8g on VC++6.0 (yes, a while ago),
I did commandline (nmake) build of everything including apps,
except I manually added /Zi /Yd to cflags in nt*.mak (they used to
be in util/pl/VC-32.pl but seem to have gotten lost somewhere);
then I created a VS console-exe project with nothing in it, but
in ProjectSettings Debug specified my executable (from the dir
which also contains the .pdb, and the .dll and .pdb if not static).
I could break/step/display fine, but go-to-defn etc. didn't work.

______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openss...@openssl.org
Automated List Manager majo...@openssl.org

sandeep kiran p

unread,
Oct 21, 2009, 11:05:34 PM10/21/09
to
Thanks Dave. I figured out how to do this. I first built a static version of libeay32 and ssleay32 using ms\nt.mak (added /Zi and removed /Wx in CFLAGS). I then created an empty VS2005 project and added apps\req.c apps\apps.c apps\app_rand.c to the project (I had to look into req utility, similar would be the procedure for other tools). I then linked libeay and ssleay to the project. Now everything built fine. But as you said, I am able to break/stepinto/display but cannot do a go-to-defn of any OpenSSL API from my project. When I say go-to-def, it always points to the prototype declaration in a .h file.

Thanks,
Sandeep

Dave Thompson

unread,
Oct 22, 2009, 9:54:10 PM10/22/09
to
> From: owner-ope...@openssl.org On Behalf Of sandeep kiran p
> Sent: Wednesday, 21 October, 2009 23:06
(fairly OT: MS Visual Studio)


> Thanks Dave. I figured out how to do this. I first built a static
version
> of libeay32 and ssleay32 using ms\nt.mak (added /Zi and removed /Wx in
CFLAGS).
> I then created an empty VS2005 project and added apps\req.c apps\apps.c
> apps\app_rand.c to the project (I had to look into req utility, similar
would be
> the procedure for other tools). I then linked libeay and ssleay to the
project.
> Now everything built fine. But as you said, I am able to
break/stepinto/display
> but cannot do a go-to-defn of any OpenSSL API from my project. When I say
go-to-def,
> it always points to the prototype declaration in a .h file.

Go-to-def (mostly) doesn't use the debug symbols, it uses the separate
but similar "browse info" which normally VS/VC++ arranges to be created.
Each foo.C/CPP file gets a foo.SBR along with its foo.OBJ, and those get
combined into a project.BSC, which I'm pretty sure is what gets used.
I experimented with this some in the past and I *think* it is possible to
make it work for a manual build, but it was never worth the trouble to me.
If you want to pursue this, look for "browse". Good luck.

vivek.john...@gmail.com

unread,
Mar 17, 2012, 11:15:16 PM3/17/12
to
Hi Sandeep,

I'm trying to debug OpenSSL using Visual Studio 2008. I went through the steps you described in the thread but I'm getting the following errors this seem to be related to
#define X509_NAME ((LPCSTR)7)
#define OCSP_REQUEST ((LPCSTR)66)

Do you have any ideas, what may be wrong?

d:\tmp_openssl\include\openssl\store.h(390) : error C2059: syntax error : 'type'
d:\tmp_openssl\include\openssl\store.h(397) : error C2059: syntax error : ','
d:\tmp_openssl\include\openssl\store.h(397) : error C2143: syntax error : missing ')' before '('
d:\tmp_openssl\include\openssl\store.h(397) : error C2143: syntax error : missing ')' before '('
d:\tmp_openssl\include\openssl\store.h(397) : error C2091: function returns function
d:\tmp_openssl\include\openssl\store.h(397) : error C2091: function returns function

Regards,
Vivek

vivek.john...@gmail.com

unread,
Mar 18, 2012, 12:00:45 AM3/18/12
to
I wrote too soon. This in rand.h helped.

#if defined(OPENSSL_SYS_WINDOWS)
#include <windows.h>
#undef X509_NAME
#undef OCSP_REQUEST
#undef OCSP_RESPONSE
#endif

Cheers,
Vivek
0 new messages