Dynamic Linking Error: Win32 Error 126问题排查

    如题所示,这个问题是我在electron项目中使用ffi调用动态链接库出现的,本机运行都好好的,打包构建然后放到别的机器上运行出错。

    这个问题一度也让我很迷茫,如果是路径导致的这个问题,那么把路径指定正确就可以了,但是偏偏路径也是对的,就是报错。那应该是环境问题。

    我为什么要使用ffi调用动态链接库?我的需求是这样的,需要编程实现tcpip方式连接诺德施瓦茨仪表设备cmw500,其实就是visa编程了,我开始通过c语言简单实现了这个功能,以为万事大吉了,然后写了一个动态链接库,让electron项目去调用,因为node方面对visa操作的很少,网上唯一可以搜到的一个链接就是github上的这个:https://github.com/petertorelli/ni-visa。我当时没有细看,也不确定这个方式可不可靠。

    自己写的动态链接库代码:

    pch.h

#ifdef PCH_H
#else 
#define PCH_H extern "C" _declspec(dllimport)

// add headers that you want to pre-compile here
#include "framework.h"

#endif //PCH_H
PCH_H void QueryMeasureResult(char* source,char* cmd,char* result);

    pch.cpp

// pch.cpp: source file corresponding to the pre-compiled header
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_D
03-15 06:40:46.092099 2559 2559 E AEE_DUMPSTATEV: start set_signal_for_dumpstate 03-15 06:40:46.092554 2559 2559 D AEE_DUMPSTATEV: cpu cores:8, online:8 03-15 06:40:46.092591 2559 2559 I AEE_DUMPSTATEV: aee_opt=0x10802c05 03-15 06:40:46.093234 2559 2559 E aee_dumpstatev: encrypt_dynamic_switch: File /proc/device-tree/chosen/aee,encrypt_enable not exist 03-15 06:40:46.093663 2559 2559 I AEE_DUMPSTATEV: archive_file_to_db: current dumped file is /data/vendor/aee_exp/temp/db.BngrQc/__exp_main.txt 03-15 06:40:46.094543 2559 2559 D AEE_DUMPSTATEV: archive_file_to_db: Collect file /data/vendor/aee_exp/temp/db.BngrQc/__exp_main.txt to __exp_main.txt successfully, size 2378 03-15 06:40:46.094823 2559 2559 I AEE_DUMPSTATEV: archive_file_to_db: current dumped file is /data/vendor/aee_exp/temp/db.BngrQc/SYS_PROPERTIES 03-15 06:40:46.097731 1323 1323 D RefBase : #00 pc 000000000001eacc /vendor/lib64/hw/android.hardware.camera.provider@2.6-impl-mediatek.so (NSCam::CameraDeviceManagerBase::setCallbacks(std::__1::shared_ptr<NSCam::ICameraDeviceManager::Callback> const&)+92) (BuildId: 07dcb7115531bb3a76cfdffdd14e876f) 03-15 06:40:46.097781 1323 1323 D RefBase : #01 pc 0000000000011034 /vendor/lib64/libmtkcam_hal_aidl_provider.so (mcam::aidl::AidlCameraProvider::setCallback(std::__1::shared_ptr<aidl::android::hardware::camera::provider::ICameraProviderCallback> const&)+484) (BuildId: 6a1a1f17a49f095e04e913fe67e3e1d1) 03-15 06:40:46.097792 1323 1323 D RefBase : #02 pc 0000000000009714 /vendor/lib64/android.hardware.camera.provider-V3-ndk.so (aidl::android::hardware::camera::provider::_aidl_android_hardware_camera_provider_ICameraProvider_onTransact(AIBinder*, unsigned int, AParcel const*, AParcel*)+676) (BuildId: 380fe1c5402524f7bead3c10e7bcf9c0) 03-15 06:40:46.097799 1323 1323 D RefBase : #03 pc 0000000000014c5c /system/lib64/libbinder_ndk.so (ABBinder::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+140) (BuildId: bee170cde521d5b46deec92cf12225ad) 03-15 06:40:46.097806 1323 1323 D RefBase : #04 pc 00000000000547a0 /system/lib64/libbinder.so (android::IPCThreadState::executeCommand(int)+1136) (BuildId: 1b648455103b1dc733387ca8b48e7827) 03-15 06:40:46.097811 1323 1323 D RefBase : #05 pc 00000000000561f0 /system/lib64/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+448) (BuildId: 1b648455103b1dc733387ca8b48e7827) 03-15 06:40:46.097818 1323 1323 D RefBase : #06 pc 00000000000051c4 /vendor/bin/hw/camerahalserver (main+2308) (BuildId: bb79eb04c3b959e493028f943a6845b4) 03-15 06:40:46.097824 1323 1323 D RefBase : #07 pc 000000000008d2d4 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+116) (BuildId: 3aab8884e58fcc217f003033d570dce2) 03-15 06:40:46.097862 1323 1323 W camerahalserver: AIBinder_linkToDeath is being called with a non-null cookie and no onUnlink callback set. This might not be intended. AIBinder_DeathRecipient_setOnUnlinked should be called first. 03-15 06:40:46.098210 2450 2450 W cameraserver: AIBinder_linkToDeath is being called with a non-null cookie and no onUnlink callback set. This might not be intended. AIBinder_DeathRecipient_setOnUnlinked should be called first. 03-15 06:40:46.098257 2450 2450 W BpBinder: Linking to death on android.hardware.camera.provider.ICameraProvider but there are no threads (yet?) listening to incoming transactions. See ProcessState::startThreadPool and ProcessState::setThreadPoolMaxThreadCount. Generally you should setup the binder threadpool before other initialization steps. 03-15 06:40:46.098537 1323 1323 W mtkcam-devicemgr: [notifyDeviceStateChange] Not implement, newState=0
03-19
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

luffy5459

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值