I am trying to develop a Pintool on Windows. But so far I have been unable to configure or execute PIN. I have Microsoft Visual Studio 10.0 installed on my system. I have also downloaded and unzipped pin from its website.

On windows, "pin" command needs ".dll" file of pintool to execute. Suppose I want to execute "icount.cpp" on "prog1.exe". How can I do this?

How can I use Visual Studio to develop my own tools? I have gone through tutorials and I know what to writ, but I am not getting where and how to start?

Thanks you in advance.

3 Answers 3


The fastest and less cumbersome way I know is to make a copy of MyPinTool directory (under <pin dir>\source\tools\ and overwrite the file MyPinTool.cpp with your own code.

Open the MyPinTool.sln in Visual Studio and build your target. After that you can rename the DLL to whatever you want.

It is not an elegant solution but it gets the job done. In the end, you want to spent your time writing your PinTool and not annoyed with compiler specific settings...


I was able to find a blog which helped me configure Visual Studio 10 to develop my own tools. Here is the link to blog . The steps mentioned are generalized. But one thing I observed was that few directory names were different in my Pin installation. So please keep in mind to update those names. For some weird reasons I had to add "\LIBPATH:(path to additional library directories)" variable to Command Line Linker Options.

Also in the beginning of each cpp file mention

#define _SECURE_SCL 0

One common error you may face is "Error:LNK1104:Cannot open file* **". You can refer to this link to solve the issue.

EDIT: To execute the PIN tool:

Build the solution in Release configuration. I have extracted PIN inside my solution directory itself. Go to directory where pin.exe exists. Execute command in below format in command prompt:

pin -t [location (with file name) of solution DLL in release direcroty] -- [location (with file name) of application to execute]

Hope this will be helpful for anyone facing this issue in future.


Carlos's answer is more of a workaround, but it's so much spot on. Getting all the right knobs right is an insane job. And even more so with version 3 that switched away from whatever native runtime the OS may have, and started to use their own.

After half a day reversing the examples, I could come up with this (I'm assuming a 64 bit Windows target, but it shouldn't be difficult to notice what's architecture specific)

First of all you should get the include folders right (make sure to set PIN_ROOT in the first place though)


Then, set these flags in the compiler: /MT /GR- /GS- /EHs- /EHa- /fp:strict /Oi- /FIinclude/msvc_compat.h

And these defines for the preprocessor: TARGET_IA32E;HOST_IA32E;TARGET_WINDOWS;WIN32;__PIN__=1;PIN_CRT=1;__LP64__ (please, really pay attention to the first two.. IA32E means x86-64 and their wrong combination can lead to countless ungodly issues with symbols and whatnot).

Remember that with the exception of like 3 headers ([xmm]intrin.h and somewhat limitedly windows.h) you cannot use any other one outside of pintool.

Next there is the linker. You need these folders


and these libraries, in the absolutest correct order (/NODEFAULTLIB is recommended)


(stlport-static.lib, m-static.lib, c-static.lib and os-apis.lib may also be needed in more complex situations)

Last but not least, you should add /export:main /SAFESEH:NO /IGNORE:4210 /IGNORE:4049 to the linker command line. For anything else give a check to the PinCRT whitepaper, whose reading I cannot recommend enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.