C++ Project have lib files but it gives missing *.dll error when starting - visual-c++

Hello Professional Developer Community.
I'm a C# and Android developer. I don't understand much from C++.
I have a C++ Win32 project. I think it's written with VS 2015.
Project have two static libraries (LuaLibDll.lib and LuaScriptVM.lib)
Lib files have been added to the Linker>Input and have header files(.h).
The compilation is successful but gives me an error when starting the Win32 program.
The program can't start because LuaLib.dll (and LuaScriptMV.dll) is
missing from your computer.Try reinstalling the program to fix this
problem.
Note:
Project does not create dll(s).
These codes are added in LuaLib.h and LuScriptVM.h
#ifndef __linux
#ifdef LUASCRIPTVM_EXPORTS
#define _LUAVM __declspec(dllexport)
#else
#define _LUAVM __declspec(dllimport)
#endif
#else
#define _LUAVM
#endif
Thank you for your interest

Related

Memory leak in CPP module

I have a cpp service which is built using cxx file. How can I analyze memory leak in this file using CRT library?
Tried with adding
#define new new(_NORMAL_BLOCK_,__FILE__,__LINE__)
But its showing error.
Is that the same way?
Try this:
#define DEBUG_NEW new(__FILE__, __LINE__)
#define new DEBUG_NEW

unresolved external symbol _IID_IDXGIAdapter4

It is really weird....
I think this symbol _IID_IDXGIAdapter4 in dxguid.lib, but when I use DUMPBIN command to check the symbols inside the dll. There are _IID_IDXGIAdapter1~3, no _IID_IDXGIAdapter4.
Windows SDK : 10.0.18362.0
And most weird is I found a DX12 tutorial that using IDXGIAdapter4 and I can compile it successfully, but my project can't, even I copy his project setting.
https://github.com/jpvanoosten/LearningDirectX12/blob/v0.0.1/Tutorial1/src/main.cpp
In this project, he only use d3d12.lib ,dxgi.lib ,dxguid.lib, and I already put them into project setting.
This was an oversight and is fixed in the next Windows 10 SDK after the current one (i.e. 19041 still has the bug).
DXGUID.LIB was missing:
IID_IDXGIAdapter4
IID_IDXGIOutput6
IID_IDXGIFactory6
IID_IDXGIFactory7
It was reported on GitHub as well.
There's nothing special about dxguid.lib. It's just code like this:
#define INITGUID
#include <Windows.h>
#include <d3dcommon.h>
#include <dxgi1_5.h>
#include <dxgidebug.h>
#include <d3d11_4.h>
#include <d3d11shader.h>
#include <d3d11sdklayers.h>
#include <d3dcompiler.h>
#include <d3d12.h>
#include <d3d12video.h>
#include <d3d12shader.h>
#include <d3d12sdklayers.h>
The bug was using dxgi1_5.h in the dxguid library source, but I updated it to use dxgi1_6.h.
Note that most of the "COM" GUIDs such as for Windows Imaging Component (WIC) are in uuid.lib.
UPDATE: This bug in dxguid.lib is fixed in Windows 10 SDK (20348), version 2104.
pDxgiAdapter1->QueryInterface(IID_IDXGIAdapter4, (LPVOID *)p_ppDxgiAdapter4);
change to
pDxgiAdapter1->QueryInterface(__uuidof(IDXGIAdapter4), (LPVOID *)p_ppDxgiAdapter4);
solve my problem
but in dxgi1_6.h
DEFINE_GUID(IID_IDXGIAdapter4,0x3c8d99d1,0x4fbf,0x4181,0xa8,0x2c,0xaf,0x66,0xbf,0x7b,0xd2,0x4e);
I still can't use IID_IDXGIAdapter4.

dumpbin command not listing function names in dll

I have a DLL which is develeoped in VB.Net. I am trying to call its functions from my vc++ code. The dll has successfully loaded using LoadLibrary function.
But when I try calling any function within the dll, it gives a null pointer exception.
I used the dumpbin command to confirm the function arguments within my dll. But it is not listing any functions. Could it be a problem with the dll or does dumpbin support few dlls only? Please help!
C:\Program Files (x86)\Microsoft Visual Studio 11.0>dumpbin ECR.dll
Microsoft (R) COFF/PE Dumper Version 11.00.51106.1 Copyright (C)
Microsoft Corporation. All rights reserved.
Dump of file ECR.dll
File Type: DLL
Summary
2000 .reloc
4000 .rsrc
2000 .sdata
16000 .text
Try writing before any function in your DLL file (header .h files) the name of the project with _API at the end (ECR_API).
for example, lets say we want to create a constructor and destructor for a class called Loader:
class Loader{
public:
ECR_API Loader();
ECR_API ~Loader();
}
also dont forget to add export and import statements at the beggining of your header file:
#ifdef ECR_EXPORTS
#define ECR_API __declspec(dllexport)
#else
#define ECR __declspec(dllimport)
#endif
hope this helps!
worked fine for me.

Multi threading in borland

I'm programming c++ in Borland c++ 5.02. I'm trying to run this code:
#include <stdio.h>
#include <pthread.h>
#define NUM 5
main()
{
pthread_t t1, t2; /* two threads */
void *print_msg(void *);
pthread_create(&t1, NULL, print_msg, (void *)"hello");
pthread_create(&t2, NULL, print_msg, (void *)"world\n");
pthread_join(t1, NULL);
pthread_join(t2, NULL);
}
But I get this error:
Info :Compiling C:\BC5\BIN\noname00.cpp
Error: noname00.cpp(2,2):Unable to open include file 'PTHREAD.H'
Error: noname00.cpp(8,15):Undefined symbol 'pthread_t'
Error: noname00.cpp(8,15):Statement missing ;
Error: noname00.cpp(12,18):Call to undefined function 'pthread_create'
I highlighted the main error which is caused by 'PTHREAD.H'. I checked the include folder for this file. It doesn't exist. How can I fix this problem?
Borland's C++ toolchain doesn't include a pthreads library, nor does the Windows SDK. You'll either need to use native Win32 thread APIs or get a 3rd party pthreads implementation for Windows.
Some options include:
winpthreads.h: http://locklessinc.com/articles/pthreads_on_windows/
pthreads-win32: https://www.sourceware.org/pthreads-win32/
I have no idea how well those things work with Borland C++ 5.x.
Another alternative is to use a toolchain that includes a pthreads implementation, such as TDM's MinGW toolchain:
http://tdm-gcc.tdragon.net/
your problem is #include <pthread.h>
you need either copy all the pthread related files (.h,.c,.cpp,.hpp,.lib,.obj)
into compiler include folder
or add include path to it in your project/compiler settings
or copy it locally to your project and change #include <pthread.h> to #include "pthread.h"
So compiler did not find the pthread.h header
so no datatype from it is known from compiler side (like pthread_t)
therefore the rest of the errors...

buildroot : predefs.h header error

I'm using buildroot to build OS for Raspberry. when compiling I get this error
BuildRoot/bsquask/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/include/bits/predefs.h:20:3: error: #error "Never use <bits/predefs.h> directly; include <features.h> instead."
# error "Never use <bits/predefs.h> directly; include <features.h> instead."
I searched online, some make a patch for this header and modify it, they say it works but not for me (I found many patches)
predefs.h
#ifndef _FEATURES_H
# error "Never use <bits/predefs.h> directly; include <features.h> instead."
#endif
#ifndef _PREDEFS_H
#define _PREDEFS_H
/* We do support the IEC 559 math functionality, real and complex, but only
if a VFP coprocessor is present. If we don't have one, we fall back to
software emulation and the functions won't work properly. So in general,
we don't claim to support this functionality. */
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
#define __STDC_IEC_559__ 1
#define __STDC_IEC_559_COMPLEX__ 1
#endif
#endif /* predefs.h */
edit the file by ignoring the error (comment the line)
#ifndef _FEATURES_H
//# error "Never use <bits/predefs.h> directly; include <features.h> instead."
#endif
on my experience, it works for me fine this way

Resources