MapScript C# (MapServer 4.10): mapscriptPINVOKE problem on 64-bit platform.

Hong ljfong at SDF.LONESTAR.ORG
Thu Jan 25 13:54:05 PST 2007


Ok, I tried to compile using "win64" mode by going through 'Visual Studio 2995
x64 Win64 Command Prompt' but mapserver failed to compile. The error:

D:\TGI\Developer\mapserver_4_10_build\mapserver-4.10.0>nmake /f Makefile.vc

Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl /nologo /Ox /MD /W3  /EHsc -ID:\TGI\Developer\mapserver_4_10_build\ma
pserver-4.10.0\..\gdwin32      -ID:\TGI\Developer\mapserver_4_10_build\mapserver
-4.10.0\..\regex-0.12            -ID:\arcgis\arcsde/include      -DHAVE_STRING_H
 -DREGEX_MALLOC -DNEED_STRCASECMP -DNEED_STRNCASECMP -DNEED_STRLCAT       -DUSE_
GD_PNG -DUSE_GD_JPEG   -DUSE_GD_FT -DGD_HAS_GETBITMAPFONT -DGD_HAS_FTEX_XSHOW
-DUSE_THREAD    -DIGNORE_MISSING_DATA   -DENABLE_STDERR_DEBUG  -DUSE_POINT_Z_M
        -DUSE_GD_ANTIALIAS    -DUSE_SDE     -DWIN32 -D_WIN32 /c mapbits.c /Fomap
bits.obj
mapbits.c
d:\tgi\developer\mapserver_4_10_build\mapserver-4.10.0\map.h(321) : error C4235:
 nonstandard extension used : '_asm' keyword not supported on this architecture
d:\tgi\developer\mapserver_4_10_build\mapserver-4.10.0\map.h(322) : error C2065:
 'fld' : undeclared identifier
d:\tgi\developer\mapserver_4_10_build\mapserver-4.10.0\map.h(322) : error C2146:
 syntax error : missing ';' before identifier 'flt'
d:\tgi\developer\mapserver_4_10_build\mapserver-4.10.0\map.h(323) : error C2146:
 syntax error : missing ';' before identifier 'fistp'
d:\tgi\developer\mapserver_4_10_build\mapserver-4.10.0\map.h(323) : error C2065:
 'fistp' : undeclared identifier
d:\tgi\developer\mapserver_4_10_build\mapserver-4.10.0\map.h(323) : error C2146:
 syntax error : missing ';' before identifier 'intgr'
d:\tgi\developer\mapserver_4_10_build\mapserver-4.10.0\map.h(324) : error C2143:
 syntax error : missing ';' before '}'
NMAKE : fatal error U1077: '"D:\Program Files (x86)\Microsoft Visual Studio 8\VC
\BIN\amd64\cl.EXE"' : return code '0x2'
Stop.

Probably I need to get past this error first before considering other things.

Thanks.

On Thu, Jan 25, 2007 at 08:37:26PM +0100, Tamas Szekeres wrote:
> Hi,
> 
> You probably need to link against the 64 bit version of the
> MSVCR80.DLL in this case.
> The Visual Studio 8 Dependency Walker can display the 64 bit images as well.
> 
> In order to produce 64 bit code you should set the proper environment
> variables for your command prompt first. In your case opening the
> 'Visual Studio 2005 x64 Win64 Command  Prompt' would be sufficient.
> Alternatively you can look into C:\Program Files (x86)\Microsoft
> Visual Studio 8\VC\vcvarsall.bat and find out a proper path to your
> specific vcvars....bat to run.
> Apparently, to execute your 64 bit code the dependent dll-s (eg.
> proj.dll) might also be compiled as a 64 bit image.
> 
> <mapscript C# specific>
> 
> You should make sure your code is running against the proper version
> of the .NET framework. For example you can use the SysInternals
> Filemon to check whether the 64 bit or the 32 bit version has been
> loaded. Sometimes, you might want to force the usage of a specific
> framework by adding supportedRuntime to the app.config file, like:
> 
> <configuration>
> <startup>
>  <supportedRuntime version="v2.0.50727" />
> </startup>
> </configuration>
> 
> If you compile code to produce a Win32 image on a Win64 platform (By
> using the Visual Studio 2005 Command Prompt for example) the default
> options does not force to use the 32 bit version of the framework, and
> your application will not run properly. Therefore you might want to
> add '/platform:x86' to your csc command line when compiling the
> mapscript libraries in this case. (the default option is
> /platform:any)
> 
> <end mapscript C# specific>
> 
> In the future, I consider adding some further action to the csharp's
> makefile.vc in order to handle these cases more smoothly.
> 
> Best Regards,
> 
> Tamas
> 
> 
> 
> 2007/1/25, Hong <ljfong at sdf.lonestar.org>:
> >Yep I know I need 64-bit DLLs. The MapServer I used was compiled from the
> >source (buildkit) with very stripped down configurations, that was, no 
> >linkage
> >to MySQL, PDF generation library, GEOS, and others, as they were 
> >irrelevant to
> >what I needed.
> >
> >Looking at all the switches for cl.exe (visual c++ compiler), link.exe 
> >(visual
> >c++ linker), and csc.exe (c# compiler), I did not notice any specific 
> >switch
> >to produce 64-bit code. Since I compiled it using Visual Studio 2005 
> >installed
> >and running on a 64-bit machine, I think the code produced should run on a
> >64-bit machine. Apparently it is just not that simple. I'm starting to 
> >think
> >it was either incorrect CRT library being loaded or the SWIG binary I used 
> >to
> >produce the c# mapscript binding DLLs was not 64-bit. I'm still at loss
> >however.
> >
> >Nope, I doubt it would make a difference to have AMD processor, after all 
> >AMD
> >architecture is virtually the same as Intel one, as far as assembly
> >instructions go. Unless the software has to interact with the processor
> >directly and make use of processor specific assembly instructions in some 
> >way,
> >which I don't think applies to MapServer, it should not matter.
> >
> >Hong.
> >
> >On Thu, Jan 25, 2007 at 10:34:21AM +0100, Tobias.Knoetzele at atosorigin.com 
> >wrote:
> >> Hi,
> >>
> >> I don?t know much about C and the very special Error you had.
> >> But I know that
> >> - there are dependencies between the DLLs
> >> - you need 64-Bit DLLs
> >> - I didn?t manage to get the DLLs required as 64 Bit - one isn?t Open 
> >Source and the producer says it?s not available for 64Bit Windows.
> >>
> >> Maybe this helps you.
> >>
> >> If you say you?ve got all the DLLs as 64 Bit - then I?d love to have 
> >them. Do you know wether it makes a difference to have AMD Processors?
> >>
> >> These are the DLLs required:
> >> ssleay32.dll
> >> xerces-c_2_7.dll
> >> zlib1.dll
> >> bgd.dll
> >> gdal13.dll
> >> geos_c.dll
> >> geotiff.dll
> >> iconv.dll
> >> libcurl.dll
> >> libeay32.dll
> >> libecwj2.dll
> >> libmap.dll
> >> libmysql.dll
> >> libpq.dll
> >> libtiff.dll
> >> libxml2.dll
> >> lti_dsdk_dll.dll
> >> mapscript.dll
> >> pdflib.dll
> >> proj.dll
> >>
> >> Tobias
> >>
> >> -----Urspr?ngliche Nachricht-----
> >> Von: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu] Im 
> >Auftrag von Hong
> >> Gesendet: Donnerstag, 25. Januar 2007 01:49
> >> An: MAPSERVER-USERS at lists.umn.edu
> >> Betreff: [UMN_MAPSERVER-USERS] MapScript C# (MapServer 4.10): 
> >mapscriptPINVOKE problem on 64-bit platform.
> >>
> >> Hi,
> >>
> >> I was trying to run mapserver compiled on a 64-bit Intel dual xeon 
> >processor machine running Windows Server 2003 R2 64-bit edition. On map 
> >object creation, the subroutine threw an exception "The type initializer 
> >for 'mapscriptPINVOKE'
> >> threw an exception.". The stack trace was:
> >>
> >> at mapscriptPINVOKE.new_mapObj(String jarg1) at mapObj..ctor(String 
> >filename)
> >>
> >> I wrote a small test C++ application on the 64-bit machine that tried to 
> >create a map object by compiling and linking it to mapscript.lib and 
> >mapscript_i.lib. The application ended up with the error:
> >>
> >> Debug Assertion Failed!
> >> Program: D:\TGI\Developer\MapServerTest\debug\MapServerTest.exe
> >> File: dbgheap.c
> >> Line: 1252
> >>
> >> Expression: _CrtIsValidHeapPointer(pUserData)
> >>
> >> So it looked like I was having problem with the CRT library on the 
> >64-bit machine. Looking at libmap.dll revealed that it depended on 
> >c:\windows\syswow64\MSVCRT.DLL (is this the correct CRT to load?)
> >>
> >> The compiler was MS Visual Studio 2005.
> >>
> >> The C++ test program itself:
> >>
> >> // MapServerTest.cpp : Defines the entry point for the console 
> >application.
> >> //
> >>
> >> #include "stdafx.h"
> >> #include <iostream>
> >> #include "map.h"
> >>
> >>
> >> int _tmain(int argc, _TCHAR* argv[])
> >> {
> >>       std::cout << "Hello World" << std::endl;
> >>
> >>       mapObj* p_mapObj = msNewMapObj();
> >>
> >>       return 0;
> >> }
> >>
> >> At this point I'm stumped on where to proceed next and can use any 
> >help/suggestion.
> >>
> >> Hong
> >>
> >



More information about the MapServer-users mailing list