# [tor-dev] Embedding tor in an application and using tor without opening a port

wac waldoalvarez00 at yahoo.com
Sat Apr 6 02:17:13 UTC 2013

Hi Navin:

Some versions of zlib can be built with the IDE but for the one I used (oldest bugfree because of gzip support) I used nmake.

Just open Visual Studio command prompt. Or if you don't locate it, (but recommend you to do it) just run vcvars32.bat (is in bin directory) to set up the environment.

For libevent:

open the Visual Studio Command Prompt, then

cd \where\you\put\it
nmake -f makefile.nmake

for zlib something similar.

for openssl you need to do more steps and install perl for configuration (they recommend activestateperl)

at INSTALL.W32 file just read "Visual C++" section. I just used dynamic library but there is a way to do it static library if you want.

when you open the solution left click at the project. Select properties. Then go to

Configuration properties -> C/C++ -> General

See there "Additional include directories". You need to change those as they are not relative.

Then go to
Configuration properties -> Linker -> General

See there "Additional Library Directories". You need to change those too to point to your directory.

I then dropped the openssl dlls next to Tor executable.

I want you to know I changed the runtime to be non debug version as I don't needed to debug there so if you want to do it you need to somehow build them with debug symbols and take back debug build of tor to use debug runtime otherwise it won't link as the linker would find duplicated symbols.

Maybe the tree is unnecessary but ok there it goes.

Regards
Waldo

------------------------------
On Thu, Apr 4, 2013 20:56 EDT Navin Francis wrote:

>Hi Waldo,
>
>I tried to build using your project and I think most of the Tor code works
>but I am not sure how to add all the libraries. Can they be built from the
>IDE?
>
>Can you also run "tree /f >files.txt" in your source folder and attach the
>file. That way, I can make sure I have the same files as you.
>
>thanks,
>Navin
>
>
>On Tue, Apr 2, 2013 at 10:49 PM, wac <waldoalvarez00 at yahoo.com> wrote:
>
>
> ------------------------------
> On Wed, Apr 3, 2013 00:38 EDT Navin Francis wrote:
>
> Hi Nick:
>
> >It seems like like we are trying to do almost exactly the same thing :)
> >
> >You also mentioned that you got Tor working as a visual studio project. I
> >was trying to do this myself, but its really a PITA since the Tor
> >configuration does not generate a visual studio project and the VC++
> >libraries don't play well with the cygwin libraries (I thought that Tor
> >only supports cygwin on windows). If your code compiles, I would really
> >appreciate it if you can upload it somewhere.
>
> Sure. I did it with visual studio 2010 since cygwin weights a lot and I am
> over dialup. So just used resources available ;). The solutions + project +
> instructions will serve to you? I attached the solutions + project. I am
> looking to upload the rest once I am done. I tested  writing and works like
> a charm but I am using the same thread. Requested www.torproject.orgwebpage using Tor :). Still gotta make things reentrant. Maybe someone
> wants to join.
>
> You need to place the files inside the folder win32 and drop the files
> there. I named it tor-windows-vs2010 but you likely can choose whatever you
> want for the name.
>
> You will have to change libraries location and header files since I didn't
> set them relative.
>
> I built all the libraries from source. OpenSSL, libevent and zlib with
> visual studio as well with nmake using the visual studio console. For
> OpenSSL you need Perl. Not sure if zlib is ok since I had to try several
> for gzip support and picked an old one.
>
> If you need help building the libraries just let me know.
>
> Ahh and I had to move some files around. At least curve25519-donna.c I
> placed it in win 32 directory for Tor 0.2.4.
>
> That should do, but if you hit something just let me know.
>
> Regards
> Waldo
>
>
> _______________________________________________
> tor-dev mailing list
> tor-dev at lists.torproject.org
> https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev
>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: tree.zip
Type: application/zip
Size: 6008 bytes
Desc: not available
URL: <http://lists.torproject.org/pipermail/tor-dev/attachments/20130406/9b424c42/attachment.zip>