zlib miniunzip fails to open zip files - c++

I installed zlib 1.2.8 and built the miniunzip and minizip projects to test creating and opening a zip.
I built as debug on visual studio 2010 32 bit, with the debug dll zlibwapid .
Minizip worked fine to create a zip file however miniunzip failed to open the zipfile created, and looking in miniunz.c the failure is because:
uf = unzOpen2_64(zipfilename,&ffunc); returns 0.
I saw the code is wrapped as follows in defines:
#ifdef USEWIN32IOAPI
fill_win32_filefunc64A(&ffunc);
uf = unzOpen2_64(zipfilename,&ffunc);
#else
uf = unzOpen64(zipfilename);
#endif
On a hunch I changed the define at the top to:
#ifdef _WIN32
//#define USEWIN32IOAPI //disabled this
#include "iowin32.h"
#endif
Now mininunzip works fine but I dont really know why. Anyone know if this is a known bug , I couldnt find any information about it.
Thanks

Related

TBB on Windows XP (using in OpenCV) - error entry point InitializeCriticalSectionEx

I tried to compile TBB which I want to use on OpenCV. I am using Windows XP and Visual Studio 2010 C++. When I compiled TBB 4.4 I got the error
"The procedure entry point InitializeCriticalSectionEx could not be located in the dynamic link library KERNEL32.dll."
The error is similar but under little different conditions like here:
http://answers.opencv.org/question/6151/opencv_createsamplesexe-entry-point-problem-with-xp/
In my case I cannot run the program at all. I tried the solution described there, so I renamed InitializeCriticalSectionEx to InitializeCriticalSection and removed parameter 2 and 3.
OpenCV claimes the bug is not on their side. I know OpenCV uses this:
#if (_WIN32_WINNT >= 0x0600)
InitializeCriticalSectionEx(&cs, 1000, 0);
#else
InitializeCriticalSection(&cs);
#endif
I know this should not make any problems but I commented some lines to keep InitializeCriticalSection(&cs); only. I recompiled the OpenCV and still the same error. Finally I have found in TTB:
tbb44_20160627oss\include\tbb\machine\windows_api.h
__TBB_WINBASEAPI BOOL WINAPI TryEnterCriticalSection( LPCRITICAL_SECTION );
__TBB_WINBASEAPI BOOL WINAPI InitializeCriticalSectionAndSpinCount( LPCRITICAL_SECTION, DWORD );
// Overloading WINBASEAPI macro and using local functions missing in Windows XP/2003
#define InitializeCriticalSectionEx inlineInitializeCriticalSectionEx
I also find the word "InitializeCriticalSectionEx" in opencv_core310d.dll and opencv_core310.dll. Does the overload really work and why I got the error? How could I fix it?
Update:
the definition in OpenCV
#ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?)
#define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
#endif
"The procedure entry point InitializeCriticalSectionEx could not be located in the dynamic link library KERNEL32.dll."
This is a standard error that Windows displays when you try to run a program that contains a statically-bound call to a function in a DLL that does not exist.
The InitializeCriticalSectionEx function is not available on Windows XP, but the version of the library that you have contains code that calls this function.
OpenCV claimes the bug is not on their side. I know OpenCV uses this:
#if (_WIN32_WINNT >= 0x0600)
InitializeCriticalSectionEx(&cs, 1000, 0);
#else
InitializeCriticalSection(&cs);
#endif
OpenCV's workaround is a compile-time solution. It determines at the point when the library is compiled which version of Windows is being targeted, and uses that information to generate a call to the appropriate version of the function.
There are two possibilities for why this is going wrong in your case:
You are using the OpenCV library in binary form, and the binary that you have was compiled to target Windows Vista and later. You can solve this by obtaining the source code for OpenCV and compiling it yourself, either as a DLL or a static library.
You are compiling with _WIN32_WINNT set to 0x0600 or later. By default, the Windows headers define this symbol to the latest available version. You have to explicitly define an earlier target version if you want it. To arrange for targeting Windows XP, add the following code at the top of your code file (probably in your precompiled header):
#include <WinSDKVer.h>
#define _WIN32_WINNT _WIN32_WINNT_WINXP
#include <SDKDDKVer.h>

Hello World MQTT program in mbed

Was just testing a simple hello world mqtt program on my mbed board and I keep getting this error:
Error: Cannot open source input file "fsl_enet.h": No such file or directory in "EthernetInterface/lwip-eth/arch/TARGET_Freescale/k64f_emac_config.h", Line: 33, Col: 23.
Error
I even tried fixing the error by doing what the compiler suggests by adding mbed-dev library, but the error is still there.
#ifndef K64F_EMAC_CONFIG_H__
#define K64F_EMAC_CONFIG_H__
#include "fsl_enet.h"
#define ENET_RX_RING_LEN (16)
#define ENET_TX_RING_LEN (8)
#define ENET_ETH_MAX_FLEN (1522) // recommended size for a VLAN frame
#if defined(__cplusplus)
extern "C" {
#endif
int phy_link_status(void);
#if defined(__cplusplus)
}
#endif
#endif // #define K64F_EMAC_CONFIG_H__
Looks like the EthernetLibrary was broken recently for K64F. If you import https://developer.mbed.org/teams/mqtt/code/HelloMQTT/, and choose NOT to update libraries it compiles fine for K64F.
thanks for reporting. The tools scripts were not updated (+ mbed lib), which caused this breakage in the ethernet library. Because ethernet lib requires some new KSDK files which are not yet available.
The next mbed SDK release is tomorrow, which should fix this. In the meantime, we will look at this, to find better solution - for instance to move the target code in the lwip/arch into HAL. I'll have a look today.

Playing cutscenes in c++

I'm using SDL for opening a window and handeling events. And OpenGL to render my objects to the screen. SDL_mixer for sound, and SDL_ttf for text. Now I'm trying to figure out how to be able to put a video on display. Like an animated logo or something before the game starts. Just to experiment with it. At some point I will need to know it...
I've found and tried installing FFMPEG, I've included the "include" folder, and set the "lib" folder. At first I got an error telling me it was unable to load "inttypes.h". So I downloaded a package with that and put it in the include folder for FFMPEG.
Now I'm stuck with this error, which I can't seem to be able to solve.
c:\program
files\ffmpeg-20140507-git-4cdea92-win64-dev\include\libavutil\common.h(87):
fatal error C1004: unexpected end-of-file found
And another question, is there other libraries aviable that may be easier to use for displaying a simple video? I read something about SDL being able to do it, but nothing was to be found about it.
EDIT: Here is line 78 to 96:
#if FF_API_AV_REVERSE
extern attribute_deprecated const uint8_t av_reverse[256];
#endif
#ifdef HAVE_AV_CONFIG_H
# include "config.h"
# include "intmath.h"
#endif
/* Pull in unguarded fallback defines at the end of this file. */
#include "common.h"
#ifndef av_log2
av_const int av_log2(unsigned v);
#endif
#ifndef av_log2_16bit
av_const int av_log2_16bit(unsigned v);
#endif
Wrap your #include <libav*.h>s inside a block like this:
#ifndef __STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS
#define UNDEFINE_STDC_CONSTANT_MACROS
#endif
extern "C"
{
#include <libavdevice/avdevice.h>
#include <libavdevice/version.h>
}
#ifdef UNDEFINE_STDC_CONSTANT_MACROS
#undef __STDC_CONSTANT_MACROS
#endif
There's probably a way around using the UNDEFINE_STDC_CONSTANT_MACROS hack but the logic just isn't coming to me right now.
Worked for me on VS2012 using Zeranoe's 32-bit ffmpeg development binaries and msinttypes' inttypes.h.
Hmm, I found the DLL-files, and it gave me a linker error with the 64-bit library.
I changed back to 32-bit and the 32-bit dlls and it worked fine. I guess that libraries ask if you have 32/64-bit Visual Studio insteath of Windows.

Unable to open lib python. Project Panda3D. VS

I have just started a project c++ with Panda3D. ( Visual Studio 2010 )
With a simple HelloWorld, I add paths etc. No compile error except :
an error just appeared :
error LNK1104: cannot open file 'python27_d.lib'
And I have no idea how to fix it.
Plz help !
Thanks !
There's a few things you can do.
1) just build in release mode (not a good solution, since you can't debug too well this way)
2) add another build configuration based on "Release" but with debug symbols and without the _DEBUG preprocessor definition (can mess up some libraries)
3) find or build a Python 2.7 version with debug and release libraries build in Visual Studio 2010
4) just change this one section in the pyconfig.h where it actually links to the *.lib file to just use the python27.lib for both configurations.
/* For an MSVC DLL, we can nominate the .lib files used by extensions */
#ifdef MS_COREDLL
# ifndef Py_BUILD_CORE /* not building the core - must be an ext */
# if defined(_MSC_VER)
/* So MSVC users need not specify the .lib file in
their Makefile (other compilers are generally
taken care of by distutils.) */
# ifdef _DEBUG
# //-----------------------change the next line-------------//
# pragma comment(lib,"python27_d.lib")
# else
# pragma comment(lib,"python27.lib")
# endif /* _DEBUG */
# endif /* _MSC_VER */
# endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */
1) 2) and 4) are hacky solutions, so I'd suggest you try to use 3).

LoadString(AFX_IDP_PARSE_INT) fails in an mfc exe (not in a dll)

AFX_IDP_PARSE_INT is the id for a standard MFC error message (it's defined in afxres.h), but in my project it fails to load, meaning that LoadString returns FALSE, GetLastError returns ERROR_RESOURCE_NAME_NOT_FOUND, and CString stays empty.
This happens even when I try loading it at the beginning of InitInstanse:
BOOL CMyLegacyProject::InitInstance()
{
CString string;
if (!string.LoadString(AFX_IDP_PARSE_INT))
AfxMessageBox(_T("Failed."));
}
This same code works on a new project, however - same linking of MFC (I link to it statically), same WINVER, I've tried making it as similar as my old project, but I can't reproduce the error on a newly started project.
It looks like your resources are not building correctly. Make sure your .rc file includes all the AFX resources as well. First I'd try building a brand new project from scratch, test loading the string in that, and then have a look to see what the default .rc file looks like.
It should be including a file called 'afxres.rc', ie your RC should have something like this in it:
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif //_WIN32
#include "res\MyRes.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#include "afxprint.rc" // printing/print preview resources
#endif