Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. VS8: how to link C static library in Windows Forms

VS8: how to link C static library in Windows Forms

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialcsharpc++dotnetvisual-studio
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sakthii
    wrote on last edited by
    #1

    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.

    S 1 Reply Last reply
    0
    • S sakthii

      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.

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      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.

      S 1 Reply Last reply
      0
      • S Stuart Dootson

        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.

        S Offline
        S Offline
        sakthii
        wrote on last edited by
        #3

        Thanks for your reply. I will try.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups