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.
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!
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++.
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!
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.
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!
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
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.
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks