none
What is the "any cpu" build option for? How to distribute a version that runs on x64 and x32 RRS feed

  • Question

  • Hello everyone,

    I still haven't figured out what the "any cpu" build option is for. According to the name, i assume that it will compile a version that will run on both x64 and x32 systems but...what if i need to include an external library?

    I tipically build my projects with "any cpu" and develop on a x64 machine.

    The problem is when i want to run the same application on a x32 environment: i use a ADO .NET provider for SQLite (system.data.sqlite) and, because i referenced a x64 version during development, it will fail to load on x32 systems.

    The reason is quite obvious but...is there any way to work around this? Can i reference both x64 and x32 versions of libraries and have the CLR sort out which one to use?

    Thanks in advance,
    Luís Silva
    Thursday, March 13, 2008 4:34 PM

Answers

  • Can i reference both x64 and x32 versions of libraries and have the CLR sort out which one to use?
    So far as I know, you can not do this since it's not supported by CLR.

    In my opinion, you have to maintain two versions of your application(32bit and 64bit) which reference the corresponding version of sqlite.
    Monday, March 17, 2008 3:13 AM
  • Well, IF it was all .net code then there wouldn't be an issue.  But since there is true compiled code you have issues.  You can't have a 64bit pointer being pushed into a 32 bit pointer.  That just won't work!  You'd aso have the issues of a 32bit DLL needed a resource in memory that only a 64bit architecture could access (IE Beyone the range od 32 bit addressing)  Just not something that is good to do.

     

    Your SQLLite probably reference a COM object and is just a .Net wrapper around it.

     

    You COULD use that Target platform to target your binary to 32 bit.  That would then run in a puerly 32bit process and you wouldn't have issues with anything.

    Saturday, March 22, 2008 2:16 AM

All replies

  • When i said "x32" i obviously meant x86 ;o)
    Thursday, March 13, 2008 4:46 PM
  • Can i reference both x64 and x32 versions of libraries and have the CLR sort out which one to use?
    So far as I know, you can not do this since it's not supported by CLR.

    In my opinion, you have to maintain two versions of your application(32bit and 64bit) which reference the corresponding version of sqlite.
    Monday, March 17, 2008 3:13 AM
  • It's a shame the CLR doesn't support "multiple architecture builds".

    Thanks a lot for the info! Surprise)
    Thursday, March 20, 2008 5:40 AM
  • Not CLR's fault, in Windows system, you cannot load both 32bit and 64bit DLLs in a single process. And the Sqlite is not a pure .net assembly( So far as I know ) which can be compiled to x86 or x64 on demand.
    Thursday, March 20, 2008 5:45 AM
  • As far as i see it, i consider it to be "CLR's fault" because it could have a mechanism of distributing binaries for multiple archs and, in run time, load the correct one...

    By the way, regarding the "any cpu", can you explain me what it is for?

    Thanks,
    Luís Silva
    Friday, March 21, 2008 2:38 AM
  • Well, IF it was all .net code then there wouldn't be an issue.  But since there is true compiled code you have issues.  You can't have a 64bit pointer being pushed into a 32 bit pointer.  That just won't work!  You'd aso have the issues of a 32bit DLL needed a resource in memory that only a 64bit architecture could access (IE Beyone the range od 32 bit addressing)  Just not something that is good to do.

     

    Your SQLLite probably reference a COM object and is just a .Net wrapper around it.

     

    You COULD use that Target platform to target your binary to 32 bit.  That would then run in a puerly 32bit process and you wouldn't have issues with anything.

    Saturday, March 22, 2008 2:16 AM