error LNK2001: unresolved external symbol _CLSID_XYS - winapi

There is one idl file defined in microsoft sdk which is not available in VS2005. I am using some of the interfaces from that IDL.
Now this works fine on VS 2010 . I want to make it compile on VS2005.
I copied the header file to my project directory. But it is giving me compilation error.
When I looked into header file , the class id is defined in it as
EXTERN_C const CLSID CLSID_Xyz.
Now it is defined as extern so it means it should be declared somewhere else in code.
So my question is just including .h file is sufficient or do I need to also include _i.c file.
Any suggestions

Once you examine that _i.c file you'll see the indeed the CLSID constants are defined there. So yes, you need to incorporate that .c file into you program - either by #including it into a .c or .cpp file or just by adding it to your project so that it compiles separately and then links into the final binary.

Related

Create CMake file from Visual Studio Project

I have finished a project developed in Visual Studio 2013 (Windows) using OpenCV. Now, my manager told me he needs the code files and the CMAKE file.
I'm reading this documents:
https://cognitivewaves.wordpress.com/cmake-and-visual-studio/
http://www.cmake.org/cmake-tutorial/
but I don't understand properly and I don't know if they are what I need...
I can explain a little bit more my project:
My project has:
main.cpp
Some .cpp created by myshelf.
Some .h created by myshelf.
I use OpenCV libraries (lib, dll, ...)
I use Vimba libraries (lib, dll, ...).
I have never worked with CMAKE files... Could anyone lead me about how create this file/s?? I'm really missed...
THANKS in advance!!!
Any help is welcome!
I have achieve create the makeFile. It's working properly in Windows. I execute cmake and from the code files it create the visual studio project properly and it works fine.
BUT when I try to execute the make command in LINUX I get errors :S:
*In function ..... error: 'infinity' des not name a type const auto....
*.... error: 'infinity' was not declared in this scope
*.... error: 'infinity' was not declared in this scope
*.... error: 'infinity' was not declared in this scope
The line where is the problem is this one:
const auto infinity = std::numeric_limits<int>::infinity();
It's a line from this project: https://github.com/soimy/munkres-opencv/tree/master/src
I think the problem is defining a infinity limit... Could anyone lead me to solve this problem?
THANKS!!!

.lib file not working in visula studio 2010 C++

My client provide me a dll file without any lib file for the project, so I create a lib file from this link.
Now after successfully generating a lib file I follow the answer of this link
Now after following these two links, I simply build my code in which I have not define any thing till now.My code build successfully, but when I build my code after calling a function from my lib file I got this:-
error C3861: 'upgStop': identifier not found
where upgStop is the function that I call.
It seems something went wrong while linking the lib file. So, guys please tell the exact solution of this problem.
'Identifier not found' is a compiler error (not linker error) which implies the header file which specifies upgStop() hasn't been #included in the file from which the function is being called.
Do you have a header file which contains the declaration/prototype of ugpStop()?
Once this is resolved, you may have linker errors isntead - as you either need to link against the dll/lib, or load it dynamically using "LoadLibrary()" (and then find functions within the loaded library by their string name.

gsoap : plug in stlvector

I'm writting hellow-world program using gsoap v 2.8 and trying to compile it in Visual Studio 2010. I want to use stl-vector functionality. But there are import errors in directive
#import "import/stlvector.h"
The error:
error C1083: Cannot open type library file: 'r:\work\vs2010\xmlme\xmlme\import\stlvector.h' Error while loading library r:\work\vs2010\xmlme\xmlme\xmlme.h
And consequence:
IntelliSense: cannot open source file "R:/Work/VS2010/XmlMe/XmlMe/Debug/stlvector.tlh" r:\work\vs2010\xmlme\xmlme\xmlme.h
Cannot figure out what Intellisense wants from me. I copied import folder from gsoap directory to my project and referencing it properly as I think.
my solution archive (link may expire)
UPDATE:
I've tried -s parameter for wsdl2h utility to exclude stl-dependency from xmlme.h file. And now I've similar error:
error C1083: Cannot open type library file: soap12.h: Error while loading library. xmlme\xmlme.h
... producing the same weird consequence:
IntelliSense: cannot open source file "XmlMe/Debug/soap12.tlh" \xmlme\xmlme.h
The thing is to not include XmlMe.h (file generated with wsdl2h.exe tool) in the project. It uses soapcpp2-compliant language (C-based but not C and that's why VS10 compiler generates error when including such a file).
Also you need to include .nsmap file, for e.g. in your main function definition file.

Where can i find the 16F877A.h?

When i run my program in MPLAB. ( Project wizard -> PIC16F877A -> Hi Tech Ansi C Compiler -> RUN )
Error [141] C:\Users\WhyWhy\Desktop\test.c; 1.22 can't open include file "16F877A.h": No such file or directory
Where can i find the header file for the 16F877A?
Chip-specific header files should not be explicitly included in HITECH-C, the documentation clearly states that. Instead, you include the compiler header, which will take care of including the chip-specific file for you:
#include <htc.h>
All you need for this to work is to configure correct chip in the project settings. The 16F877A.h file exists in the compiler directory, but including it directly will throw a warning.
C:\Program Files\HI-TECH Software\PICC\9.70\include
In my case , I have installed HITech Compiler In C:\ Program Files.
You have to know, where have you installed the files of the compiler.
This file is from the compiler, so in your case the Hi Tech you can find here:
C:\Program Files\HI‐TECH Software\PICC\\include\
Before you have found the file you have to add in the Header Files folder in the Project window on MPLAB.
And in your code you have to include it
#include <16F877A.h>

How to use CMake to generate vs project, which link to some .dll files

I use Cmake to generate VS project, based on some dll file by
if(WIN32)
MESSAGE(WINDOWS)
LINK_LIBRARIES(${***_Test_SOURCE_DIR}/../../Build/Win32/Release/***.dll)
else(WIN32)
MESSAGE(POSIX)
LINK_LIBRARIES(${***_Test_SOURCE_DIR}/../../Build/POSIX/lib***.so)
endif(WIN32)
But when I open the generated project, build and it throw out
\***.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2B0
Is anyone has ideas?
If do not use CMake, how to add external dll(not reference to some project) file in VS project. Is there any strict steps I can follow?
Thanks
On Windows, you need to link against .lib and not against a .dll, that's stupid, but Microsoft uses the same .lib extension for static and dynamic libraries. There should be ***.lib somewhere in ${***_Test_SOURCE_DIR}/../../Build/Win32/Release/.
LINK_LIBRARIES(${***_Test_SOURCE_DIR}/../../Build/Win32/Release/***.lib)
If it is not the case, you can follow this article to build a .lib from a .dll: How To Create 32-bit Import Libraries Without .OBJs or Source. Briefly (taken from Adrian Henke’s Blog), within a VS command prompt:
dumpbin /exports C:\yourpath\yourlib.dll
This will print quite a bit of text to the console. However we are only interested in the functions:
ordinal hint RVA name
1 0 00017770 jcopy_block_row
2 1 00017710 jcopy_sample_rows
3 2 000176C0 jdiv_round_up
4 3 000156D0 jinit_1pass_quantizer
5 4 00016D90 jinit_2pass_quantizer
6 5 00005750 jinit_c_coef_controller
...etc
Now copy all those function names (only the names!) and paste them into a new textfile. Name the nextfile yourlib.def and put the line “EXPORTS” at its top. My yourlib.def file looks like this:
EXPORTS
jcopy_block_row
jcopy_sample_rows
jdiv_round_up
jinit_1pass_quantizer
jinit_2pass_quantizer
jinit_c_coef_controller
...
Now from that definition file, we can finally create the .lib file. We use the “lib” tool for this, so run this command in your Visual Studio Command Prompt:
lib /def:C:\mypath\mylib.def /OUT:C:\mypath\mylib.lib

Resources