Groups | Blog | Home
all groups > visual c libraries > october 2005 >

visual c libraries : How to link a .lib file to a C++ project(managed C++, to build dll


VicVic
10/6/2005 3:32:02 PM
Hello,

I am trying to build an dll in .Net, using managed C++. But i need to use
another dll in my project. I have the xxx.dll file and xxx.lib file. But i do
not know how to set my project to link it to my project.

I know how to do that in Visual Studio 6.0 C++, in Project Settings--->Link,
add "/libpath:../../lib" under "Project Options" and add xxx.lib under
"Object/library modeules". But i do not know how to do this in .Net. I am a
newcomer in .Net

Thanks for your help!

Marcus Heege
10/7/2005 8:37:24 PM
You can do the same as in VS6: #include the DLL's header and add the import
lib to the linker's input.Once you have done that, you can call the
functions as before.

The compiler and the linker are smart enough to generate interop metadata
for all native functions you call from managed code.

Marcus Heege

[quoted text, click to view]

VicVic
10/8/2005 11:27:02 AM
Hello Marcus,

Thank you very much for your help.
I #include the xxx.h in my application's .h file, and i set the library
path, then i added the import lib in the input, but i still have link errors
each time i am tying to call the functions from xxx.dll. Please let me know
if there is any place i made mistakes.
Thanks again for your help and have a great weekend!

Vic
------------------------------
[quoted text, click to view]
Marcus Heege
10/8/2005 11:53:50 PM
I assume your problem is not related to IJW. Are you sure your header files
/ input libs would be sufficient in a native project?

If not, you first have to find the correct .lib or .obj files to add as
input sources or the corrent headers to include.

Marcus

[quoted text, click to view]

VicVic
10/11/2005 12:45:18 PM
Hi Marcus,

Thanks for your time. I followed your suggestion and checked carefully of
the project i built. I found that the .lib file was changed because of the
mistake of my old settings which wrote to xxx.lib (exported, with exactly the
same file name xxx.lib).
This made me confusing because i did succeed once, and later always have the
link errors. I created the xxx.lib file and had been trying to use the
xxx.lib that i created, not the original one i should use!
When i was trying to use the wrong xxx.lib file, it could not find and link
the functions i need to call, which caused the problem.

Now i copied the original xxx.lib file again and i can compile my project
without any error.:)

I sincerely appreciate your time and patience. Thanks a lot.

Best regards,

Vic


[quoted text, click to view]
AddThis Social Bookmark Button