CXX0017error symbol not found for dllimport variables - visual-studio-2010

I have two different DLLs and via dllimport/export I am able to share some variables betweens the two dlls! My code runs, but while debugging , when I add those imported variables to the watch window, it says: CXX0017error symbol "MyVariable" not found. The other variables which are not imported are fine.
Any clue what is going wrong?
Do I need to enable something in VISUAL STUDIO? Or import some outfile from the DLL were the shared variables are declared?
Thx

Related

Immediate window VIsual studio debugging undefined

I am debugging a lot with visual code righ now and have problem with functionality called
immediate window. I used to use IntelliJ IDEA evaluation. I would like to evaluate AdjustWindowRect function with different parameters which is in
scope but when I typed in I am getting
#include <winuser.h>
unrecognized token
as implication of this I am getting for AdjustWindowRect
identifier "AdjustWindowRect" is undefined
Is even this functionality possible I mean declaring local variables and importing headers and calling functions in Visual Studio? Neither of them works for me. The only thing it works is locals variable which is defined.
Is even this functionality possible I mean declaring local variables
and importing headers and calling functions in Visual Studio?
As far as I know, immediate window will not catch variables, functions outside the current module by default which means that you cannot use it to obtain info outside the current debug page.
Since AdjustWindowRect function is from winuser.h(a extra head file), you cannot get it on immediate window. You can check this similar issue.
Or use IntelliJ IDEA from Resharper(third party extension) may realize it.
Besides, some workarounds are discussed here which you can try to check whether they do help.

How to make dbghelp to load symbols from custom sym store?

Is there any way for SymInitialize and SymFromAddr methods to automatically load symbols from a custom symbol store. I'm trying to resolve an address to a readable function name using SymFromAddr(). It seems to work fine if I have symbols for the given module stored locally, however I'd like it to automatically download them from the path given to SymInitialize, just like WinDbg does it.
I call SymInitialize like that:
SymInitialize(procHandle, "SRV*c:\\symbols*http://msdl.microsoft.com/download/symbols;http://mycustomstore.com/symbols", TRUE);
SymFromAddr returns error 487 "Attempt to access invalid address." as it can't find the symbol since it has never even attempted to download it.
Is there any way to force download them?
As it turned out dbghelp.dll needs symsrv.dll in order to load symbols. It was struggling to find it, so needed a bit of help.
I've used dbghelp logging to help track down the issue https://msdn.microsoft.com/en-us/library/ms680687.aspx
If you want to use a HTTP symbol store, you define it with
.sympath SRV*c:\mysymbols*http://example.com/symbols
To add the Microsoft symbol path, use
.symfix+ c:\microsoftsymbols
Looking at the WinDbg symbol path now gives you:
0:000> .sympath
srv*c:\mysymbols*http://example.com/symbols;SRV*c:\microsoftsymbols*http://msdl.microsoft.com/download/symbols
which tells us that your symbol path was not correct, since it didn't have the second SRV*...* part but just http://.... If you copy/paste the symbol path from your code to WinDbg, it probably wouldn't work as well.

LNK2019 Unresolved Symbol Even When The Linkage Exists

PLATFORM
Visual Studio 2010 Proffesional
MY PROBLEM
I have a solution called solution A. I have projects 'a' (static library containing internal and external header and source files) and 'b' (executable to see if 'a' functions can be used).
I intend to use static library 'a' functionality in another executable project 'c' which is in a different Solution C. What I have done is the following:
1) Added the static library folder (relative path) to the Include Directories section in my 'c' project properties (both debug and release configurations).
2) Checked the intellisense messenger to see whether or not the imports were successful.
Before I build solution C, everything was fine. However, as soon as I build it popped LNK2019 error because there is a function foo()that seemed to be unresolved. The (reported) function signatures are:
extern void foo(params);
extern void bar(void);
Just to remind the readers, foo(params) function is in static library 'a' in Solution A.
The error message I got was:
error LNK2001: unresolved external symbol _foo
error LNK2001: unresolved external symbol _bar
MY digagnosis so far
The obvious diagnosis would be that:
1) the function signature reported seem to have a mismatch with my orignal one (I checked using real man's find and replace tool in visual studio; there is no mismatch).
2) Check for any include guards that is blocking it (I have checked once again, but it doesn't have any that will cause this problem).
The one things that I need to mention is that exec. project b in Solution 'C' can use foo and bar in static library a easily. That may be because they are in the same solution and by simply adding the project directory to Include Directories in the project b properties will do the job. But when I try to use it in a different solution, it is breaking down. I did a full clean and rebuild of the solution, but no luck.
I am starting to think that it cannot find the definition in the same header file and gets confused. Although the definition is in the identically-named source file, it may still get confused.
I am struggling to find a solution to this without having a full modification. Does anyone know what to do?
I think I solved this problem by simply using "Add Reference" by right-clicking on the executable project where I was using it. However, I still had to manually import the static library project 'a' into the foreign solution C so that the referencing can be made.
I know it is not probably a good way of doing things, but it is definitely safer and I am pretty sure that it is going to work - one way or the other.

VS2010 linker error, looking for a .lib of a .dll file

I am building a Visual C++ 6.0 workspace in Visual Studio 2010, so that it'll update some dependencies
I have all the files and dll's it is looking for, it builds but then fails at linking with this error
1>LINK : fatal error LNK1181: cannot open input file '\Projects\exe\CRelease/api.lib'
I have api.dll which it needs to build, but I don't have a .lib file version of it. and even if I did (like if I somehow converted the .dll into a .lib), I wouldn't know where to place it in a directory structure
how do I "fix" this?
guidance appreciated, thank you
Normally api.dll would have an accompanying import library called api.lib which is what you need to link to. The import library is different to a statically-compiled version of api (which would also likely be called api.lib) - it's more like a list of available functions provided by the dll, and so will usually be much smaller than a corresponding static library.
If you do find or get api.lib, it doesn't really matter where it lives, as long as it can be accessed by your linker.
If you don't find the import library, you're looking at doing explicit run-time linking where api.dll is loaded and unloaded explicitly in your code, and api's exported functions are called through function pointers.

DLL Get Symbols From Its Parent (Loader)

I am porting a program to MS Windows. This program uses dynamically loaded plugins. The plugins reference symbols in the main program. I cannot even get the DLLs past the linker without all symbols being resolved. Is there a way to solve this?
(Sorry, I'd like to ask for clarification in a comment but I'm too much of a newbie to be allowed.)
When you say the plugins "reference symbols in the main program", is it about referencing functions or data? Also, what language/compiler are you using?
Assuming it's only about functions, and in C/C++: it's possible to export a function from a .EXE as if it were a DLL. Just specify __declspec(dllexport) in front of the function definition in the .EXE . When compiling the .EXE, a .LIB file should get generated, which you can then use as input when linking each plugin.

Resources