defining pragmas in a freeglut programme - c++

I am building an application that uses freeglut, in windows 32bit, debug mode. I have linked the static debug freeglut lib.
To fix linkage errors, as mentioned here:
freeglut error LNK1104
I have added:
#define FREEGLUT_STATIC
#define _LIB
#define FREEGLUT_LIB_PRAGMAS = 1
to the head of my .cpp.
That solves the linkage errors, but gives me an error in the freeglut_std.h file.
These sections:
# if FREEGLUT_LIB_PRAGMAS
# pragma comment (lib, "freeglut_static.lib")
# endif
# if FREEGLUT_LIB_PRAGMAS
# pragma comment (lib, "glu32.lib") /* link OpenGL Utility lib */
# pragma comment (lib, "opengl32.lib") /* link Microsoft OpenGL lib */
# pragma comment (lib, "gdi32.lib") /* link Windows GDI lib */
# pragma comment (lib, "winmm.lib") /* link Windows MultiMedia lib */
# pragma comment (lib, "user32.lib") /* link Windows user lib */
# endif
give me:
Error 3 error C1017: invalid integer constant expression freeglut_std.h 72 1
4 IntelliSense: expected an expression freeglut_std.h 72 12
Where am I going wrong here?
Thank you.

Related

DirectX 11 and g++ compile error

Hello I actually learning DirectX 11 with this tutorial: http://www.rastertek.com/dx11tut03.html
First Part
My code (where the probleme come from):
d3dclass.h:
//Linking
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "d3dx11.lib")
#pragma comment(lib, "d3dx10.lib")
//Include
#include <dxgi.h>
#include <d3dcommon.h>
#include <d3d11.h>
#include <d3dx10math.h>
I do all like the tutorial, the only diference is I compile it with g++, trough this the command :
g++ -mwindows WinMain.cpp systemclass.cpp inputclass.cpp graphicsclass.cpp d3dclass.cpp -o Prog.exe -I "D:\Programme File\DirectX SDK\Include" 2> log.txt
but in the output file, I have a large sum of errors. This is the log.txt:
https://drive.google.com/open?id=1XUlcAFUyRcLIvdKbe0FkLVjkvwxpOmEv
To sum up the log there is a lot of things like __in which has not been declared in the dxgi.h, but this header is from DirectX11 Library;
Second Part
I found the way to fix a lot of my problem (of the first part) with adding this :
#define __in
#define __out
#define __inout
#define __in_bcount(x)
#define __out_bcount(x)
#define __in_ecount(x)
#define __out_ecount(x)
#define __in_ecount_opt(x)
#define __out_ecount_opt(x)
#define __in_bcount_opt(x)
#define __out_bcount_opt(x)
#define __in_opt
#define __inout_opt
#define __out_opt
#define __out_ecount_part_opt(x,y)
#define __deref_out
#define __deref_out_opt
#define __RPC__deref_out
but there still is a major problem, this is the error output :
D:\Programme File\DirectX SDK\Include/d3dx10core.h:345:13: error: expected ';' at end of member declaration
HRESULT WINAPI_INLINE GetDesc(D3DX10_FONT_DESCA *pDesc) { return GetDescA(pDesc); }
it comes from WINAPI_INLINE (this is in the DirectX header)
How can I fix this? please.
I don't have any experience with using g++, but I can help with a few details here. To use g++ you need to install the Windows SDK and configure it to include the proper paths. The legacy DirectX SDK requires the Windows SDK and is not fully standalone.
Note that the legacy DirectX SDK and the Windows SDK don't claim to be compatible with the GCC toolchain.
The __in, __out, etc. macros are called "SAL annotations" and they are there to improve the quality of static code analysis both internally at Microsoft and when using Visual C++'s /analyze switch. They are defined as 'blank' in other cases so they just get removed from the code. The macros are defined in the Windows SDK. You can try explicitly doing a #include <sal.h> and/or #include <specstrings.h> before including a version of dxgi.h.
Another thing to keep in mind is that the legacy DirectX SDK itself is deprecated along with the D3DX9, D3DX10, and D3DX1 utility libraries. As such, if you are using the Windows 8.0, 8.1, or 10 SDK you can code Direct3D 11 without using it at all--see Living without D3DX. If you do want to continue to use those older helpers--which the somewhat dated rastertek tutorials assume--, you can do so but you need to make sure the DirectX SDK include and lib paths are searched after the Windows SDK include/lib paths.
If you were using Visual C++ (which BTW has a free Community edition available), then you'd probably be having an easier time. You might also want to see the DirectX Tool Kit tutorials.

FFmpeg. avcodec_find_encoder(AV_CODEC_ID_H264) return false

The problem: I can not connect the h264 codec for encoding and decoding of frames.
Description:
I downloaded from here ffmpeg library https://ffmpeg.zeranoe.com/builds/, version dev.
Connect it to your project QT:
extern "C"
{
#include <libavcodec\avcodec.h>
#include <libavformat\avformat.h>
#include <libavformat\avio.h>
#include <libswscale\swscale.h>
#include <libavutil\mem.h>
}
    
#pragma comment (lib, "avcodec.lib")
#pragma comment (lib, "avformat.lib")
#pragma comment (lib, "swscale.lib")
#pragma comment (lib, "avutil.lib")
Next prescribe av_register_all(); to include all codecs.
Next, call the function: avcodec_find_encoder(AV_CODEC_ID_H264), returns false.
In the ReadMe file, the library said that it was collected with --enable-libx264 and --enable-gpl compile the keys including h264 codec that is supposed to be.
If the call: avcodec_find_encoder(AV_CODEC_ID_MPEG1VIDEO), it returns an object AVCodec, as it should.
I use the MinGW compiler. OC Windows 7.
How can I resolve or work around the problem? Compile the library itself has not yet obtained. I understand you to connect sources and "poking" them, that too is meaningless.
** Once again, I will describe my problem: **
I need to encode the codec h264 (can VP9) individual frames in one program, and then decode them in another program. You can use other libraries. The language C ++. It is necessary to use interframe compression codec, rather than simply pressed apart frames.
Sorry for my english.
Ideas. Advice. Suggestions.

LINKER error: comsupp.lib and comsuppwd.lib

error is:
Error 14 error LNK2005: "void __stdcall _set_com_error_handler(void (__stdcall*)(long,struct IErrorInfo *))" (?_set_com_error_handler##YGXP6GXJPAUIErrorInfo###Z#Z) already defined in comsupp.lib(comsupp.obj) comsuppwd.lib
Did anyone run into this before?
There is a bug in the Visual Studio 2010 header <msclr/marshal.h>.
There is written
#pragma comment(lib, "comsupp.lib")
but compared to <comdef.h> there must be written
#ifdef _NATIVE_WCHAR_T_DEFINED
# ifdef _DEBUG
# pragma comment(lib, "comsuppwd.lib")
# else
# pragma comment(lib, "comsuppw.lib")
# endif
#else
# ifdef _DEBUG
# pragma comment(lib, "comsuppd.lib")
# else
# pragma comment(lib, "comsupp.lib")
# endif
#endif
See also the Lib-section in https://learn.microsoft.com/de-de/cpp/cpp/set-com-error-handler?view=vs-2019
So you have 2 Options
BAD: Edit the msclr/marshal.h in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\msclr\marshal.h. But then all collegues must change their file too.
Change the ProjectSetting Linker -> Input -> Ignore Specific Default Libraries and add commsupp.lib. !!!But attention if you have set the compiler option /Zc: wchar_t- (see C/C++ -> Language -> Treat WChar_t as Built in Type) AND compiling for Release then it must not be ignored!!! So each project configuration may/must be changed differently.
Error is resolved now. The cause of error was a header file: #include <msclr\marshal_cppstd.h> and conversion from System::String^ to std::string(I found a similar issue here):
//commented out following 3 lines and problem solved:
//looks like following type conversion has problems:
#include <msclr\marshal_cppstd.h>
msclr::interop::marshal_context marshal_context_1;
string_TempDir_XMLfiles=marshal_context_1.marshal_as<std::string>(String_Ptr_Destin_Dir_XMLfiles);

How to configure Visual Studio not to output warnings from libraries?

Is there any way to prevent Visual Studio from printing out warnings from included libraries?
\Wall gives me loads of warnings from STL and Qt headers, although I only want to see those originating from my own code (i.e. the code which is part of the current Visual Studio project).
You can use pragma to set the warning levels for each file.
So before you include
#pragma warning( push )
#pragma warning( disable : 4705 )
#pragma warning( disable : 4706 )
#pragma warning( disable : 4707 )
// Some code
#include your files here
#pragma warning( pop )
More information here: http://msdn.microsoft.com/en-us/library/2c8f766e%28v=vs.80%29.aspx
That's the only portable way (if using -isystem with other compilers):
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: ...)
#endif
#include <Q...>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
Hopefully they will implement isystem one of these days:
https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/14717934-add-a-cl-exe-option-for-system-headers-like-gcc-s
You can use warning level 4, it will only include warnings for your code.

glut.h error when testing glut in code blocks

When trying to build a project using glut I get an error. Not in the main.cpp but rather in the glut.h I've included.
#pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */
#pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */
#pragma comment (lib, "glu32.lib") /* link with OpenGL Utility lib */
#pragma comment (lib, "glut32.lib") /* link with Win32 GLUT lib */
#pragma warning (disable:4244) /* Disable bogus conversion warnings. */
#pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */
All of these lines are the ones who show an error with the description:
Warning: ignoring #pragma warning [-Wunkown-pragmas]
It's the same error for all of the these lines.
I also get one additional error, also in the glut.h file. It's on the line:
typedef unsigned short wchar_t;
This error reads:
error: redeclaration of built in C++ type "wchar-t" [-fpermissive]
Anyone who's got an idea of how I should go about solving this issue.
The linking seems to be fine since it realizes that the glut.h file
exist but the glut.h is the file providing the errors.