huihut / OpenCV-MinGW-Build

👀 MinGW 32bit and 64bit version of OpenCV compiled on Windows. Including OpenCV 3.3.1, 3.4.1, 3.4.1-x64, 3.4.5, 3.4.6, 3.4.7, 3.4.8-x64, 3.4.9, 4.0.0-alpha-x64, 4.0.0-rc-x64, 4.0.1-x64, 4.1.0, 4.1.0-x64, 4.1.1-x64, 4.5.0-with-contrib, 4.5.2-x64
https://opencv.org/
924 stars 213 forks source link

作者你好,我在使用你编译出来的库的时候出现了无法定位程序输入点的错误 #18

Closed sennnnn closed 4 years ago

sennnnn commented 4 years ago

编译环境: 作者提供的编译工具包

这是我的makefile:

INCLUDES = -I. -ID:\OpenCV-4.1.1\include
# opencv 主要模块 core,imgproc,highgui,imgcodecs,videoio(注意和video的区别),calib3d,feature2d,video,objdetect,dnn,ml,gapi,cuda
# LIBS = -lopencv_core420 -lopencv_imgcodecs420
LIBDIRS = -L. -LD:\OpenCV-4.1.1\x64\mingw\bin 
LIBS = -lopencv_core411 -lopencv_imgcodecs411
# OPT = -O3 -Wno-deprecated

CC=g++

# % 表示匹配当前目录下的所有文件,$@ 代表规则中的目标,$< 指代第一个依赖条件,$^ 指代所有的依赖条件,$+ 与 $^ 相似,只是其不会去除重复的部分。

a:*.cpp
    $(CC) $+ $(INCLUDES) $(LIBDIRS) $(LIBS) -o $@ $(OPT)

.PHONY: all clean
clean:
    rm -f *.o 
all:
    echo make complete

这是我的main.cpp:

#include<opencv2/core.hpp>
#include<opencv2/imgcodecs.hpp>
#include<iostream>

using namespace std;
using namespace cv;

int main()
{
    cv::Mat a;
    a = cv::imread("1.png");
    cout<<a<<endl;
}

这是执行输出的a.exe得到的结果:

无法定位程序输入点
_ZNSt6thread15_M_start_threadESt10unique_ptrINS_6_StateESt1
4default_deleteIS1_EEPFvvE 于动态链接库
D:\OpenCV-4.1.1\x64\mingw\bin\libopencv_imgcodecs411.dll
上。
sennnnn commented 4 years ago

dll已经被添加到Path用户变量里面,是不行的,之后把dll就和exe放在同一目录下也不行的,而后我再把dll放在system32下面还是不行的

huihut commented 4 years ago
无法定位程序输入点...于动态链接库...

这个意思是能找到dll文件,但是找不到对应的库入口。原因可能很多,但我猜是你在32位的程序中使用了我编译的64位 OpenCV-4.1.1-x64 导致的,生成64位目标程序就可以了。

huihut commented 4 years ago

@sennnnn 现在怎么样了?若是解决了,我将关闭这个 issue。

sennnnn commented 4 years ago

感谢作者,暂时先关闭吧,目前已经转为使用 msvc 了,等过一段时间再来转回 MinGW

sennnnn commented 4 years ago

这次我大致弄清楚了,

无法定位程序输入点_ZNSt6thread15_M_start_threadESt10unique_ptrINS_6_StateESt14default_deleteIS1_EEPFvvE

这个错误是因为anaconda 中的 LIBSTDC++-6.DLL 与 MinGW64 的LIBSTDC++-6.DLL 冲突所导致的,在配置环境变量时将 MinGW64 的 bin 路径移到高于 anaconda 的 mingw-w64/bin 路径更高优先级的位置就可以了。

bbqz007 commented 2 years ago

your stdc++ version is too older than what the libopencv is compiled with.

the opencv3.4 is compiled with gcc7, and the document of the repo says gcc8, i think the opencv4 maybe compiled with gcc8.

make sure you link a newer stdc++.dll during runtime.

AtomicVar commented 10 months ago

这次我大致弄清楚了,

无法定位程序输入点_ZNSt6thread15_M_start_threadESt10unique_ptrINS_6_StateESt14default_deleteIS1_EEPFvvE

这个错误是因为anaconda 中的 LIBSTDC++-6.DLL 与 MinGW64 的LIBSTDC++-6.DLL 冲突所导致的,在配置环境变量时将 MinGW64 的 bin 路径移到高于 anaconda 的 mingw-w64/bin 路径更高优先级的位置就可以了。

牛,这个问题真的把我搞死,果然是 Conda 搞的鬼。

ycdhqzhiai commented 8 months ago

@sennnnn 我也遇见了这个问题,但是我没有安装ancoda, image 我这种的话该怎么处理啊

WRtux commented 7 months ago

@sennnnn @ycdhqzhiai
Found that one import _ZNSi5seekgESt4fposIiE from libstdc++-6.dll has changed in newer versions of GCC. For my current setup (MinGW-w64 12.2.0), the signature now becomes _ZNSi5seekgESt4fposI9_MbstatetE. More mismatches may exist as well.

To solve this problem, use a libstdc++-6.dll from older versions of MinGW.


@huihut
I suggest adding -static-libstdc++ when building to eliminate the dependency on specific versions of MinGW.

Feanus commented 1 month ago

神仙谢谢