I'm writing a native node module and I'd like to be able to build it in release and debug versions.
The node module links to another library, which has a debug and release version in two different directories.
Now this is where I'm stuck - how do I specify the library directory for the current configuration being built?
I've tried setting that in configurations.debug.link_settings key, but I get the error:
'link_settings not allowed in the Debug configuration, found in target binding.gyp
Apparently this is not possible in a cross-platform way.
So hopefully this will spare you a couple of hours of experimentation.
This is a gyp file which builds the addon for Mac and Windows.
//This example assumes you have an external library 'thelibrary', located in
//./external/thelibrary
//With the two flavors, debug and release in lib/debug and lib/release
{
"targets": [
{
"target_name": "addon",
"sources": [
"src/addon.cpp",
"src/expose_the_library.cpp"
],
"include_dirs": [
"external/thelibrary/include"
],
"cflags!": [
"-fno-exceptions"
],
"cflags_cc!": [
"-fno-exceptions"
],
"conditions": [
[
"OS=='mac'",
{
"defines": [
"__MACOSX_CORE__"
],
"architecture": "i386",
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES"
},
"link_settings": {
"libraries": [
"-lthelibrary",
"-framework",
"IOBluetooth" //this is how you use a framework on OSX
],
"configurations": {
"Debug": {
"xcode_settings": {
"OTHER_LDFLAGS": [
"-Lexternal/thelibrary/lib/debug"
]
}
},
"Release": {
"xcode_settings": {
"OTHER_LDFLAGS": [
"-Lexternal/thelibrary/lib/release"
]
}
}
}
}
}
],
[
"OS=='win'",
{
"link_settings": {
"libraries": [
"-lthelibrary.lib",
]
},
"configurations": {
"Debug": {
"msvs_settings": {
"VCCLCompilerTool": {
"ExceptionHandling": "0",
"AdditionalOptions": [
"/MP /EHsc"
]
},
"VCLibrarianTool": {
"AdditionalOptions": [
"/LTCG"
]
},
"VCLinkerTool": {
"LinkTimeCodeGeneration": 1,
"LinkIncremental": 1,
"AdditionalLibraryDirectories": [
"../external/thelibrary/lib/debug"
]
}
}
},
"Release": {
"msvs_settings": {
"VCCLCompilerTool": {
"RuntimeLibrary": 0,
"Optimization": 3,
"FavorSizeOrSpeed": 1,
"InlineFunctionExpansion": 2,
"WholeProgramOptimization": "true",
"OmitFramePointers": "true",
"EnableFunctionLevelLinking": "true",
"EnableIntrinsicFunctions": "true",
"RuntimeTypeInfo": "false",
"ExceptionHandling": "0",
"AdditionalOptions": [
"/MP /EHsc"
]
},
"VCLibrarianTool": {
"AdditionalOptions": [
"/LTCG"
]
},
"VCLinkerTool": {
"LinkTimeCodeGeneration": 1,
"OptimizeReferences": 2,
"EnableCOMDATFolding": 2,
"LinkIncremental": 1,
"AdditionalLibraryDirectories": [
"../external/thelibrary/lib/release"
]
}
}
}
}
}
]
]
}
]
}
I faced this issue as well and it seems that if you pass --format=make-linux (for example) on the command line it will generate for the 'make' format but it will explicitly use the 'linux' flavor.
Related
I'm starting to test ArangoSearch to use in an upcoming feature. I have a nested JSON field that I want to do a token search on a nested field.
{ip:{dpdm:{description:<text>}}}
The view is:
{
"writebufferIdle": 64,
"type": "arangosearch",
"writebufferSizeMax": 33554432,
"consolidationPolicy": {
"type": "tier",
"segmentsBytesFloor": 2097152,
"segmentsBytesMax": 5368709120,
"segmentsMax": 10,
"segmentsMin": 1,
"minScore": 0
},
"primarySort": [],
"globallyUniqueId": "h7437427BB0F0/26371461",
"id": "26371461",
"storedValues": [],
"writebufferActive": 0,
"consolidationIntervalMsec": 1000,
"cleanupIntervalStep": 2,
"commitIntervalMsec": 1000,
"links": {
"pmconfig": {
"analyzers": [
"identity"
],
"fields": {
"ip.dpdm.version_notes": {
"analyzers": [
"text_en"
]
},
"ip.digital.feature_list": {
"analyzers": [
"text_en"
]
},
"ip.common.Available-Views": {
"analyzers": [
"text_en"
]
},
"ip.pipeline.comment": {
"analyzers": [
"text_en"
]
},
"ip.dpdm.eccn": {
"analyzers": [
"text_en"
]
},
"ip.dpdm.description": {
"analyzers": [
"text_en"
]
},
"ip.dpdm.maturity_comments": {
"analyzers": [
"text_en"
]
}
},
"includeAllFields": true,
"storeValues": "none",
"trackListPositions": false
}
},
"primarySortCompression": "lz4"
}
The following query return 58 objects:
for d in pmconfig filter d.ip.dpdm.description like('% synchronous %') return d
But the following doesn't return any items:
for d in v_myView search analyzer(d.ip.dpdm.description in tokens('synchronous', 'text_en'), 'text_en') return d
I'm sure I did something wrong but it looks right to me. A pointer to get me going would be appreciated.
I knew I was missing something. Looks like I shouldn't use nested field paths when specifying the view. All I needed to do was to set the top level field "ip" to the "text_en" analyzer in the view. All is good now.
all - hoping you can help me learn how to parse a JSON response.
I have a service that makes an API call like this:
private REST_API_SERVER = 'myapicall.com'
constructor(private httpClient: HttpClient) { }
public sendGetRequest(): Observable<any> {
return this.httpClient.get(this.REST_API_SERVER);
}
The above is returned to a component:
sendGetRequest(): void {
this.dataService.sendGetRequest()
.subscribe(data => this.data = data);
}
I can output the response in my component HTML like this:
{{data | json}}
At which point a response with a structure like this is written to the screen:
{
"findItemsByKeywordsResponse": [
{
"ack": [
"Success"
],
"version": [
"1.13.0"
],
"timestamp": [
"2022-03-03T16:12:06.220Z"
],
"searchResult": [
{
"#count": "1",
"item": [
{
"itemId": [
"294786675398"
],
"title": [
"Apple iPhone 12 mini (5G) Factory Unlocked GSM+CDMA 256GB | 128GB | 64GB"
],
"globalId": [
"EBAY-US"
],
"subtitle": [
"✤Cheapest Online ✤FREE SHIPPING ✤FREE RETURN ✤US SELLER"
],
"primaryCategory": [
{
"categoryId": [
"9355"
],
"categoryName": [
"Cell Phones & Smartphones"
]
}
],
"galleryURL": [
"https://i.ebayimg.com/thumbs/images/g/hBYAAOSw~qhgy8mG/s-l140.jpg"
],
"viewItemURL": [
"https://www.ebay.com/itm/Apple-iPhone-12-mini-5G-Factory-Unlocked-GSM-CDMA-256GB-128GB-64GB-/294786675398?var=593157879172"
],
"autoPay": [
"true"
],
"postalCode": [
"112**"
],
"location": [
"Brooklyn,NY,USA"
],
"country": [
"US"
],
"shippingInfo": [
{
"shippingServiceCost": [
{
"#currencyId": "USD",
"__value__": "0.0"
}
],
"shippingType": [
"Free"
],
"shipToLocations": [
"Worldwide"
],
"expeditedShipping": [
"true"
],
"oneDayShippingAvailable": [
"true"
],
"handlingTime": [
"1"
]
}
],
"sellingStatus": [
{
"currentPrice": [
{
"#currencyId": "USD",
"__value__": "439.88"
}
],
"convertedCurrentPrice": [
{
"#currencyId": "USD",
"__value__": "439.88"
}
],
"sellingState": [
"Active"
],
"timeLeft": [
"P28DT9H52M53S"
]
}
],
"listingInfo": [
{
"bestOfferEnabled": [
"false"
],
"buyItNowAvailable": [
"false"
],
"startTime": [
"2022-02-01T02:05:58.000Z"
],
"endTime": [
"2022-04-01T02:04:59.000Z"
],
"listingType": [
"FixedPrice"
],
"gift": [
"false"
],
"watchCount": [
"26"
]
}
],
"returnsAccepted": [
"true"
],
"condition": [
{
"conditionId": [
"1500"
],
"conditionDisplayName": [
"Open box"
]
}
],
"isMultiVariationListing": [
"true"
],
"topRatedListing": [
"true"
]
}
]
}
],
"paginationOutput": [
{
"pageNumber": [
"1"
],
"entriesPerPage": [
"1"
],
"totalPages": [
"12825623"
],
"totalEntries": [
"12825623"
]
}
],
"itemSearchURL": [
"https://www.ebay.com/sch/i.html?_nkw=iPhone&_ddo=1&_ipg=1&_pgn=1"
]
}
]
}
In my component HTML, how would I write this item's title to the screen?
Assuming that
const data={complete_json_you_have_provided}
//then
console.log(data.findItemsByKeywordsResponse[0].searchResult[0].item[0].title);
prints required title array [Apple iPhone 12 mini (5G) Factory Unlocked GSM+CDMA 256GB | 128GB | 64GB]
check here TS PLAYGROUND
I don't understand why (please help educate me if you know), but I got it working by changing the sendGetRequest() function to:
public sendGetRequest(): Observable<any> {
return this.http.get(this.REST_API_SERVER);
}
Rather than:
public sendGetRequest(): Observable<any> {
return this.httpClient.get(this.REST_API_SERVER);
}
I need to compile a Managed C++ module in a Node.JS application. I read online that I need to enable CLI with the /clr flag, and set the msvs-settings and msbuild_settings attributes, it's still not working for me. I receive this error message:
cl : Command line error D8016: '/clr' and '/EHs' command-line options are incompatible [C:\MyProject\native-modules\encryption-utilities\addon\
build\encrypt.vcxproj]
I've gotten the information from this page:
https://github.com/nodejs/node-gyp/issues/568
Here is my binding.gyp.
Thank you.
{
"targets": [
{
"target_name": "encrypt",
'conditions': [
['OS=="mac"', {
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
"GCC_ENABLE_CPP_RTTI": "YES",
"OTHER_CFLAGS": ["-mmacosx-version-min=10.7", "-std=c++11", "-stdlib=libc++"],
"OTHER_CPLUSPLUSFLAGS": ["-mmacosx-version-min=10.7", "-std=c++11", "-stdlib=libc++"]
},
'defines': [
'LINUX_DEFINE',
'_MAC',
'_ULONGLONG',
],
"cflags": ["-Wall", "-std=c++11", '-fexceptions', '-Wno-writable-strings'],
"cflags!": ['-fno-exceptions', '-Wwritable-strings'],
"cflags_cc!": ['-fno-exceptions', '-Wwritable-strings'],
"cflags_cc": ['-fexceptions', '-Wno-writable-strings'],
"include_dirs": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
]
}],
['OS=="win"', {
'defines+': [
'WIN_DEFINE',
'INCLUDE_SIGNATURE_ENCRYPTION',
'WIN64',
'WIN32',
'_WIN32',
"_WIN32_WINNT=0x0601",
"_WINSOCK_DEPRECATED_NO_WARNINGS",
"_HAS_EXCEPTIONS=2",
"_SCL_SECURE_NO_WARNINGS",
"UNICODE",
"_UNICODE",
"_NO_ASYNCRTIMP",
"BOOST_ERROR_CODE_HEADER_ONLY"
],
'msbuild_toolset': 'v141',
{
'cflags_cc': [
'/clr'
],
}],
'msvs_settings': {
'VCCLCompilerTool': {
'RuntimeLibrary':'MultiThreadedDLL'
}
},
'msbuild_settings': {
'ClCompile': {
'CompileAsManaged':'true' # can be safe, pure
}
},
"include_dirs": [
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared",
],
# "run_as": {
# "action": ['C:/Program Files/nodejs/node.exe', '$(ProjectDir)/../../out/encrypt.js', ],
# },
"configurations": {
"Debug": {
'defines': [
'DEBUG',
'_DEBUG'
],
'library_dirs': [
],
},
"Release": {
'defines': [
'NDEBUG',
],
'library_dirs': [
],
}
},
"libraries": [
"crypt32.lib",
"winhttp.lib",
"httpapi.lib",
"bcrypt.lib",
"ws2_32.lib",
"iphlpapi.lib"
]
}]
],
"sources": [
"hello.cc",
"aes.cpp",
"base64.cpp",
"crypt.cpp",
"StringUtil.cpp"
],
"cflags": ["-Wall", "-std=c++11"],
"cflags!": ['-fno-exceptions'],
"cflags_cc!": ['-fno-exceptions'],
"include_dirs": [
"<!(node -e \"require('nan')\")",
"addon",
"addon/include",
"../addon/include",
"C:/Projects/C++/vcpkg/installed/x64-windows/include",
"include",
".."
]
},
{
"target_name": "copy_binary",
"type": "none",
"dependencies": ["encrypt"],
'conditions': [
[
'OS=="mac"', {
"copies": [
{
"destination": "<(module_root_dir)/mac/",
"files": ["<(module_root_dir)/build/Release/encrypt.node"]
}
],
}
],
[
'OS=="win"', {
'msbuild_toolset': 'v141',
{
'cflags_cc': [
'/clr'
],
}],
'msvs_settings': {
'VCCLCompilerTool': {
'RuntimeLibrary':'MultiThreadedDLL'
}
},
'msbuild_settings': {
'ClCompile': {
'CompileAsManaged':'true' # can be safe, pure
}
},
"configurations": {
"Debug": {
"copies": [
{
"destination": "<(module_root_dir)/win32/",
"files": ["<(module_root_dir)/build/Debug/encrypt.node", "<(module_root_dir)/build/Debug/encrypt.pdb"]
}
]
},
"Release": {
"copies": [
{
"destination": "<(module_root_dir)/win32/",
"files": ["<(module_root_dir)/build/Release/encrypt.node", "<(module_root_dir)/build/Release/encrypt.pdb"]
}
]
},
}
}
],
]
}
]
}
I don't know much about node.js or .gyp files, but I do know the error you are getting. D8016 means that "/clr implies /EHa, and you cannot specify any other /EH compiler option with /clr". The problem is likely to occur when you import old project files, or add /clr to an existing project.
The official way to fix it is open the offending .vcxproj project file in Visual Studio, navigate to the project Properties / Config Properties / C/C++ / Code Generation and change Enable C++ Exceptions from "Yes with extern C functions (/EHs)" to "Yes with SEH Exceptions (/EHa)".
To do it outside VS, open the .vcxproj file in any text (or xml) editor and either delete the lines:
<ExceptionHandling>SyncCThrow</ExceptionHandling>
or replace them with:
<ExceptionHandling>Async</ExceptionHandling>
I'm creating a flatpak package for vlc. Since flatpak runs in sandbox and vlc depends on lua -> guile -> bdw-gc -> libunistring.
I have to first compile all these dependencies into flatpak sandbox. However bdw-gc and libunistring`` compile perfectly, butguilefails in last step ofmake` with error:
make[1]: Leaving directory '/run/build/guile'
stripping /home/ivansek/projects/vlc/flatpak/vlc-repo2/files/bin/guile to /home/ivansek/projects/vlc/flatpak/vlc-repo2/files/lib/debug/bin/guile.debug
stripping /home/ivansek/projects/vlc/flatpak/vlc-repo2/files/lib/libguile-2.0.so.22.8.1 to /home/ivansek/projects/vlc/flatpak/vlc-repo2/files/lib/debug/lib/libguile-2.0.so.22.8.1.debug
Error: module guile: Error opening file '/home/ivansek/projects/vlc/flatpak/vlc-repo2/files/lib/debug/source/guile/libguile/scmconfig.h': Permission denied
I'm using flatpak-builder for that using manifest file as:
{
"app-id": "org.gnome.vlc",
"runtime": "org.gnome.Platform",
"runtime-version": "3.22",
"sdk": "org.gnome.Sdk",
"command": "vlc",
"finish-args": [
"--socket=x11",
"--share=network",
"--share=ipc",
"--filesystems=host"
],
"modules": [
{
"name": "bdw-gc",
"sources": [
{
"type": "archive",
"url": "http://www.hboehm.info/gc/gc_source/gc-7.6.0.tar.gz",
"sha256": "a14a28b1129be90e55cd6f71127ffc5594e1091d5d54131528c24cd0c03b7d90"
}
]
},
{
"name": "libunistring",
"sources": [
{
"type": "archive",
"url": "http://ftp.gnu.org/gnu/libunistring/libunistring-0.9.6.tar.xz",
"sha256": "2df42eae46743e3f91201bf5c100041540a7704e8b9abfd57c972b2d544de41b"
}
]
},
{
"name": "guile",
"sources": [
{
"type": "archive",
"url": "https://ftp.gnu.org/gnu/guile/guile-2.0.13.tar.xz",
"sha256": "3744f2addc282a0de627aaef048f062982b44564d54ac31ff5217972529ed88b"
}
]
},
{
"name": "autogen",
"sources": [
{
"type": "archive",
"url": "https://ftp.gnu.org/gnu/autogen/rel5.18/autogen-5.18.tar.xz",
"sha256": "0c2dce22d4306ea29a01f6e54a35ea2b42dc7cf14f9818057b785e375bfbb784"
}
]
},
{
"name": "lua",
"sources": [
{
"type": "archive",
"url": "https://www.lua.org/ftp/lua-5.3.3.tar.gz",
"sha256": "5113c06884f7de453ce57702abaac1d618307f33f6789fa870e87a59d772aca2"
}
]
},
{
"name": "vlc",
"sources": [
{
"type": "archive",
"url": "http://get.videolan.org/vlc/2.2.4/vlc-2.2.4.tar.xz",
"sha256": "1632e91d2a0087e0ef4c3fb4c95c3c2890f7715a9d1d43ffd46329f428cf53be"
}
]
}
]
}
How can I solve this problem, or what is another approach to include vlc in flatpak?
I can't seem to figure this out and would appreciate any and all help.
I am using Node.js to make a query to MongoDB using the MultiPolygon filter. I am connecting to the native driver rather than using Mongoose because it doesn't seem like Mongoose supports MultiPolygon (absent in docs).
I receive a malformed query error though
GatheredListings.collection.find({
$and: [
{ 'rentAmount': { $gte: filterParameters.minPrice } },
{ 'rentAmount': { $lte: filterParameters.maxPrice } },
{ 'availabilityDate': { $gte: filterParameters.date } },
{ 'propertyType': filterParameters.propertyType },
{ 'bedrooms': filterParameters.bedrooms },
{ 'location': {
$geoWithin: {
$geometry: {
type : "MultiPolygon" ,
coordinates: [
geoArrayCollection
]
}
}}
}
]
}).toArray(function(err, properties) {
if (err || !properties)
{
console.log('err ' + err);
callback("No properties found", null);
}
else {
console.log('Number of properties retrieved: ' + properties.length);
callback(null, properties);
}
});`
The error is :
`err MongoError: Malformed geo query: { $geoWithin: { $geometry: { type: "MultiPolygon", coordinates: [ [ [ [ 43.77307711737606, -79.53517913818359 ], [ 43.79191518340848, -79.4476318359375 ], [ 43.75559702541283, -79.43887710571289 ], [ 43.7501411993079, -79.46514129638672 ], [ 43.7541091221655, -79.46943283081055 ], [ 43.75547303488856, -79.47406768798828 ], [ 43.75510106177428, -79.47715759277344 ], [ 43.75435710860915, -79.48093414306641 ], [ 43.75200119590339, -79.48282241821289 ], [ 43.74592499302, -79.48316574096678 ], [ 43.74282465186857, -79.49621200561523 ], [ 43.7404682852067, -79.49604034423828 ], [ 43.73873195568971, -79.49295043945312 ], [ 43.73525914559611, -79.49501037597655 ], [ 43.73538317799622, -79.50410842895508 ], [ 43.73290248118248, -79.51148986816406 ], [ 43.73947610307701, -79.51320648193359 ], [ 43.73649945803657, -79.52642440795898 ], [ 43.77307711737606, -79.53517913818359 ] ], [ [ 43.79203909839882, -79.4476318359375 ], [ 43.80380985089954, -79.39647674560547 ], [ 43.76334592336985, -79.38712120056152 ], [ 43.76179622406369, -79.39501762390137 ], [ 43.73600333614323, -79.43381309509277 ], [ 43.79203909839882, -79.4476318359375 ] ] ] ] } } }
Thank you
The MultiPolygon wasn't formatted correctly. You wanted this:
{
"type": "MultiPolygon",
"coordinates": [
[
[
[
43.77307711737606,
-79.5351791381836
],
[
43.79191518340848,
-79.4476318359375
],
[
43.75559702541283,
-79.43887710571289
],
[
43.7501411993079,
-79.46514129638672
],
[
43.7541091221655,
-79.46943283081055
],
[
43.75547303488856,
-79.47406768798828
],
[
43.75510106177428,
-79.47715759277344
],
[
43.75435710860915,
-79.4809341430664
],
[
43.75200119590339,
-79.48282241821289
],
[
43.74592499302,
-79.48316574096678
],
[
43.74282465186857,
-79.49621200561523
],
[
43.7404682852067,
-79.49604034423828
],
[
43.73873195568971,
-79.49295043945312
],
[
43.73525914559611,
-79.49501037597655
],
[
43.73538317799622,
-79.50410842895508
],
[
43.73290248118248,
-79.51148986816406
],
[
43.73947610307701,
-79.5132064819336
],
[
43.73649945803657,
-79.52642440795898
],
[
43.77307711737606,
-79.5351791381836
]
]
], // <--- missing this
[ // <--- missing this
[
[
43.79203909839882,
-79.4476318359375
],
[
43.80380985089954,
-79.39647674560547
],
[
43.76334592336985,
-79.38712120056152
],
[
43.76179622406369,
-79.39501762390137
],
[
43.73600333614323,
-79.43381309509277
],
[
43.79203909839882,
-79.4476318359375
]
]
]
]
}
but you were missing a layer of closing and opening of arrays that I have highlighted. The structures are big and nested so it's hard to eyeball what is going on; I'd suggest using tools like jsonlint and geojsonlint to contrast my corrected structure with your previous structure. It's the only way I was able to spot the problem.