Implementing DirectX SDK sample(XAudio2Sound3D) gives me an unresolved external error? - directx

When I implement the XAudio2Sound3D sample from the June 2010 SDK.I pretty much copied it all in my own framework and this one variable(sound3DInstance) shows up as an unresolved external: X3DAudioCalculate(sound3DInstance, &listener, &emitter, calcFlags, &dspSettings); and X3DAudioInitialize(details.OutputFormat.dwChannelMask, SPEEDOFSOUND, sound3DInstance);
Where the variable types are:
X3DAUDIO_HANDLE sound3DInstance;
X3DAUDIO_LISTENER listener;
X3DAUDIO_EMITTER emitter;
X3DAUDIO_DSP_SETTINGS dspSettings;
DWORD calcFlags = X3DAUDIO_CALCULATE_MATRIX | X3DAUDIO_CALCULATE_DOPPLER | X3DAUDIO_CALCULATE_LPF_DIRECT | X3DAUDIO_CALCULATE_LPF_REVERB | X3DAUDIO_CALCULATE_REVERB;
const float SPEEDOFSOUND = X3DAUDIO_SPEED_OF_SOUND;
XAUDIO2_DEVICE_DETAILS details;
Now the only common variable in both functions that show the error is sound3DInstance,so that has to be the problem.In the SDK Sample all the variables are put in a struct called *AUDIO_STATE* and in the initialization of the program,they call:
*ZeroMemory( &g_audioState, sizeof( AUDIO_STATE ) );*
In my code the variables are members of my Sound class and I just ZeroMemory them one by one,so shouldn't the effect be the same?

You're not linking your program against the XAudio library (Xaudio2.lib). Check the linker settings for your project.

Related

ESP8266 - Reading total and used bytes from Filesystem

I'm trying to check the total size and the used bytes of the Flash-FileSystem on an ESP8266.
I'm using Arduino IDE (2.0.1) with "esp8266 by ESP8266 Community" (3.0.2)
I found in different tutorials the commands
#import <FS.h>
SPIFFS.usedBytes();
SPIFFS.totalBytes();
Also in the arduino-esp32-documentation I found this functions, but the compiler says:
In file included from C:\Users\...\esp8266_temp_humid_log_with_http.ino:38:
C:\Users\...\http_serving.h: In function 'void showFilesize()':
C:\Users\...\http_serving.h:42:24: error: 'class fs::FS' has no member named 'totalBytes'
42 | int tBytes = SPIFFS.totalBytes();
| ^~~~~~~~~~
C:\Users\...\http_serving.h:45:25: error: 'class fs::FS' has no member named 'usedBytes'
45 | int uBytes = SPIFFS.usedBytes();
| ^~~~~~~~~
exit status 1
Compilation error: 'class fs::FS' has no member named 'totalBytes'
I know, SPIFFS is depricated. I also tried LittleFS with the same result. Unfortunally I cant find the library on my folders to take a look into it.
I don't get it, why this function is not available.
May anyone have an idea to solve the problem?
Thanks a lot.
the comment from Juraj helps me to solve the problem:
FSInfo fs_info;
SPIFFS.info(fs_info);
long usedBytes = fs_info.usedBytes;
long totalBytes = fs_info.totalBytes;
Thanks for the help.

msvc trying to compile cv::Matx<float,3,1> as a 4-element vector

Using MSVC 2017, OpenCV 3.4. Code
typedef Vec3f localcolor;
inline double lensqd(const localcolor & c) {
return c.ddot(c);
}
Get
error C2338: Matx should have at least 4 elements. channels >= 4
note: while compiling class template member function 'cv::Matx<float,3,1>::Matx(_Tp,_Tp,_Tp,_Tp)'
when compiling the ddot function.
The compiler is trying to instantiate a 3-element vector with 4 initializers. I can't see anything in the OCV source code that would make this happen.
So do I file a bug report with MS?
And how do you suggest I get a working build? The code is this way because I sometimes want
typedef Vec4f localcolor;
which BTW compiles without error.
Could you show the ddot function ?
I recently had the same error by attempting to initialize a Vec3f with 4 elements.

OmniThreadLibrary C++ builder Build issues

I'v been trying to get OmniThreadLibrary to run in builder, i've built it with all the c++ required files it builds ok but when i use it in an c++ builder app i get a bunch of error messages that look like the following
[bcc32 Error] DSiWin32.hpp(385): E2040 Declaration terminated incorrectly
one points at this line of code in the generated hpp file
static const System::Int8 CSIDL_ADMINTOOLS = System::Int8(0x30);
has anyone had this working in C++ builder or know the best way to resolve these issues
I'm using c++ builder settle and OmniThreadLibrary version 3.06
The Win32 API (and Delphi, for that matter) already declares CSIDL_ADMINTOOLS, Omni should not be declaring it at all. It should be using Delphi's Shlobj unit instead.
The Win32 API declares CSIDL_ADMINTOOLS using a #define statement:
#define CSIDL_ADMINTOOLS 0x0030
So the declaration in Omni's .hpp is getting modified by the C++ preprocessor to this:
static const System::Int8 0x0030 = System::Int8(0x30);
Thus the "Declaration terminated incorrectly" compiler error.
When Delphi code declares something that already exists in C++, it needs to be declared as either {$EXTERNALSYM} or {$NODECLARE} to avoid duplicate declarations, and then optionally use {$HPPEMIT} to output a relevant #include statement in a generated .hpp file. Delphi's units already do that for its Win32 declarations.
If Omni is not already doing that (and the error would suggest it is not) then it needs to be updated accordingly.

Lua - "multiple vms detected" while trying to add extension for statically linked Lua

I have application that contain statically linked lua 5.2 inteperpreter (and haven't access to code).
When I trying to write extension with next code:
#define LUA_LIB
#define LUA_BUILD_AS_DLL
#include "lua.hpp"
extern "C"
{
static int test(lua_State* state)
{
return 1;
}
static const struct luaL_Reg functions[] = {
{"test", test},
{NULL, NULL},
};
int __declspec(dllexport) luaopen_test(lua_State* state)
{
luaL_newlibtable(state, functions);
luaL_setfuncs(state, functions, 0);
return 0;
}
}
And compile it with statically linked lua52.lib .
I get "multiple vms detected" error when I trying to require it fromn lua code.
What I can do in this situation?
You can't compile it with statically linked lua52.lib as the main application loads its own version of lua52.lib and when this module is "required", it loads its own copy, which leads to "multiple VMs detected" message.
With statically compiled VM you have two options (on Windows): (1) include all your modules statically, or (2) compile your modules against Lua52.dll, but instead of the actual DLL include a "proxy" DLL that will forward Lua API calls to the methods in the statically compiled executable (the API methods also need to be exported in the executable).
See this thread for the discussion on how the executable needs to be compiled and LuaProxyDllFour page for the proxy DLL.
On Linux you don't need to have a proxy library, but you still need to avoid linking Lua interpreter into the library and export symbols from the executable by using -Wl,-E linker option; see lhf's answer for details.

CAP_PROP_FRAME_WIDTH undeclared in 'How to build applications with OpenCV inside the Microsoft Visual Studio' sample code

I'm following the instructions in How to build applications with OpenCV inside the Microsoft Visual Studio but I'm getting errors from the sample code:
error C2065: 'CAP_PROP_FRAME_WIDTH' : undeclared identifier
error C2065: 'CAP_PROP_FRAME_HEIGHT' : undeclared identifier
error C2065: 'CAP_PROP_FRAME_COUNT' : undeclared identifier
I think the identifiers that are undeclared should be declared in highgui so why am I not getting them despite the demo code's #include <opencv2/highgui/highgui.hpp>?
Here are the steps I have taken.
I've unpacked the OpenCV (Version 2.4.6) files into C:\OpenCV, run setx -m OPENCV_DIR C:\OpenCV\Build\x64\vc11 from an elevated command prompt and added %OPENCV_DIR%\bin to my path (following instructions in Installation in Windows). Then using the Property pages (View -> Property Pages or Shift-F4) set to 'All Configurations'
I've added $(OPENCV_DIR)\..\..\include to my C/C++ Additional Include Directories
I've added $(OPENCV_DIR)\lib to the linker Additional Library Directories
I've cut-an-paste the directory listing of the lib files in C:\OpenCV\build\x64\vc11\lib into my input Additional Dependencies
I've copied the sample code from the article into a new C++ console app (with ATL). I had to change one line in the template code from int _tmain(int argc, _TCHAR* argv[]) to int _tmain(int argc, char* argv[])
I think the identifiers that are undeclared should be (are) declared in highgui so why am I not getting them despite the demo code's #include <opencv2/highgui/highgui.hpp>?
Other people having similar issues getting this sample code working in the How to build applications with OpenCV inside the Microsoft Visual Studio note seem to fall over with link errors (e.g. here and here) but I am getting past the linker.
========== EDIT ==========
There appear to be more insurmountable difficulties with the sample code. It is documented as a simple example to load and display an image whose path is supplied as the sole argument to main, while the code listing itself is video code requiring four command line arguments (i.e. it first checks and stops if argc != 5). I've submitted a documentation bug. I think the sample code listing should have been be taken from this: https://github.com/Itseez/opencv/blob/master/samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
Try with CV_CAP_ or cv::CAP_... It looks like there were some changes aiming to improve consistency of constants in OpenCV...
I am using the opencv 2.4.6 and this has helped me do the trick
change CAP_PROP_FRAME_WIDTH into CV_CAP_PROP_FRAME_WIDTH
change CAP_PROP_FRAME_HEIGHT into CV_CAP_PROP_FRAME_HEIGHT
change CAP_PROP_FRAME_COUNT into CV_CAP_PROP_FRAME_COUNT
and similarly if there are any other cap prop keywords into cv cap prop keywords
try this.

Resources