Closed Thread
Results 1 to 10 of 10

Thread: C# Compiler - Daft question.

  1. #1
    Join Date
    Oct 2007
    Posts
    538
    Rep Power
    21

    C# Compiler - Daft question.

    Does anyone know how to compile C# classes independently and then statically link them together?

    The documentation seems to skip this entirely or at least does the standard MS trick of burying the relevant details in obscure corners or under a metric tonne of irrelevancies. All the tutorials I see basically devolve into rebuilding the entire project every time 'csc my-very-long-list-of-files'. I can't honestly believe that this is considered a sane way to work.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Oct 2008
    Posts
    4,060
    Blog Entries
    6
    Rep Power
    44

    Re: C# Compiler - Daft question.

    I don't believe you can do static linking with Microsoft's C# compiler, and they probably didn't provide that functionality since the whole point of .NET is to have the libraries there separately. However, I think, but don't quote me on this, that Mono is able to do static linking with the whole runtime.
    Interested in participating in community events?
    Want to harness your programming skill and turn it into absolute prowess?
    Come join our programming events!

  4. #3
    Join Date
    Oct 2007
    Posts
    538
    Rep Power
    21

    Re: C# Compiler - Daft question.

    What I meant was compiling n classes separately and then linking them into a single assembly. As far as I have been told elsewhere this isn't possible. That you can get some sort of emulation but it actually turns out slower than compiling the whole thing each time. I suppose with so much done at run time the compilation step for C# would be simpler than that for C++.

  5. #4
    Join Date
    Oct 2008
    Posts
    4,060
    Blog Entries
    6
    Rep Power
    44

    Re: C# Compiler - Daft question.

    Are you asking whether you could, say, make an assembly that has, for instance, classes that you use the most, that you could compile but still use in your program? If I'm right about what your talking about, you would compile them into a DLL file, and reference that DLL file. I'm not sure, but I think to do that you add /references:dllfilename.dll or something similar to the command line.
    Interested in participating in community events?
    Want to harness your programming skill and turn it into absolute prowess?
    Come join our programming events!

  6. #5
    Join Date
    Oct 2007
    Posts
    538
    Rep Power
    21

    Re: C# Compiler - Daft question.

    Not I want to compile the classes separately but then dump them all into one file. I.E. I should be able to delete the files that contained the classes after linking since it will not be stored within the assembly.

  7. #6
    Join Date
    Oct 2008
    Posts
    4,060
    Blog Entries
    6
    Rep Power
    44

    Re: C# Compiler - Daft question.

    I'm still not sure what it is your trying to do. Maybe you could show an example of it being done with another language and compiler and I could see what it is you are attempting to do.
    Interested in participating in community events?
    Want to harness your programming skill and turn it into absolute prowess?
    Come join our programming events!

  8. #7
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    100

    Re: C# Compiler - Daft question.

    Do you want to integrate the classes into the application and each time you run the application they will be extracted?

    I can't really understand

  9. #8
    Join Date
    Oct 2007
    Posts
    538
    Rep Power
    21

    Re: C# Compiler - Daft question.

    In c++ or c you can do the following

    g++ -c file1.cpp -o file1.o
    g++ -c file2.cpp -o file2.o

    Then you can combine them

    g++ file1.o file2.o -o main

    If you then delete the *.o files main will still work because the object files have been combined into main. In C# you can build modules but it doesn't seem possible to bundle them into a combined assembly, when you delete them any assembly that used them breaks.

  10. #9
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    100

    Re: C# Compiler - Daft question.

    When you say modules you mean? Classes?

  11. #10
    Join Date
    Oct 2007
    Posts
    538
    Rep Power
    21

    Re: C# Compiler - Daft question.

    No the C# compiler allows you to build source files into modules via /target:module. You can then link to a module via /addmodule. However the modules are not merged into the final assembly, merely dynamically linked. They essentially work no differently to /target:library.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. What is your fav compiler ?
    By genux in forum C and C++
    Replies: 9
    Last Post: 04-14-2010, 10:52 AM
  2. quickie question for anyone- using Dev-C++ compiler..
    By proeliumfessus in forum C and C++
    Replies: 7
    Last Post: 05-26-2009, 03:23 PM
  3. Replies: 6
    Last Post: 05-23-2008, 08:00 AM
  4. Best C/C++ Compiler?
    By bbalegere in forum C and C++
    Replies: 9
    Last Post: 02-27-2007, 01:29 PM
  5. C++ Compiler question
    By skilletsteve in forum C and C++
    Replies: 4
    Last Post: 09-28-2006, 05:39 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts