[try Beta version]
Not logged in

 
How to compile a C++ code through another C++ code

Nov 26, 2011 at 5:13pm
Hi,
i want to compile a .cpp file(suppose Test.cpp) living in an other C++ file (Pro.cpp), mean i want to compile Test.cpp indirectly. how i can do so in windows?
Last edited on Nov 26, 2011 at 5:16pm
Nov 26, 2011 at 5:17pm
i want to compile a .cpp file(suppose Test.cpp) living in an other C++ file (Pro.cpp)

What does it mean for a text file to "live inside" another text file?
Nov 26, 2011 at 5:27pm
i mean, how i can i compile a c++ file using another c++ file ?
Nov 26, 2011 at 5:29pm
you can use it
#include<windows.h>
int main()
{
system("gcc test.cpp");
return 0;
}
Nov 26, 2011 at 5:37pm
hmm, but it doesn't work...
Last edited on Nov 26, 2011 at 5:37pm
Nov 26, 2011 at 5:38pm
how i can i compile a c++ file using another c++ file ?


You can't. C++ files don't compile things. A C++ file is plain text.
Last edited on Nov 26, 2011 at 5:39pm
Nov 26, 2011 at 6:13pm
is their any other way to compile it indirectly ?
Nov 26, 2011 at 6:31pm
You could use a makefile.
Nov 26, 2011 at 7:58pm
i don't know the syntax, would you guide me ?
Nov 26, 2011 at 8:02pm
I think you should just compile it directly.
Nov 26, 2011 at 8:07pm
search for make file tutorial . that will compile what ever file you would like to complile
Nov 26, 2011 at 9:05pm
closed account (236Rko23)
u mean to compile a piece of code , that is inside another c++ file as a byte/uint8_t array?
if thats the case then you should first convert the file to a uint8_t array, and embed it in the source file (as when embeding images in teh binary), then write it to the disk and run the compiller.
but you would need Pro.cpp compiled first, and when you run it, it would dump the file from itself to the disk and then run the compiler on it.

if u could give a code example of what u want to do it would be a lot easier as the description u gave is a bit hard to understand
Topic archived. No new replies allowed.