VS8: how to link C static library in Windows Forms
-
I am using Visual Studio 8. I created two win32 empty project and created C "Mylib.c" "MyWrapperlib.c" file to get static library Mylib.lib and MyWrapperlib.lib. I created another win32 empty project and when i link the static library "MyWrapperlib.lib" (with Mylib.lib and MyWrapperlib.lib in library path) with simple C code "TestApp.C" with main(), it is working fine. I have used windows.h in "Mylib.c" and "MyWrapperlib.c" for FILE operations. I want to have a GUI application, so I created NewProject->CLR->Windows Forms Application (MyUIApp.Cpp). When i used MyWrapperlib.lib, it gave linking error. so I created DLL for MyWrapperlib.c by using #define dllexport __declspec(dllexport) enclosing with extern C When i use MyWrapper.dll in MyUIApp.Cpp, it is giving below error "fatal error LNK1107: invalid or corrupt file: cannot read at 0x2B0" Can some guide me how to create 'C' lib/dll and use it with GUI application.
-
I am using Visual Studio 8. I created two win32 empty project and created C "Mylib.c" "MyWrapperlib.c" file to get static library Mylib.lib and MyWrapperlib.lib. I created another win32 empty project and when i link the static library "MyWrapperlib.lib" (with Mylib.lib and MyWrapperlib.lib in library path) with simple C code "TestApp.C" with main(), it is working fine. I have used windows.h in "Mylib.c" and "MyWrapperlib.c" for FILE operations. I want to have a GUI application, so I created NewProject->CLR->Windows Forms Application (MyUIApp.Cpp). When i used MyWrapperlib.lib, it gave linking error. so I created DLL for MyWrapperlib.c by using #define dllexport __declspec(dllexport) enclosing with extern C When i use MyWrapper.dll in MyUIApp.Cpp, it is giving below error "fatal error LNK1107: invalid or corrupt file: cannot read at 0x2B0" Can some guide me how to create 'C' lib/dll and use it with GUI application.
sakthii wrote:
I want to have a GUI application, so I created NewProject->CLR->Windows Forms Application (MyUIApp.Cpp).
Should have used MFC, then you'd have native code throughout, so you could have used your static library. However - you can link C++/CLR modules against your static library (meaning you don't need the DLL). In your project proerties, change the "Common Language Runtime support" option to "Common Language Runtime Support (/clr). Worked for me, anyway.
-
sakthii wrote:
I want to have a GUI application, so I created NewProject->CLR->Windows Forms Application (MyUIApp.Cpp).
Should have used MFC, then you'd have native code throughout, so you could have used your static library. However - you can link C++/CLR modules against your static library (meaning you don't need the DLL). In your project proerties, change the "Common Language Runtime support" option to "Common Language Runtime Support (/clr). Worked for me, anyway.