error: ‘wxWebRequestEvent’ has not been declared Error despite having #include <wx/webrequest.h>

huangapple go评论72阅读模式
英文:

error: ‘wxWebRequestEvent’ has not been declared Error despite having #include <wx/webrequest.h>

问题

在我的Ubuntu操作系统上,我在CodeLite IDE中遇到了这个错误,但我不确定原因,因为我已经正确包含了#include <wx/webrequest.h>

Documents/CodeliteProjects/LearnFrench/modifyVocabFrame.cpp:75:10: error: wxWebRequest’在此作用域中未声明

我尝试编译了wxWidgets-3.2示例文件夹中的wxWebRequest示例,使用终端中的make命令,但出现了以下错误。

webrequest.cpp:29:2: error: #error "wxUSE_WEBREQUEST必须为1才能运行此示例。"
   29 | #error "wxUSE_WEBREQUEST必须为1才能运行此示例。"
      |  ^~~~~
webrequest.cpp:251:28: error: wxWebRequestEvent’未声明

wx-config命令显示我可以访问wxNet和其他wxCore/Base库,而且我的系统上似乎已经安装了g++和build-essentials,但找不到msw,而头文件也位于正确的位置。有人知道如何解决这个错误吗?

我尝试在终端中将wxUSE_WEBREQUEST=1导出为环境变量,但似乎无法解决make的错误。不确定是否需要在makefile中传递一个标志,或者是否需要完全不同的方法。如果问题是标志设置不正确,那么makefile似乎应该已经包含正确的标志,所以我认为问题可能是其他方面,但不太确定。

英文:

I'm getting this error in the CodeLite IDE on my ubuntu OS, and I'm not sure why since I've done the proper #include <wx/webrequest.h>

Documents/CodeliteProjects/LearnFrench/modifyVocabFrame.cpp:75:10: error: &#39;wxWebRequest&#39; was not declared in this scope

I've gone to the wxWebRequest sample in my wxWidgets-3.2 samples folder, and tried compiling it by using make in terminal and get these errors.

webrequest.cpp:29:2: error: #error &quot;wxUSE_WEBREQUEST must be 1 for this sample.&quot;
   29 | #error &quot;wxUSE_WEBREQUEST must be 1 for this sample.&quot;
      |  ^~~~~
webrequest.cpp:251:28: error: ‘wxWebRequestEvent’ has not been declared

wx-config says I have access to wxNet and all the other wxCore/Base libraries and it appears I have g++ on my system with the build-essentials, and can't seem to find msw, and the header file is in the proper spot. Does anyone know how to resolve this error?

I tried exporting the wxUSE_WEBREQUEST=1 as an environment variable in terminal, didn't seem to solve the make errors. Not sure if I need to pass a flag to the compiler in the makefile, or something else entirely. It seems weird the makefile wouldn't have the proper flag set already if that's the issue, so I'm thinking it's something else, not quite sure what.

答案1

得分: 1

我解决了这个问题。原来,存储库中的库默认情况下关闭了wxWebRequest,原因不明(或者也许在我安装了存储库中的wx-3.2库时,我当时没有安装libcurl-dev?谁知道呢)。所以我下载了wxWidgets源代码,然后使用./configure、make、make install编译(在安装之前,我确保在make文件中有wxUSE_WEBREQUEST=1),然后将新创建的库连接到IDE中,它就可以工作了!这绝对不是我寻找的答案,但至少源代码被编译并且可以工作。如果官方的Ubuntu存储库库可以开箱即用会更好,但看来wxWidgets似乎不是这样。

英文:

I solved the problem. Turned out, the libraries from the Repo have wxWebRequest turned off by default for some reason (Or maybe I didn't have libcurl-dev at the time I installed the wx-3.2 libraries from the repos? Who knows). So I downloaded the wxWidgets Source code and compiled using ./configure, make, make install (I made sure wxUSE_WEBREQUEST=1 was in the make files before installing), and hooked up the newly created libraries in the IDE and it worked! Definitely not the answer I was looking for, but at least the source code compiled and it worked. Be nicer if the official Ubuntu repo libraries worked out of the box, but wxWidgets don't seem like they do.

答案2

得分: 0

wxUSE_XXX 预处理符号在构建库时被定义为0或1。在Unix下,这发生在运行configure脚本时,该脚本会生成包含这些定义的wx/setup.h文件。如果在你的情况下wxUSE_WEBREQUEST 的值为0,这意味着你的库版本中根本没有支持wxWebRequest

要解决这个问题,你需要使用系统包中的库,它应该已经启用了相关支持,或者自己构建库并检查你自己的config.log(不是无关的libtool包的),该文件是在运行configure时创建的,用于查看是否已启用支持以及如果没有启用支持,则查看原因。

后者最有可能的原因是你没有安装libcurl-dev包(也可能称为libcurl4-dev)。在这种情况下,你需要安装它,然后重新运行configuremake来构建带有wxWebRequest支持的库。

英文:

wxUSE_XXX preprocessor symbols are defined as 0 or 1 when building the library. Under Unix this happens when running configure script, which generates the wx/setup.h file containing these definitions. If wxUSE_WEBREQUEST is 0 in your case, it means that support for wxWebRequest is simply not present in your version of the library.

To fix this, you need to either use the library from the system package, which should have it enabled, or build it yourself and check your config.log (not that of unrelated libtool package) created when you run configure to see whether support for it was enabled or not and why if it wasn't.

The most likely reason for the latter is that you don't have libcurl-dev package (which may also be called libcurl4-dev) installed. In this case you need to install it, and then rerun configure and make to build the library with wxWebRequest support.

huangapple
  • 本文由 发表于 2023年2月27日 10:11:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75576261.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定