New Fun Blog – Scott Bilas

Take what you want, and leave the rest (just like your salad bar).

Quickie: Building P4.Net

with one comment

In my last post I wrote about building AnyCPU assemblies that can reference 32 or 64 bit DLL’s automatically based on the environment. Just wanted to make a quick followup for people who are actually following my example, specifically trying to implement it for P4.Net. There are a few little snags if you’re not super familiar with native programming.

Make sure you do the following:

  • You must have the 64 bit compilers installed or you won’t be able to add 64-bit configurations to p4dn. Most likely you didn’t check the box for this when originally installing Visual Studio. Just go to add/remove programs, “change”, and check 64-bit under the C++ area.
  • The p4dn library requires Perforce’s p4api native library, which comes in many flavors. It is included in the distribution for P4.Net, but it is an old version. I recommend getting the latest API from their FTP site.
    • I used the p4api_vs2008_dyn and p4api_vs2008_dyn_vsdebug configurations from the ntx64 and ntx86 builds.
    • Why dynamic instead of static? .NET is all about DLL’s – using static just causes problems with the linker with conflicting runtimes.
  • Update the include and lib paths in the p4dn C++ project settings so that the library can find your p4api. If you don’t do this you’ll get #include errors about missing paths.

April 25th, 2010 at 3:23 pm

Posted in .net,p4,quickie

One Response to 'Quickie: Building P4.Net'

Subscribe to comments with RSS or TrackBack to 'Quickie: Building P4.Net'.

  1. Thanks for the update, and the help via e-mail – it cleared up a lot for me!

    In my particular case, I was trying to dynamically load P4.Net into 3d Studio Max from MaxScript.

    After all the P4API fuss, it loaded fine, but when it tried to actually use the P4Connection it threw a MSVCRTD.dll error.

    Sometimes it’s just easier to use the command line… =)

    Keep it up! I learn a lot here!

    ~Alex

    Alex

    27 Apr 10 at 10:27 am

Leave a Reply