Im busy to create a dll (in Windows, with VS 6.0).
That dll have some functions who call some other functions from a external dll.
In the main dll I have added :
include "external_lib.h"
But when I try to compile get this error:
main_lib.obj : error LNK2001: unresolved external symbol
_My_external_Function
It seems that the main dll do not find the external dll...
In external_lib.h there is no assign to "C:\myprg\external_lib.dll"
How can i assign the name of that dll ?
I understand that, if the directory is not defined, it search into "C:\windows\system", but how to declare the name of the external dll ? ( here "external_lib.dll" )
Must i declare it in main_lib.h or external_lib.h ?
After a big fight, I get it.
First I had to find the code of the external dll and recompile it to have his lib file ( all the tools like dll2lib do not work ).
Then include in link-import that external.lib, compile and it works.
Im happy.
Related
I have three projects - one exe, one dll and one lib. exe depends on dll which depends on lib. I have XAML user control defined in a namespace in lib and that control is used in the MainPage.xaml in exe project. But the exe project gives compilation error <namespace name>: is not a member of 'winrt' in XamlTypeInfo.g.cpp file. Not sure what I am missing.
In XamlTypeInfo.g.cpp TypeInfos array is defined in which there is an entry for this control type. Please let me know if details are needed. But do not know what all I should share so not sharing it right away.
I am currently trying to add control to a Power Analyzer in an excel tool. The company provides USB drivers and the appropriate modules and DLLs. I added the DLLs to the System32 folder to ensure they were read in the path. After importing the modules and trying to run the program, I get the error "File Not Found". I then tried to hard code the location of the DLL and I received the same error.
I've looked around the internet and the only issue I could find was possibly a dependency missing from the DLL. An example of the line I'm trying to use is:
Declare Function TmSend Lib "tmctl.dll" (ByVal id As Long, ByVal msg As String) As Long
This line is apart of the module provided by the manufacturer. Is there something I'm missing to get this to work? I want to make sure before I contact the manufacturer.
EDIT:
It appears that the manufacturer uploaded a corrupt DLL causing the issue to arise. When checking the file with Dependency Walker, it failed to even read the DLL.
I see from your question that you've tried all the normal things (making sure the dll is on your path &c.)
You now need to examine the dll carefully. Download this: http://www.dependencywalker.com/
Then use it to open your dll. All the missing dependent dlls will be clearly displayed. Put those on your path too and you're done.
(To clear up some confusion: you will not need to register this dll or add a reference to it.)
I was trying to use the sha2.c file from polarssl at this link,
https://polarssl.org/sha-256-source-code
I am actually quite a newbie to this, but I was able to get this on Eclipse and when I tried to build it, it gives the error
c:/mingw/x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text+0x3d): undefined reference to `WinMain'
do I have to pass some kind of data in the arguments? how can I find out how to use it?
The problem is not in the source file you downloaded, but the fact that you need to make 'an application'. Eclipse cannot compile 'just some functionality' unless you instruct it to build a library. You will have to provide a WinMain / main function so that Windows knows what to do when you start the application.
That is what the compiler is complaining about, there is no main() functions it can compile into the application!
Easiest way to start is to start a Generic C Application in Eclipse and then add this sha2 source file and header to that project. The Generic C application project already has a main function you can work from..
I tried to use __declspec(dllexport) to export functions in my DLL, but it doesn't work.
When I run GetProcAddress in main app, it always shows "The specified module could not be found".
But if I export my functions by .def file. It works very well.
Can you help me to solve this problem. I want to use __declspec(dllexport) instead of the .def file.
Thank you very much.
(I'm using Visual C++ 2005, MFC)
The specified module could not be found
That's the wrong error message, you will only get that when LoadLibrary fails. Typically because you are using the wrong file name. GetProcAddress() fails with error 127, "The specified procedure could not be found".
Assuming it is actually the exported function name, you do not have a lot of options to rename the function with __declspec(dllexport). You only have extern "C" to suppress C++ name mangling. The exported name is still going to have a underscore before its name, #n after its name if it was declared __stdcall. Exporting completely undecorated is only possible in 64-bit code or by using a .def file.
Use dumpbin.exe /exports on the DLL to see actual names. You'll get a better dump if you delete the .pdb file first. Depends.exe is fine too.
I expect you're not looking for the right name when using GetProcAddress. Have you used dumpbin or Dependency Walker to verify the name of the exported function yet?
I was add to my program reference to dll and it's work good.
Declare Function adc11_get_driver_version Lib "C:\example.dll" () As Integer
but I want to write the specific location of the dll from file(config file) and replace the "C:\example.dll" by string
how can I do this?
thanks
Saar
I think you need to do dynamic PInvoke. One way to do this is using the LoadLibrary function to load the library before .Net tries to find it. You can find some sample code here.
If you leave out the location completely, it will load it based on the current directory of the application. If it's not there, then it looks in the PATH.
If you want to do something more complex, then you need to write the LoadLibrary and GetProcAddress calls yourself in your own proxy.
Some guidance here:
http://www.codeproject.com/KB/cs/dyninvok.aspx