CefView / QCefView

A Qt Widget encapsulated CEF view based on QWidget
https://cefview.github.io/QCefView/
GNU Lesser General Public License v2.1
529 stars 137 forks source link

STATIC_CRT设置为ON ,在VS2019编译demo不通过 #38

Closed reghtml closed 2 years ago

reghtml commented 2 years ago

您好: 我将QcefView里边的 option(STATIC_CRT "Use MultiThreaded linkage for MSVC" ON) 将QcefViewCore里边的 option(STATIC_CRT "Use MultiThreaded linkage for MSVC" ON)

环境变量指定 QTDIR = F:\QT\5.15.2static\msvc2019_64_static 【这个是我的QT静态编译的目录】

其他的没有修改,然后双击generate-win-proj.bat生成解决方案。

其他的项目能通过编译,但是demo失败: 图片

于是我按照文档里的说明自己新建一个demo项目去测试: `#include "myCef.h"

include <QtWidgets/QApplication>

include

int main(int argc, char *argv[]) { QApplication a(argc, argv);

QCefConfig config(argc, argv);
config.setUserAgent("QCefViewTest");
config.setLogLevel(QCefConfig::LOGSEVERITY_VERBOSE);
config.setBridgeObjectName("CallBridge");
config.setRemoteDebuggingPort(9000);

QCefContext cefContext(&a, &config);

myCef w;
w.show();

int rc = a.exec();

return rc;

} ` 结果还是无法正常启动: 图片

请问应该怎样怎样正确的使用MT/MTD静态编译来运行demo

tishion commented 2 years ago

你是要编译静态库吧?静态库跟MT/MD没有关系。 QCefView暂时不提供编译静态库的功能。

reghtml commented 2 years ago

你是要编译静态库吧?静态库跟MT/MD没有关系。 QCefView暂时不提供编译静态库的功能。

我不想静态编译库,我的exe程序是静态编译的,我想在我的程序里调用QCefView

总体来说: STATIC_CRT=OFF 一切正常, 同样其他配置不变的情况下,修改 STATIC_CRT=ON ,demo示例跑不起来!

tishion commented 2 years ago

你是要编译静态库吧?静态库跟MT/MD没有关系。 QCefView暂时不提供编译静态库的功能。

我不想静态编译库,我的exe程序是静态编译的,我想在我的程序里调用QCefView

总体来说: STATIC_CRT=OFF 一切正常, 同样其他配置不变的情况下,修改 STATIC_CRT=ON ,demo示例跑不起来!

你把STATIC_CRT改为ON之后,QCefView工程内的所有项目都会变成静态依赖CRT库,但是同时你链接了你自己的Qt库,如果你的Qt库也是静态链接CRT库(MT)的话,不应该有任问题,但是现在你跑起来之后挂掉了,而且应该是挂在跟CRT相关的地方,所以你先确认以下你的Qt库编译的时候对CRT的依赖方式是MT还是MD

reghtml commented 2 years ago

@tishion 您好,我测试了几遍,我直接用QT自带的QT库也是不行,目前用 F:\QT\5.15.2\msvc2019_64

下载好 QCefView 和 QCefViewCore 放到一起, 然后复制两份为cef1 和 cef2

图片 图片

【第一种-成功】 cef1里不做任何修改直接双击generate-win-proj.bat ,生成解决方案后直接打开cef1\QCefView.build\Windows\QCefView.sln

启动运行项目QCefViewTest 图片 完美运行。

【第二种-失败】 cef2里只修改一处cef2\QCefView\CMakeLists.txt文件的 option(STATIC_CRT "Use MultiThreaded linkage for MSVC" ON)

直接双击cef2\QCefView\generate-win-proj.bat 生成解决方案后直接打开cef2\QCefView.build\Windows\QCefView.sln 启动运行项目QCefViewTest

图片

我想问下,这种情况时候源码的问题 ? 还是 我将STATIC_CRT=ON 后 需要做其他格外的设置才行!

tishion commented 2 years ago

官方Qt版本是MD的,你把QCefViwe的CRT依赖改成MT,这样QCefView和你的Qt的CRT依赖不匹配,所以会报错。所以归根结底,你为啥想要修改CRT依赖呢?

如果你一定要使用MT,那你要保证你使用的Qt也是MT编译的。

reghtml commented 2 years ago

@tishion 因为我那个静态QT库是MT的 图片 他只支持MT的,如果我设置成MD 图片 他就报错了 图片

只有在设置成MT的时候才能成功 图片

但是我设置成MT就不能用QCefView了,因为我尝试了几天, 试着用MT去运行QCefView的demo 一直没成功

我试过 将QTDIR设置成官方QT库路径,或者 QTDIR设置成我那个静态版的QT库路径 ,都没法将QcefView以MT运行起来

tishion commented 2 years ago

贴一下你用自己的Qt + MT编译之后运行时崩溃的堆栈。

reghtml commented 2 years ago

图片 @tishion

这是输入的调试信息: `“mycef.exe”(Win32): 已加载“C:\Users\mianh\Desktop\cef3\QCefView.build\Windows\x64\Debug\mycef.exe”。已加载符号。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\ntdll.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\kernel32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\KernelBase.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\imm32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\user32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\win32u.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\dwmapi.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\wtsapi32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\uxtheme.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\gdi32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\msvcrt.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\msvcrt.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\msvcrt.dll”。 “mycef.exe”(Win32): 已卸载“C:\Windows\System32\msvcrt.dll” “mycef.exe”(Win32): 已卸载“C:\Windows\System32\msvcrt.dll” “mycef.exe”(Win32): 已加载“C:\Windows\System32\gdi32full.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\combase.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\combase.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\msvcp_win.dll”。 “mycef.exe”(Win32): 已卸载“C:\Windows\System32\combase.dll” “mycef.exe”(Win32): 已加载“C:\Windows\System32\ucrtbase.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\ucrtbase.dll”。 “mycef.exe”(Win32): 已卸载“C:\Windows\System32\ucrtbase.dll” “mycef.exe”(Win32): 已加载“C:\Windows\System32\rpcrt4.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\bcryptprimitives.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\ws2_32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\advapi32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\sechost.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\userenv.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\version.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\shell32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\netapi32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\profapi.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\cfgmgr32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\SHCore.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\windows.storage.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\winmm.dll”。 “mycef.exe”(Win32): 已加载“C:\Users\mianh\Desktop\cef3\QCefView.build\Windows\x64\Debug\QCefView.dll”。已加载符号。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\powrprof.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\umpdc.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\winmmbase.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\winmmbase.dll”。 “mycef.exe”(Win32): 已卸载“C:\Windows\System32\winmmbase.dll” “mycef.exe”(Win32): 已加载“C:\Windows\System32\shlwapi.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\kernel.appcore.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\cryptsp.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\ole32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\oleaut32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\netutils.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\srvcli.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\cryptbase.dll”。 “mycef.exe”(Win32): 已加载“C:\Users\mianh\Desktop\cef3\QCefView.build\Windows\x64\Debug\libcef.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\wintrust.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\msasn1.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\dbghelp.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\crypt32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\IPHLPAPI.DLL”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\dxgi.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\comdlg32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\d3d11.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\UIAutomationCore.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\oleacc.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\secur32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.18362.418_none_e6c6b287130d565d\comctl32.dll”。 “mycef.exe”(Win32): 已加载“C:\Users\mianh\Desktop\cef3\QCefView.build\Windows\x64\Debug\chrome_elf.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\hid.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\propsys.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\DWrite.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\winspool.drv”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\usp10.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\bcrypt.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\d3d9.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\dxva2.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\credui.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\urlmon.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\winhttp.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\cryptui.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\dhcpcsvc.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\wevtapi.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\nsi.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\ncrypt.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\esent.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\wininet.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\DXCore.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\iertutil.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\ntasn1.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\sspicli.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\wkscli.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\samcli.dll”。 QCoreApplication::applicationDirPath: Please instantiate the QApplication object first QObject: Cannot create children for a parent that is in a different thread. (Parent is QApplication(0xfe736fae0), parent's thread is QThread(0x1e312d65400), current thread is QThread(0x1e312d82db0) QObject::startTimer: Timers can only be used with threads started with QThread [0216/190652.516:WARNING:resource_bundle.cc(419)] locale_file_path.empty() for locale [0216/190652.516:ERROR:alloy_main_delegate.cc(538)] Could not load locale pak for en-US [0216/190652.516:ERROR:alloy_main_delegate.cc(545)] Could not load cef.pak [0216/190652.516:ERROR:alloy_main_delegate.cc(562)] Could not load cef_100_percent.pak [0216/190652.516:ERROR:alloy_main_delegate.cc(571)] Could not load cef_200_percent.pak [0216/190652.516:ERROR:alloy_main_delegate.cc(581)] Could not load cef_extensions.pak “mycef.exe”(Win32): 已加载“C:\Windows\System32\msctf.dll”。 [0216/190652.525:VERBOSE1:node_controller.cc(150)] Initializing node EE8C494421020DF1.1D5ECB718F948938 [0216/190652.526:INFO:content_main_runner_impl.cc(1065)] Chrome is running in full browser mode. “mycef.exe”(Win32): 已加载“C:\Windows\System32\dpapi.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\nlaapi.dll”。 线程 0x15820 已退出,返回值为 0 (0x0)。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\dhcpcsvc6.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\dnsapi.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\clbcatq.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\SogouTSF.ime”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\msimg32.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\SogouPY.ime”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\ntmarta.dll”。 “mycef.exe”(Win32): 已加载“D:\SOFT\souGou\SogouInput\11.2.0.5091\Resource.dll”。 “mycef.exe”(Win32): 已加载“D:\SOFT\souGou\SogouInput\Components\PicFace\1.1.0.1881\PicFace64.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\psapi.dll”。 线程 0x11180 已退出,返回值为 0 (0x0)。 [0216/190652.609:VERBOSE1:pref_proxy_config_tracker_impl.cc(186)] 00000474C4DE0610: set chrome proxy config service to 00000474C4E0DE10 “mycef.exe”(Win32): 已加载“C:\Windows\System32\gpapi.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\mdmregistration.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\msvcp110_win.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\dmcmnutils.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\omadmapi.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\iri.dll”。 “mycef.exe”(Win32): 已卸载“C:\Windows\System32\msvcp110_win.dll” “mycef.exe”(Win32): 已卸载“C:\Windows\System32\dmcmnutils.dll” “mycef.exe”(Win32): 已卸载“C:\Windows\System32\iri.dll” “mycef.exe”(Win32): 已卸载“C:\Windows\System32\omadmapi.dll” “mycef.exe”(Win32): 已卸载“C:\Windows\System32\mdmregistration.dll” “mycef.exe”(Win32): 已加载“C:\Windows\System32\winsta.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\MMDevAPI.dll”。 “mycef.exe”(Win32): 已加载“C:\Windows\System32\devobj.dll”。 [0216/190652.635:VERBOSE1:webrtc_internals.cc(118)] Could not get the download directory. [0216/190652.636:VERBOSE1:media_stream_manager.cc(700)] MSM::InitializeMaybeAsync([this=00000474C4E442D0]) [0216/190652.636:VERBOSE1:media_stream_manager.cc(700)] MDM::MediaDevicesManager() [0216/190652.636:VERBOSE1:media_stream_manager.cc(700)] MSM::MediaStreamManager([this=00000474C4E442D0])) [0216/190652.639:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.639:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.639:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.640:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.641:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.643:WARNING:resource_bundle.cc(1063)] locale resources are not loaded [0216/190652.643:FATAL:prefs_tab_helper.cc(281)] Check failed: success. mycef.exe 已触发了一个断点。

`

tishion commented 2 years ago

locales目录没有找到,参考QCefView项目最终生成的目录结构。

reghtml commented 2 years ago

@tishion 恩,我之前是将所有文件都复制到exe所在文件夹下的,结构如下 图片 但是我打开Debug\locales这个文件夹下,是空的,我尝试将Debug\resources\locales\下所有文件复制到Debug\locales,此时启动项目可以成功启动,但是我只是在main.cpp中初始化了QCefContext实例还没创建浏览器: 图片

当我创建了一个QCefView实例后: 图片 启动就报错了: 图片

图片

tishion commented 2 years ago

这些错误信息都已经很明显了,你自己解决吧。

reghtml commented 2 years ago

@tishion 对不起,我太菜了,实在没有查到这个错误怎么解决 源码很简单,应该没什么问题: 图片

启动软件运行正常: 图片

点击按钮创建浏览器,报同样的错误: 图片 图片

图片

tishion commented 2 years ago

你检查一下是不是Debug和Release版本的Qt dll混用了,或者不同版本的混用了。

reghtml commented 2 years ago

好的,感谢! 应该是这样的, 在网上查找这种错误也都说还是混用了Debug和Release ,我再研究下