Omnet++ make issues - omnet++

I get the following error when compiling omnetpp-5.4.1, do I need to uninstall the libgles2-mesa-dev package ?
In file included from /usr/include/GL/gl.h:2055:
/usr/include/GL/glext.h:469:19: error: typedef redefinition with different types
('ptrdiff_t' (aka 'int') vs 'khronos_intptr_t' (aka 'long'))
typedef ptrdiff_t GLintptr;
^
/usr/include/GLES3/gl31.h:74:26: note: previous definition is here
typedef khronos_intptr_t GLintptr;
^
In file included from osgviewer.cc:27:
In file included from /usr/include/arm-linux-gnueabihf/qt5/QtGui/QOpenGLFunctions:1:
/usr/include/arm-linux-gnueabihf/qt5/QtGui/qopenglfunctions.h:60:16: error:
cannot combine with previous 'double' declaration specifier
typedef double GLdouble;
^
/usr/include/osg/GL:129:38: note: expanded from macro 'GLdouble'
#define GLdouble double
^
3 errors generated.

This seems to be an issue with the system headers. If you do not need OpenSceneGraph/osgEarth support, you can turn it off in the configure.user file and the re-configure/rebuild omnet. That will exclude the OSG specific files from the build process. (if you do not need the graphical environment (Qtenv) you can even turn off that in the configure.user which will prevent also linking with Qt libs).

Related

Error: xkeycheck.h(179): warning C4005: 'char16_t': macro redefinition” | Fatal error C1189

My question is similar to this: Error: "warning C4005: 'SWIGTEMPLATEDISAMBIGUATOR': macro redefinition"
I have a similar warning code (changing on 'char16_t'):
xkeycheck.h(179): warning C4005: 'char16_t': macro redefinition
Then:
xkeycheck.h(179): note: argomenti della riga di comando: vedere la precedente definizione
di 'char16_t'
(Translation: "note: arugments of the command line: look at the previous definition of 'char16_t')
But it keeps on giving this:
xkeycheck.h(250): fatal error C1189: #error: The C++ Standard Library forbids macroizing
keywords. Enable warning C4005 to find the forbidden macro.
Compiler: Visual Studio 2015
Support for char16_t and char32_t was added to Visual Studio 2015. This means you can no longer create symbols with these names, but then again you don't need them anymore as they already exist.
The solution is to remove the creation of the typedef or macro, or at least guard it when defined(MSC_VER) && _MSC_VER < 1900.
See MSDN:
char_16_t and char32_t You can no longer use char16_t or char32_t as aliases in a typedef, because these types are now treated as built-in. It was common for users and library authors to define char16_t and char32_t as aliases of uint16_t and uint32_t, respectively.
To update your code, remove the typedef declarations and rename any other identifiers that collide with these names.

How to get better error output with Visual Studio

I was working on a project and got the following errors
Error (active) the default constructor of "Input" cannot be referenced -- it is a deleted function EquationSolver c:\Users\Kim\Documents\Visual Studio 2015\Projects\EquationSolver\EquationSolver\main.cpp 10
Error C2280 'Input::Input(void)': attempting to reference a deleted function EquationSolver <project_dir>\main.cpp 10
Since it is almost impossible to find the cause of the error from this, I tried compiling with gcc with -Wall and got following output
main.cpp: In function 'int main()':
main.cpp:10:9: error: use of deleted function 'Input::Input()'
Input input;
^~~~~
In file included from main.cpp:2:0:
Input.hpp:16:7: note: 'Input::Input()' is implicitly deleted because the default definition would be ill-formed:
class Input
^~~~~
Input.hpp:16:7: error: use of deleted function 'Expressions::Expressions()'
In file included from Input.hpp:11:0,
from main.cpp:2:
Expressions.hpp:8:7: note: 'Expressions::Expressions()' is implicitly deleted because the default definition would be ill-formed:
class Expressions
^~~~~~~~~~~
Expressions.hpp:8:7: error: uninitialized reference member in 'class Expressions'
Expressions.hpp:17:8: note: 'Expressions::Vec& Expressions::left' should be initialized
Vec& left;
^~~~
Expressions.hpp:8:7: error: uninitialized reference member in 'class Expressions'
class Expressions
^~~~~~~~~~~
Expressions.hpp:18:8: note: 'Expressions::Vec& Expressions::right' should be initialized
Vec& right;
^~~~~
This output is much more verbose and quickly helped me find the origin, which was a misplaced & (class member should be Vec left, was Vec& left).
Is it possible to make Visual Studio as verbose?
When putting Visual Studio to /Wall, I get >1800 warnings, most completely unrelated to my project, but I still only get those two errors.

error C4430: missing type specifier - int assumed?

I have written a callback method and when I am trying to compile the project in vs2012, I am getting the following error:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '&'
the both error present in same line.
These are the following code which I am trying:
#include <windows.h>
#include "atlstr.h"
///////////////////////////////////////////////////////////////////////////////
class CInf;
typedef BOOL (*PENUMDEVCALLBACK)(CInf* inf, const CString& devname, const CString& instsecname, const CStringArray& devid, PVOID context, DWORD& code);
I think the error will be present in CStringArray& argument because when I include the afxcoll.h.
the fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>.
When I removed the windows.h. the above error gone but I need windows.h header also.
Any idea how to include windows.h and afxcoll.h in same file.
It is not possible to include only isolated parts of the MFC. When you want to use CStringArray you Need to include the afx.h or afxwin.h file.
It is possible to use CString alone. If you just want an Array of CString and you don't Need the complete MFC than it is easier to use std::vector. CString works perfect with all STL container.

Unknown error when compiling Clang 3.3 with Mingw

I'm not able to compile clang(3.3) using MinGW 4.8.1. The following error always pops-up when 70% build is complete:
clang/lib/Basic/FileManager.cpp includes sys/stat.h, which defines #define stat _stat64i32 (actually there are a few other defines in between, but you get the idea ;)
clang/include/clang/Basic/FileManager.h does not include sys/stat.h; instead only has a forward-declaration.
Hence, while parsing the header, the forward declaration is used (struct stat)
But when it finally arrives at the implementation, the preprocessor will kick in and replace struct stat with struct stat64i32. Hence the mismatch.
The best solution would be to change the forward declaration in the header to instead include sys/stat.h. (I didn't actually test if it will compile then)
The current trunk does not contain the code anymore.
Update: regarding off64_t. This is defined in _mingw_off_t.h these days as:
#ifndef _OFF64_T_DEFINED
#define _OFF64_T_DEFINED
__MINGW_EXTENSION typedef long long _off64_t;
#if !defined(NO_OLDNAMES) || defined(_POSIX)
__MINGW_EXTENSION typedef long long off64_t;
#endif
#endif /*_OFF64_T_DEFINED */
So you probably want to define _POSIX before including io.h (or stdio.h)

IntelliSense: argument of type "_TCHAR *" is incompatible with parameter of type "const char *"

Sorry for asking such a beginner question but I'm really new to openCV and VC++2010. I searched the net for an answer but I did not get an appropriate one.
Building the first project "First Program-Display a Picture" of the OReilly-LearningOpenCV book, I encountered these errors:
1-error C2664: 'cvLoadImage' : cannot convert parameter 1 from '_TCHAR *' to 'const char *'
2-IntelliSense: argument of type "_TCHAR *" is incompatible with parameter of type "const char *"
here's the code:
#include "stdafx.h"
#include "opencv\highgui.h"
int _tmain(int argc, _TCHAR* argv[])
{ IplImage* img = cvLoadImage( argv[1] );
cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvShowImage( "Example1", img );
cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow( "Example1" );
system("pause");
return 0;
}
and here's the message that I get from Microsoft Visual Studio 2010:
1>------ Build started: Project: FirstProgram_DisplayAPicture3, Configuration: Debug x64 ------
1>Build started 7/6/2013 11:13:00 AM.
1>InitializeBuildStatus:
1> Touching "x64\Debug\FirstProgram_DisplayAPicture3.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1> FirstProgram_DisplayAPicture3.cpp
1>FirstProgram_DisplayAPicture3.cpp(9): error C2664: 'cvLoadImage' : cannot convert parameter 1 from '_TCHAR *' to 'const char *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.68
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Additional information that may be required:
I have made a win32 Console Application and in the second page of the wizard I have chosen precompiled header setting.
I have changed the platform of the project to x64 because I'm using win7x64 as the OS.
I have linked openCV library to my project properly.
I have just introduced highgui.lib as the additional dependencies
Any help would be appreciated.
What can I do to solve the two errors?
Edited section:
Note that these errors occur in line 6, I mean the line IplImage* img = cvLoadImage( argv[1] );
My edited section based on Roger Rowland's suggestion:
Based on what Roger Rowland said, I changed the Character Set property of the project to Not Set. The two errors mentioned above got solved but these errors rose up.
error LNK1120: 1 unresolved externals
error LNK2019: unresolved external symbol cvReleaseImage referenced in function main
How can I solve the problem?
Your project is configured for Unicode which means that the _TCHAR macro evaluates to wchar_t, which is a 16 bit UTF-16 data type on Windows. But the library you are calling accepts 8 bit char data.
So, you will need to make both sides of the interface match. Lots of ways to do that. The obvious options are:
Change your project to target ANSI (change the character set to multi byte in the VS project configuration).
Convert the input argument from UTF-16 to ANSI before calling the library.
It seems to me to be needlessly complex to use _TCHAR these days. That was useful when we needed to support Win9x (no Unicode support) and WinNT (supports Unicode) from a single code base. But I expect that nowadays you are targeting NT based systems and so you are safe to assume support for Unicode. In which case you can use wchar_t, wstring etc.
On the other hand, perhaps this is just a simple program for your personal use. In which case, since your library wants 8 bit characters, maybe it's simplest for you to target ANSI.
But either way I rather suspect that _TCHAR is just going to confuse you. I'd abandon that if I were you.
One final point is that you mention that you target x64 since your system is 64 bit. Do be aware that 64 bit systems can run 32 bit code perfectly well. If you want your program to be capable of running on a 32 bit system, and you don't have a pressing need to run under 64 bit, then it may be easier to target x86.
Your edit to the question asks a separate question, which I'll attempt to answer in spite of my reservations.
The unresolved external symbol error indicates that the linker could not resolve that particular symbol. In order for the linker to resolve it, it needs to be passed the .lib file that defines that symbol. You should double check that you have included all required .lib files in your additional dependencies. From what I can glean, there are multiple .lib files for OpenCV and you are probably missing the one which defines cvReleaseImage.
In my case I was including a header file twice.
I modified my library to be like:
#ifndef MY_LIB
#define MY_LIB
// code
#endif

Resources