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#
  4. Static libraries and C#

Static libraries and C#

Scheduled Pinned Locked Moved C#
csharpc++question
3 Posts 3 Posters 1 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
    Severino
    wrote on last edited by
    #1

    Hello, I would like to know if there is some way to use a static library (a .LIB developed using C++) from C#. Any idea? Regards Severino

    H E 2 Replies Last reply
    0
    • S Severino

      Hello, I would like to know if there is some way to use a static library (a .LIB developed using C++) from C#. Any idea? Regards Severino

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Isn't possible. .NET uses assemblies that contain dependency references, assembly attributes, modules (what actually contain the code), embedded resources, and a manifest that lists it all. This does imply, however, that you could write a library and compile it as a module (only possible with the command-line compiler, csc.exe (C# compiler) using the /t:module parameter. You can then compile an assembly that contains your code plus this module. It's not quite the same thing, but the result is pretty much the same. Again, this is only available with the command-line compiler. VS.NET doesn't support this. Doing things this way will result in an assembly with two different modules. There is an article at an old hang-out that describes writing assemblies with modules in different languages. The principal is the same even if you use the same language, though: http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=466[^].

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      1 Reply Last reply
      0
      • S Severino

        Hello, I would like to know if there is some way to use a static library (a .LIB developed using C++) from C#. Any idea? Regards Severino

        E Offline
        E Offline
        Eric Gunnerson msft
        wrote on last edited by
        #3

        Two options: 1) Compile it into a DLL. 2) Write a wrapper using Managed C++.

        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