Ok,maybe my question is strange but i have to ask.I'm developing application in C# which generates C code and i need to use some C compiler to compile it.Can i use Dev-C++ for that?As far as i know i must pass some parameters which shows the path for the source files or something like that when i'm opening Dev-C++ from my application ...So,how this can be achieved?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would not open Dev-C++ from your application, but rather drive teh compiler directly from your application. Dev-C++ is merely an IDE not a compiler. It comes with a compiler (as an option) - MinGW/GCC. This, like all compilers is a command line tool. The IDE merely drives it and hides the command line stuff from you.
You can use Dev-C++'s MinGW/GCC installation from the command line. For convenience it is a good idea to add c:\dev-cpp\bin to your PATH environment variable. You could also use the official MinGW installation without Dev-C++ (www.mingw.org). Since you are using C# you might prefer also to use Microsoft C++, that too has a command line interface (for that matter so does C#) - you don't have to use Visual Studio.
For example, using MinGW/GCC, the command line to build a single source executable is:
gcc hello.c -o hello.exe
which creates hello.exe from hello.c
If you have multiple modules you can use GCC to compile and link them directly:
gcc main.c hello_fn.c -o newhello.exe
Note that you can also compile each file separately and then invoke the linker (ld.exe) on its own, or even generate a makefile and use make to manage teh build (as Dev-C++ does).
You can do something very similar with Microsoft's C++ compiler http://msdn.microsoft.com/en-us/library/ms235639(VS.80).aspx . It too will use C compilation is you use the .c extension - but C code that compiles as C++ is also generally better C code because C++ uses stronger type checking, so you might use C++ compilation in any case.
Perhaps a better idea is to have your C# application generate C# code. This is because in order to be able to run your application, you must have the .NET framework installed, and the .NET framework includes the C# compiler (command line), so any one who can run your application can by definition build the generated code because they already have the compiler installed (even if they don't know it!). This makes deployment and configuration of your application far simpler because the end user does not neet a separate compiler installation. http://msdn.microsoft.com/en-us/library/ms379563(VS.80).aspx
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you are compiling a single file, if you name it something.c, it will be compiled as a C file. If you are compiling a project, there is a switch in your project options that tells the compiler to compile your project as a C++ project, uncheck it. (I don't have Dev on this machine, so I can't give you specific directions, but I am sure you can find it in the project options)
Note that most valid C code will in fact compile under a C++ compiler.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Uuuh what?Please read my question carefully.I need to do it from an application written in some .NET language(in my case is C#),i.e. opening Dev-C++(programmatically) and passing some parameter that shows the path to the source file(s) and then somehow to force Dev-C++ to compile those files.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yeah,this is what i need.I know Dev-C++ is an IDE,not the actual compiler,but i didn't explained very well what i'm trying to achieve.My mistake.And i don't think i'm rude.What's wrong with the "uuuh what"?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you go with the MinGW stand-alone route that Clifford referred to, you might also want to look into MSYS to provide additional build tool support, which might be useful to you at some point.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, but I gave you three suggestions. I'd be interested in which you went with and why. You are not obliged, I'd just be interested.
Note I gave you the basics of command line compiling. If you need specific options or third-party libraries refer to the GNU GCC/binutils documentation (binutils includes the linker and thus its documentation).
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I will use the first option - using the MinGW/GCC compiler.Why?Well,this is what i need.I don't need to compile C++ code,so i wont use the second option.And the third option...i'm developing this application for my own use and as i said i need to compile C code,not C++ or C#.
Wayne ok sorry,maybe i was rude.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So you are going to use Dev's download of MinGW/GCC from the command line?
Keep in mind that the version of GCC and associated tools that comes with Dev-C++ is somewhat old (reflective of the last release of Dev), you can get newer versions with a download of straight MinGW. If you know where to look, you can even get GCC-4.2 or GCC-4.3 - again, if you find yourself needing something like that - if for example you are wanting to use something like GOMP.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok,maybe my question is strange but i have to ask.I'm developing application in C# which generates C code and i need to use some C compiler to compile it.Can i use Dev-C++ for that?As far as i know i must pass some parameters which shows the path for the source files or something like that when i'm opening Dev-C++ from my application ...So,how this can be achieved?
I would not open Dev-C++ from your application, but rather drive teh compiler directly from your application. Dev-C++ is merely an IDE not a compiler. It comes with a compiler (as an option) - MinGW/GCC. This, like all compilers is a command line tool. The IDE merely drives it and hides the command line stuff from you.
You can use Dev-C++'s MinGW/GCC installation from the command line. For convenience it is a good idea to add c:\dev-cpp\bin to your PATH environment variable. You could also use the official MinGW installation without Dev-C++ (www.mingw.org). Since you are using C# you might prefer also to use Microsoft C++, that too has a command line interface (for that matter so does C#) - you don't have to use Visual Studio.
For example, using MinGW/GCC, the command line to build a single source executable is:
gcc hello.c -o hello.exe
which creates hello.exe from hello.c
If you have multiple modules you can use GCC to compile and link them directly:
gcc main.c hello_fn.c -o newhello.exe
Note that you can also compile each file separately and then invoke the linker (ld.exe) on its own, or even generate a makefile and use make to manage teh build (as Dev-C++ does).
You can do something very similar with Microsoft's C++ compiler http://msdn.microsoft.com/en-us/library/ms235639(VS.80).aspx . It too will use C compilation is you use the .c extension - but C code that compiles as C++ is also generally better C code because C++ uses stronger type checking, so you might use C++ compilation in any case.
Perhaps a better idea is to have your C# application generate C# code. This is because in order to be able to run your application, you must have the .NET framework installed, and the .NET framework includes the C# compiler (command line), so any one who can run your application can by definition build the generated code because they already have the compiler installed (even if they don't know it!). This makes deployment and configuration of your application far simpler because the end user does not neet a separate compiler installation. http://msdn.microsoft.com/en-us/library/ms379563(VS.80).aspx
Clifford
> I don't need to compile C++ code,so i wont use the second option
That makes no difference. Both VC++ and GCC support both C and C++ compilation. In fact most C++ compilers are also C compilers.
Clifford
If you are compiling a single file, if you name it something.c, it will be compiled as a C file. If you are compiling a project, there is a switch in your project options that tells the compiler to compile your project as a C++ project, uncheck it. (I don't have Dev on this machine, so I can't give you specific directions, but I am sure you can find it in the project options)
Note that most valid C code will in fact compile under a C++ compiler.
Wayne
Uuuh what?Please read my question carefully.I need to do it from an application written in some .NET language(in my case is C#),i.e. opening Dev-C++(programmatically) and passing some parameter that shows the path to the source file(s) and then somehow to force Dev-C++ to compile those files.
> Uuuh what?Please read my question carefully.
I wouldn't get short with those most likely to be able to help you if I were you. Misunderstanding should not be rebuked with plain rudeness.
Yeah,this is what i need.I know Dev-C++ is an IDE,not the actual compiler,but i didn't explained very well what i'm trying to achieve.My mistake.And i don't think i'm rude.What's wrong with the "uuuh what"?
"but i didn't explained very well what i'm trying to achieve"
Yet your reply accused me of not reading your question well. That was rude.
Wayne
If you go with the MinGW stand-alone route that Clifford referred to, you might also want to look into MSYS to provide additional build tool support, which might be useful to you at some point.
Wayne
> Yeah,this is what i need
Ok, but I gave you three suggestions. I'd be interested in which you went with and why. You are not obliged, I'd just be interested.
Note I gave you the basics of command line compiling. If you need specific options or third-party libraries refer to the GNU GCC/binutils documentation (binutils includes the linker and thus its documentation).
Clifford
I will use the first option - using the MinGW/GCC compiler.Why?Well,this is what i need.I don't need to compile C++ code,so i wont use the second option.And the third option...i'm developing this application for my own use and as i said i need to compile C code,not C++ or C#.
Wayne ok sorry,maybe i was rude.
So you are going to use Dev's download of MinGW/GCC from the command line?
Keep in mind that the version of GCC and associated tools that comes with Dev-C++ is somewhat old (reflective of the last release of Dev), you can get newer versions with a download of straight MinGW. If you know where to look, you can even get GCC-4.2 or GCC-4.3 - again, if you find yourself needing something like that - if for example you are wanting to use something like GOMP.
Wayne