First of all i am a beginner in visual studio so please forgive and guide me if i m going wrong in some way , i am a java and php programmer so i am not new to programming
i want to develop a application which reads fingerprint , i use this device
http://www.egistec.com/en/sensors/fingerprint-es603wb.aspx
which i think uses Windows Biometric Framework , so i tried to run the code mentioned in this page
http://msdn.microsoft.com/en-us/library/windows/desktop/ee207405(v=vs.85).aspx
this is what i did
#include "stdafx.h"
#include "Windows.h"
#include "Stdio.h"
#include "Conio.h"
#include "Winbio.h"
int _tmain(int argc, _TCHAR* argv[])
{ HRESULT CaptureSample(); }
you can find the function CaptureSample() in the second link provided above.
As you can see in the they said to link Winbio.lib, i know that its a dll in system32 , i did some research and created a Winbio.def file and Winbio.lib file,
Now my problem is i dont know how to link the lib file , i added "Winbio.lib" in properties >>LInker >> Additional Dependencies
it shows me the following error
*error LNK2019: unresolved external symbol _WinBioOpenSession#28*
infact this error appears even if i remove it from Additional Dependencies
please tell me where i am going wrong , should i place the lib file in any specific directory ? should i copy the dll somewhere ? or something else ?
Linker > General > Additional library Directoreis
put the path to the lib
Linker > Input
Put the lib name.
You can find this if you do some googling.
If everything is fine and still does not work, very probable that your lib file is not generated correctly. You can then try use dynamic loading of your dll file.
http://msdn.microsoft.com/en-us/library/ms810279.aspx
First loadLibrary is called to get a handle to your dll, then getProcAddress is called to get the pointer to the function. Cast the pointer into the target function defined in your h file. Then you'll be able to call the function.
I had the same problem. Following steps helped me on VS 2015 Community Edition
Right click on the project > Properties.
Linker > Input > then in the Addition Dependencies put winbio.lib; to front
Related
I'm having issues with getting #include to actually include libraries. The compiler software doesn't want to recognize the library.
Hi Folks! I'm a somewhat new programmer.
I'm currently trying to get a library from github to work (liblightmodbus) in the microchip studio compiler.
I've followed the instructions of adding include path
Microchip Studio, Toolchain Linking
I've downloaded the .zip and unpacked it to the debug folder within the project I'm working with. Then in the solution explorer i clicked "Show all Files" and right clicked the downloaded project and "Include in Project"
Despite this once I compile the program it returns error about
lightmodbus/lightmodbus.h: No such file or directory
and flags the lines whith
#include <lightmodbus/lightmodbus.h>
What have I missed?
Your include line uses <> brackets. This informs the pre-processor to go and search the toolchain directories, as defined by Atmel/Microchip Studio.
When including files, you can choose to use either
#include "file.c"
or
#include <file.c>
This post describes the behaviour is much more detail.
In addition, unpacking the library to the debug folder is likely to be your second problem (for the reasons described in the linked post). You should instead unpack it to directory containing the rest of your source, or a sub directory of there, and include using "".
I am developing programs for VxWorks using Tornado 2.2. I meet some problem when I try to use cout. My code is here:
#include <iostream>
using namespace std;
void main()
{
cout << "Hi" << endl;
}
The project can be compiled without error. But when I try to download the .out file to the target machine (mounted on VMware), I got the following error:
What's the problem and how to solve it?
The problem is you are missing the appropriate library in the kernel configuration. To rectify this, you will need to add the correct component to the kernel configuration.
At the least, you will need to add INCLUDE_CPLUS_IOSTREAMS, however this might also require other components, possibly one or more of INCLUDE_CPLUS, INCLUDE_CPLUS_DEMANGLER or INCLUDE_CPLUS_LANG, dependant on what is already included.
If you are using the tornado GUI to configure your kernel, you can just browse through the tree - I can't remember the exact location in Tornado, but is fairly near the top - probably under C++ Components.
If you are using the command line to make your project, you may need to edit config.h directly.
That's some old tech you got there... Check you kernel configuration for various CPLUS options - you're missing something.
I have a tool that generates additional source code on a build phase in a run script section. I would like to include resulting files of this section into compilation and linking. How it is possible to do? I know that it is possible to write clang calls in additional run script section but I am looking alternative options, since it will be too complex to keep run script section with clang and project compiler settings in sync.
Files that I am generating is a set of categories to classes currently included into the project. I do not need to worry about importing categories into the project, since all the code that generated automatically imported into generated-categories.h which is imported by default into precompiled header.
You can solve this problem by adding a file to your project that contains something like the following:
#include "generatedFile1.c"
#include "genreatedFile2.c"
And so on. Then, you just need to make this file (or build phase) depend on (or run after) the source-code generating step.
I'm not very familiar with Xcode, so I don't know specifically how you would accomplish that; hopefully someone with more specific experience can point you in the right direction on that front.
Edit: I made it work with a simple project here. Example:
main.m:
#import <Foundation/Foundation.h>
#import "generatedFile.m"
int main(int argc, const char * argv[])
{
#autoreleasepool {
// insert code here...
NSLog(#"%#", string);
}
return 0;
}
script.sh:
#!/bin/sh
echo "NSString *string = #\"Hello, World\";" > ${SYMROOT}/generatedFile.m
And then I added ${SYMROOT} in the "Header search paths" in the project settings and added a "run shell script" phase before the "compile sources" phase.
I inherited a substantial amount of code, including a visual studio project that is supposed to (as best as I can tell) build a .lib file. Visual studio says "... Generating Code... Creating Library... Creating browse information file...", and at the end, it says the build succeeded. In the release/debug folder, it has a bunch of .obj files, but it doesn't have a .lib file. What could I be missing?
Thanks!
Open the Project Properties (right-click the project in Solution Explorer, select 'Properties'). Under 'Librarian', check 'Output File' - that's where the output should go.
If this looks right, try dir /s *.lib in a suitable subdirectory for your project, to see if you can locate the output library by date and time. If you still can't find it, try a clean rebuild (right click project, select 'Rebuild').
For DLLs, a .Lib file is not created if the DLL exports nothing for external usage. I don't think this applies for static lib builds but I would make sure you are exporting something public from your library project source code.
.lib will not get generated if you miss to add prefix __declspec(dllexport) for methods.
My static library contains nothing but two template classes, so I didn't have a .cpp file. This caused Visual Studio 2015 to not output a .lib file. To solve this, I made a file huh.cpp which includes all of the headers.
I had the same problem, even though I was already using the __declspec(dllexport) function.
Your ProjectName.cpp file needs to #include "ProjectName.h". If you don't include the header file then the functions don't get exported. The DLL builds fine, no errors or warnings (at least in VS2017 15.8), but you don't get a LIB file.
Include the header and boom - LIB file is generated. A rookie mistake I'm sure, but everyone has to start learning somewhere.
If the Methods you want to export are in a class, you have to __declspec(dllexport) on the class. Otherwise no .lib will be created.
In my case (Visual Studio 2019), when #include "pch.h" was not the very first include statement in cpp, lib file was not created.
I just ran across this problem as well.
It was due to using an invalid macro in the output directory definition. In my case, it was
when it should have been
I had to blank out the full path in the second screen shot. I had an incorrect macro. I was using MsBuildProjectDir when I should have been using MsBuildProjectDirectory. The read-only text box will show the full path (eg: C:\Development\blah\blah\blah\) when the output directory is valid. If the output directory is not valid, you'll get something like the first screenshot.
In the DLL project, put __declspec(dllexport) beginnings of methods defined in .h and .cpp files.
After all, compile your dll again, so .lib file will be generated and ready for linking.
put Class Foo
{
public:
__declspec(dllexport) int GetFoo() const;
I was exporting a class from the dll but had declared the class inline in .h file. The .cpp file was there but empty. This setup was causing the .lib file to be not generated.
I moved the implementation of functions to .cpp file and now lib file is generated.
This is in VS2019.
Had the same issue here with VS2019. In my case I had built a few times with no symbols defined (i.e. cpp files were empty).
After I added symbol definitions into the cpp files I began to notice this issue (no lib file was being generated).
A simple clean via 'Rebuild all' fixed it. Perhaps if you build whilst there are no symbols defined, something gets cached somewhere that you have an empty product DLL, and you need to clean the solution to reset that cached state.
My issue was that in the projects Properties>C/C++>CommandLine, I had specfied the switch incorrectly.
That is instead of writting /D_HASHING_BUILD_DLL I had written /D_Hashing_BUILD_DLL.
Side note:
This is how I build my DLL/Lib files in Visual studio : (and my Hashing.h looks like this: )
#ifndef HASHING_H
#define HASHING_H
/* If we are we on Windows, we want a single define for it.*/
#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
#define _WIN32
#endif /* _WIN32 */
#if defined(_WIN32) && defined(_HASHING_BUILD_DLL)
/* We are building Hashing as a Win32 DLL */
#define HASHING_API __declspec(dllexport)
#elif defined(_WIN32) && defined(HASHING_DLL)
/* We are calling Hashing as a Win32 DLL */
#define HASHING_API __declspec(dllimport)
#elif defined(__GNUC__) && defined(_HASHING_BUILD_DLL)
/* We are building Hashing as a shared / dynamic library */
#define HASHING_API __attribute__((visibility("default")))
#else
/* We are building or calling HASHING as a static library */
#define HASHING_API
#endif
//your inlcudes
class HASHING_API MyClass
{
//...
};
#endif // !HASHING_H
and in the path I stated earlier, I just use the switch I defined here and there you go, the DLL is built just fine!
I'm not so familiar with C++ and I had the same issue. I thought I would share what worked for me. It appears that the import/export must come after the class statement, according to the following page.
https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4091?view=msvc-160
// Warning C4091
// No error but didn't produce a .lib file
__declspec(dllimport) class X {};
// __declspec attribute after the class or struct keyword
// applies to user defined type worked
class __declspec(dllimport) X3 {};
Sometimes when you break you head in a new project why .lib is not created - it can be some "past games" issue.
I was creating a new .dll but before I decided to use #define with __declspec(dllexport)/__declspec(dllimport) I tried to play with .def
After removing .def file it probably left some misconfiguration in the project file and it wasn't creating .lib file...
Till I decided to just remove the project completly and recreate - and walla, works perfectly!
when I create an xCode project with the 'Command Line Tool' c++ stdc++ template, i am able to include and compile opencv headers and run some code.
But i want to use OpenCV in a 'Cocoa Application' context. When created with that template, i got compile errors when I include the OpenCV headers in main.mm. (I already changed main.m to main.mm, the '//NSApplicationMain(argc, (const char **) argv);' is commented out)
One of those errors is: "Statement-expressions are allowed only inside functions"
I suppose its some kind of compiler version error, but when i compare the project build settings i cant find differences.
Do you have any ideas/expertise?
I ran into the same problem, I spent 2 days doing serious system tracing and as expected, the solution was so simple that an 8-year-old could have found it more quickly than I did.
Ready for this?
In the .mm file where you want to use OpenCV, you need to do your #include "opencv2/opencv.hpp" BEFORE any other includes. That's it! Just move it up a line and watch your problem magically disappear faster than that rug that really tied the room together.
This is for OpenCV 2.2 by the way, hence the new include file. Also if your XCode project uses a prefix header file (look in "Other Sources" for a "YourProjectName_Prefix.pch" file), then you'll need to put your #include "opencv2/opencv.hpp" there instead of in any other file.
Ian Charnas's Answer is correct, but there is one modification I would make.
This article has a more specific solution, and an explanation of why you need to do this.
http://aptogo.co.uk/2011/09/opencv-framework-for-ios/
// Add this new section BEFORE the #import statements for UIKit and Foundation
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif
Even if you rename your "main.m" to "main.mm" and moving the "#include opencv2/opencv.hpp" to the top (in the main file), the preprocessor will insert cocoa.h first because of the precompiled header files nemed something like "_Prefix.pch". To avoid such problems
- delete the #import statement or
- insert an #import statement above the cocoa.h import statement
Try adding: -lstdc++ to the "Other linker flags" in the build settings for your Cocoa app.
A cocoa application made by the Xcode templates won't link include the c++ library in it's settings by default.
add this to your .pch file
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif
dont forget to convert all of your .m files into .mm files
You'll probably find it easier to use OpenCV's C API rather than the C++ API. You can call C APIs directly from Objective C of course, so this makes life a lot easier. You just lose some of C++'s syntactic sugar, like default parameter values.