Fixed windows build

dev
bill sun 2 years ago
parent 3229a54bd4
commit 2ed0fd7863

@ -23,7 +23,7 @@ AQuery is tested on mainstream operating systems such as Windows, macOS and Linu
There're multiple options to run AQuery on Windows. You can use the native toolchain from Microsoft Visual Studio or gcc from Cygwin/MinGW or run it under Windows Subsystem for Linux.
- For WSL, Docker or Linux virtual machines, see Linux, Docker sections below
- For Visual Studio:
- For Visual Studio (Recommended):
1. Install python3.6 or above from [official website](https://www.python.org/downloads/windows/) or Microsoft Store.
2. Install Microsoft Visual Studio 2022 or later with **Desktop development with C++** selected.
3. Clone AQuery repo from [Github](https://github.com/sunyinqi0508/AQuery2)
@ -31,14 +31,17 @@ There're multiple options to run AQuery on Windows. You can use the native toolc
5. Change the build driver from aquery_config.py to "MSBuild"
6. The libraries and headers for Monetdb are already included in msc-plugins, however you can also choose to download them from [Monetdb Easy Setup](https://www.monetdb.org/easy-setup/) and put them in the same place.
- For MinGW:
1. Install gcc and python3 using the package manager. (For Msys2, `pacman -S gcc python3`)
- For Winlibs (Recommended):
- Download latest winlibs toolchain from the [official website](https://winlibs.com/)
- Since winlibs is linked with native windows runtime libraries (UCRT or MSVCRT), it offers better interoperatibility with other libraries built with MSVC such as python and monetdb.
- Other steps can be either the same as Visual Studio or Cygwin/Mingw (below) without ABI break.
- For CygWin/MinGW:
1. Install gcc and python3 using its **builtin package manager** instead of the one from python.org or windows store. (For Msys2, `pacman -S gcc python3`)
2. Clone AQuery repo from Github
3. Install python requirements
4. The prebuilt binaries are included in ./lib directory. However, you could also rebuild them from [source](https://github.com/MonetDB/MonetDB).
- Note that it might be possible to use python from python.org or Microsoft store with gcc from MinGW. However, it might not work because of ABI breakage. So the better way is to use gcc with MinGW python from pacman or use clang/MSVC instead.
### macOS
- Install a package manager such as [homebrew](https://brew.sh)
- Install python3 and monetdb using homebrew `brew install python3 monetdb`

@ -44,6 +44,8 @@ def init_config():
if os_platform == 'win':
add_dll_dir(cygroot)
add_dll_dir(os.path.abspath('./msc-plugin'))
if build_driver == 'Auto':
try:
import vswhere
vsloc = vswhere.find(prerelease = True, latest = True, prop = 'installationPath')
if vsloc:
@ -51,9 +53,14 @@ def init_config():
build_driver = 'MSBuild'
else:
print('Warning: No Visual Studio installation found.')
build_driver = 'Makefile'
except ModuleNotFoundError:
build_driver = 'Makefile'
# print("adding path")
else:
import readline
if build_driver == 'Auto':
build_driver = 'Makefile'
if os_platform == 'cygwin':
add_dll_dir('./lib')
__config_initialized__ = True

@ -14,7 +14,7 @@ class checksums:
libaquery_a : Optional[Union[bytes, bool]] = None
pch_hpp_gch : Optional[Union[bytes, bool]] = None
server : Optional[Union[bytes, bool]] = None
sources : Union[Dict[str, bytes], bool] = None
sources : Optional[Union[Dict[str, bytes], bool]] = None
env : str = ''
def calc(self, compiler_name, libaquery_a = 'libaquery.a' ,
pch_hpp_gch = 'server/pch.hpp.gch',

@ -435,7 +435,7 @@ gmtime_r(const time_t *__restrict__ timep, struct tm *__restrict__ result)
#define HAVE_SOCKLEN_T 1
#ifndef _MSC_VER
#define SOCKET int
// #define SOCKET int
#define closesocket close
#endif

@ -76,8 +76,8 @@ __AQEXPORT__(void) init_session(Context* cxt);
#define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {}
#ifdef _MSC_VER
void* _cdecl memcpy(void*, void*, size_t);
#ifdef _WIN32
#include <cstring>
#else
void* memcpy(void*, const void*, unsigned long long);
#endif

@ -176,10 +176,10 @@ int dll_main(int argc, char** argv, Context* cxt){
//getlasterror
if (!user_module_handle)
#ifndef _MSC_VER
#ifndef _WIN32
puts(dlerror());
#else
printf("Fatal Error: Module %s failed to load with error code %d.\n", mname, GetLastError());
printf("Fatal Error: Module %s failed to load with error code %d.\n", mname, dlerror());
#endif
user_module_map[mname] = user_module_handle;
initialize_module(mname, user_module_handle, cxt);

@ -22,7 +22,12 @@ inline constexpr monetdbe_types AQType_2_monetdbe[] = {
#else
monetdbe_int64_t,
#endif
monetdbe_int16_t, monetdbe_int8_t, monetdbe_bool, monetdbe_int128_t,
monetdbe_int16_t, monetdbe_int8_t, monetdbe_bool,
#ifdef HAVE_HGE
monetdbe_int128_t,
#else
monetdbe_int64_t,
#endif
monetdbe_timestamp, monetdbe_int64_t, monetdbe_int64_t
};

@ -20,6 +20,10 @@ int dlclose(void* handle)
return FreeLibrary(static_cast<HMODULE>(handle));
}
int dlerror() {
return GetLastError();
}
SharedMemory::SharedMemory(const char* fname)
{
this->hFileMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 2, fname);

@ -5,6 +5,8 @@ static constexpr int RTLD_LAZY = 1;
void* dlopen(const char*, int);
void* dlsym(void*, const char*);
int dlclose(void*);
int dlerror();
struct SharedMemory
{
void* hFileMap;

Loading…
Cancel
Save