I was just trying to use NtCreateSection in my code and the information at this link states the requirement as ntdll.lib. As Im using VS2010, I went to Projects > Properties > Linker > Input > Additional Dependencies and added ntdll.lib.
However, on building the solution I get an error error C3861: 'NtCreateSection': identifier not found. I'm curious about why this happens.
A workaround I'm considering is getting a handle to ntdll using LoadLibrary and getting a handle to NtCreateSection using GetProcAddress; however Im just curious about why the earlier method did not work out.
Thanks!
Perhaps of interest is the actual documentation of the function: http://msdn.microsoft.com/en-us/library/windows/hardware/ff556473(v=vs.85).aspx
This points you to a ZwCreateSection function, which notes that NtCreateSection is the name to be used for user-mode calls to this function: http://msdn.microsoft.com/en-us/library/windows/hardware/ff566428(vr85).aspx
In the standard header/library reference in the actual documentation, it says Wdm.h is the header to be included. I would recommend checking that file for the function(s), and proceeding from there. The docs for both functions, and the guide pages linked from them, also seem to have some info on things.
Related
The most recent Windows Branch of caffe (https://github.com/BVLC/caffe/tree/windows) provides the option to compile caffe as a DLL.
I found it hard to find example code how to use the DLL in another C++ project as most people use the python interface, which is not a preferred option in my case. Looking at the implementation of the train() method in caffe.cpp, I tried the following to train a net:
caffe::SolverParameter solver_param;
caffe::ReadSolverParamsFromTextFileOrDie("C:\\path\\to\\solver.prototxt", &solver_param);
Caffe::set_mode(Caffe::GPU);
shared_ptr<caffe::Solver<float>>
solver(caffe::SolverRegistry<float>::CreateSolver(solver_param));
solver->Solve();
Unfortunately, the first line throws a linker error, although I added caffe.lib and specified the path to caffe.lib and caffe.dll in my project properties in VS. Accessing other caffe functions (such as set_mode) works fine.
Apart from the linker error (suggestions to solve it are appreciated!), does the code look plausible to you? Did anyone manage to use caffe functionalities in C++ and is willing to share a code snippet?
You need to link to caffeproto.lib and to libprotobuf.lib to solve dependencies error for this piece of code.
Just diving into caffe so I can't really judge your code. I am looking at this:https://medium.com/#shiyan/caffe-c-helloworld-example-with-memorydata-input-20c692a82a22 and so far found it helpful.
Good afternoon,
I'm trying to work with some C++ dll files with Matlab, and I'm trying to implement a simple test case to understand the procedure. The dll file I'm using is copied verbatim from here:
https://msdn.microsoft.com/en-us/library/ms235636.aspx
I only implement up to step 5, since my hope is to call the dll file through Matlab. After completing step 5, I copy MathLibrary.h and MathLibrary.dll to the directory I'm using for my Matlab code, and then run
[notfound,warnings]=loadlibrary('MathLibrary.dll','MathLibrary.h');
Upon running this I get the warning
>Warning: No functions found in library.
>
>In C:\Program Files\MATLAB\R2014b\toolbox\matlab\general\loadlibrary.p>loadlibrary at 431
The cell array notfound is empty and warnings is an array with warnings = MathLibrary.h
If I try using one of the functions from the dll, I execute the following code:
calllib('MathLibrary','Add',5,3)
which throws the following error
>Error using calllib
>
>Method was not found.
I've tried Googling solutions to similar problems, but have not found solutions where I've looked (at least ones I've understood). My C++ is weak, which may be hindering my understanding of the problem and solution. I'm hoping to incorporate dll files from a much larger project soon, so understanding this would be a great help. Thanks so much!
I built Qt from source (dlls) and am trying to build an application that uses the Qt dlls. I don't have a lot of experience with C++ so I'm running into what I'm sure is a very basic issue.
My builds are failing on the includes with errors like so:
Fatal error: QNetworkProxy: No such file or directory
Here is the g++ command I am using (I also used -L to add the correct folder to the lib path, but that also didn't work):
g++ -l..\..\wkqt\bin\QtCore4.dll -l..\..\wkqt\bin\QtNetwork4.dll -l..\..\wkqt\bin\QtWebKit4.dll -I..\include -Ishared -Ipdf -Ilib -Iimage -o ..\bin\wkhtmltopdf.exe pdf\*.cc lib\*.cc image\*.cc shared\*.cc
I tried in Visual Studio as well (assuming it wouldn't build, but I wanted to see if I could at least include the Qt dlls from there properly) and I am getting the same errors. Am I doing something wrong with the way I am compiling with g++? If I am linking with the Dlls properly then what is the proper way to use Qt functions from my code?
To clarify, I am not looking for how to properly use Qt. My question is: what is the proper way to use functions defined in any Dll from native C++ code? I apologize if this is a very basic question, but I'm unable to find a clear answer on Google and I don't have any experience with C++ and including third party libraries for use from C++ code.
DLLs can be used by dynamicly loading them and calling their used functions.
to call the exposed functions first define their syntax in the begining
suppose function is syntax is
BOOL MyFunction(int a,char* pszString)
then define syntax
#typedef BOOL (WINAPI *PMYFUNCTION)(int a,char* pszString)
then make object
PMYFUNCTION pfnMyFunction;
and get valid pointer by calling GetProcaddress after loadlibrarycall
HMODULE hlib= Loadlibrary("c:\\Mylib.dll");
if(hlib)
{ pfnMyFunction = (PMYFUNCTION)Getprocaddress(hlib,"MyFunction"); }
Hope this helps...
I am testing c++ source codes using the tool cantata++. I created a project, built it and encounter the following error message.
error I9282: the global scope has no "_invalid_parameter" C:\LegacyApp\VisualStudio2005\VC\include\yvals.h 167
I find this error wierd, because yvals.h is not really a file in my source codes. What does this error message imply?
You'll find that yvals.h is probably included by one of the many system header files the Microsoft compiler includes, and you are only seeing it in the error message because the Cantata++ instrumenter is finding a problem with it. My guess would be that there is some problem with the settings in either Cantata++, your Visual Studio project or a mismatch between the two meaning they are not using the same settings.
In order to help diagnose the problem it would help to know a few things about the setup you have, and the code you are building when you get the error.
As Joachim Wuttke said, I would suggest you contact the Cantata Technical Support team directly if you are still having problems with this issue. They will be able to provide you with further information to help solve the problem.
Sometimes VS autos/locals/watches break and instead of variables/values all I have is different kinds of:
CXX0029: Error: not struct pointer
CXX0033: Error: error in OMF type information
CXX0072: Error: type information missing or unknown
CXX0025: Error: operator needs class/struct/union
Rebuilding project, cleaning PDB/NCB etc doesn't solve it. What can I do?
Look at this Microsoft support note on: FIX: CXX0033 Error in OMF Type from Forward Class Declaration
Once you fix the PCH problem cited in the support note, I think all your errors will go away.
There is in fact a solution that lets you keep using precompiled headers: check out this more recent KB article and the documentation of the /Yl switch - which seems specifically tailored to this error.
Just add to the stdafx.cpp (or your own custom /Yc file) command line '/Ylxxxx', where xxxx stands for an arbitrary function name in your lib.
I recently faced symptoms identical to yours (in VS2010), and that solved it for me.
Are you trying to debug the "release" build? If so, many local variables will not exist as "debuggable" elements. You can get around this (if you must debug the release build) by debugging at the assembly level and look at the register values (vs. stack values, where auto/local would be in the debug build) and cast them appropriately in the "watch window".
Otherwise, build the Debug build and debug that build version. You'll get assertions where preconditions are not met, relevant/irrelevant stuff dumped to your output window, and more straight-forward debug single stepping.
It helped me to switch from using a program database (/ZI) to "c7 compatible" (/Z7). Switching off precompiled headers did not make a difference. Neither did rebuilding.