At the moment I am trying to port a Visual C++ application to Linux. The code compiles without errors in Visual Studio, but I get many compiler errors under Linux. One of these errors is:
目前我正在尝试将Visual C ++应用程序移植到Linux。代码在Visual Studio中编译时没有错误,但我在Linux下遇到了很多编译器错误。其中一个错误是:
../src/wktools4.cpp:29: error: no matching function for
call to 'operator new(unsigned int, const char[40], int)'
More information:
- IDE: kdevelop with G++
- GUI API:
IDE:使用G ++进行kdevelop
The error appears at the following line:
错误出现在以下行:
IMPLEMENT_APP(Cwktools4App)
and some other lines.
和其他一些行。
What am I missing?
我错过了什么?
2 个解决方案
#1
It looks like your Visual C++ app has overloaded operator new()
.
看起来你的Visual C ++应用程序重载了operator new()。
This is often done (with the additional parameters you see) to add debugging and other analysis info to each memory allocation.
这通常是(使用您看到的附加参数)完成,以便为每个内存分配添加调试和其他分析信息。
Since you get the error with something as simple as frame = new Cwktools4Frame;
I recommend looking for macros or compiler-level defines that are redefining "new" as something else. The first place to look should be in debug-specific builds.
因为你得到的错误就像frame = new Cwktools4Frame一样简单;我建议寻找将“new”重新定义为其他东西的宏或编译器级定义。首先要看的是调试特定的构建。
#2
I found the error:
我发现了错误:
#ifdef __WXDEBUG__
#define new WXDEBUG_NEW
#endif
When I remove these lines, I don't get the errors any more. The code was generated from a wxwidgets wizard for VisualStudio. I have no idea what it does...
当我删除这些行时,我不再得到错误。代码是从VisualStudio的wxwidgets向导生成的。我不知道它做了什么......
Thank you all for your help! Now I have to fix the linker errors ;)
感谢大家的帮助!现在我必须修复链接器错误;)
#1
It looks like your Visual C++ app has overloaded operator new()
.
看起来你的Visual C ++应用程序重载了operator new()。
This is often done (with the additional parameters you see) to add debugging and other analysis info to each memory allocation.
这通常是(使用您看到的附加参数)完成,以便为每个内存分配添加调试和其他分析信息。
Since you get the error with something as simple as frame = new Cwktools4Frame;
I recommend looking for macros or compiler-level defines that are redefining "new" as something else. The first place to look should be in debug-specific builds.
因为你得到的错误就像frame = new Cwktools4Frame一样简单;我建议寻找将“new”重新定义为其他东西的宏或编译器级定义。首先要看的是调试特定的构建。
#2
I found the error:
我发现了错误:
#ifdef __WXDEBUG__
#define new WXDEBUG_NEW
#endif
When I remove these lines, I don't get the errors any more. The code was generated from a wxwidgets wizard for VisualStudio. I have no idea what it does...
当我删除这些行时,我不再得到错误。代码是从VisualStudio的wxwidgets向导生成的。我不知道它做了什么......
Thank you all for your help! Now I have to fix the linker errors ;)
感谢大家的帮助!现在我必须修复链接器错误;)