View Ticket
Not logged in
Ticket UUID: a9a868ab2def878f48afd73f584dd7fff3f95734
Title: building sqlite on 64 bit system for 32 bit target only fails
Status: Closed Type: Build_Problem
Severity: Important Priority: Immediate
Subsystem: Build_Automation Resolution: Works_As_Designed
Last Modified: 2011-09-16 22:15:06
Version Found In:
i'm developing on a 64 bit system. if i set the configuration for all the projects to build as x86 i get the linker error:

LNK1302: only support linking safe .netmodules; unable to link pure .netmodule

i need to build the sqlite dll to be built for 32 bit systems only

shane added on 2011-06-08 12:51:37 UTC:
I tested the following on my 64bit Windows system, using Visual Studio 2010:

* Using Fossil, get a clean copy of the source.
* In Visual Studio, open the solution SQLite.NET.2010.sln
* Select the configuration "DebugNativeOnly".
* Select the solution platform "Win32".
* From the build menu, select "Rebuild Solution".

Additional build notes here:

anonymous added on 2011-09-16 19:29:22 UTC:
Yes, NativeOnly builds ok, but what we need is to compile all projects as x86.

When you try to run AnyCPU managed application with Win32 interop on a x64 machine, .net starts application as x64 (as AnyCPU supposed to), and then fails to load x86 interop (again, by design, x64 app cannot load x86 library).

So unless there is some clever way to select correct interop (x64 or x86) at startup, AnyCPU is practically useless in this scanario.

And building Release with all projects set x86 produces described error.

mistachkin added on 2011-09-16 19:59:08 UTC:

AnyCPU is a synonym for x86. If you want to run the built files on x64, please use the x64 platform.

anonymous added on 2011-09-16 20:41:50 UTC:
Well, not right so.

When starting AnyCPU compiled .net application on x86 machine it starts as x86 process.

And on x64 machine it starts as x64 process.

So when you use AnyCPU app with x86 native dll on x64 machine it won't work.

And recompiling System.Data.SQLite.Module as x86 won't work also, 'cause it won't compile as 'safe' .netmodule if it is platform-specific.

Solution is to compile System.Data.SQLite.Module as AnyCPU, Interop as Win32, and *your app* as x86. So when your app starts as x86 process it will load SQlite assembly as x86 too.