does anybony compiled successfully the Maxmind C library on Visual Studio 2010? I'm not able to compile it on Windows because I get a lot of errors regarding files not found like unistd.h
Asked
Active
Viewed 1,103 times
1 Answers
4
The error that you are seeing is probably because you are including GeoIPUpdate which isn't really necessary. GeoIPUpdate is a standalone script for updating the databases, and isn't necessary to use the APIs themselves. Try removing that to see if that resolves your issues.
Additionally, to get version 1.4.8 to compile for me on Visual Studio 2005 I had to do the following additional steps:
- In GeoIPCity.c change the inclusion of the GeoIP*.h files to use "" instead of <>
- In GeoIPCity.h change the inclusion of GeoIP.h to use "" instead of <>
- In GeoIP.h add
#define ssize_t long
- In GeoIP.c change
PACKAGE_VERSION
to "1.4.8" - In GeoIPCity.c you cannot use a
static const
when declaring an array. Change the definition oftmp_fixed_record
to beunsigned char tmp_fixed_record[6+4]; //Can't use CITYCONFIDENCEDIST_FIXED_RECORD in declaration
- In GeoIPCity.c declare
t
at the start of_extract_record()
. - Add main function to GeoIPCity.c to get your code to compile.
- Download the zlib125.dll.zip files from http://www.winimage.com/zLibDll/index.html. Extract these files and save the dllx64/* and static64/zlibstat.lib files to a location on disk. Now, in Visual Studio go to Project->Properties->Linker->Input and under "Additional Dependencies" add "ws2_32.lib zlibwapi.lib zlibstat.lib". Next, Under Linker->General go to "Additional Library Dependencies" and add the location of where you saved the files above.
- In GeoIPCity.c and GeoIP.c
pread
is undefined. Add the following definition to each of these files:
#define pread my_pread
static size_t my_pread( int file_no, void *buffer, size_t size, size_t offset )
{
if (_lseek( file_no, (long)offset, SEEK_SET) == offset)
return _read(file_no, buffer, (int)size);
else
return -1L;
}
Additionally, add #include <io.h>
to GeoIP.h so that _lseek
and _read
are included.-
thank you, I wil accept your answer although I fixed it by porting the C# version to C++ – Stefano Nov 22 '12 at 12:43