473,320 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Add "compile" option into an application

Hi guys!

I am coding a free software that will have 2 parts. Part 1. is an admin panel where a user will be able to select some options. Part 2. is a finished new application which a user can send to some other user, so a standalone application that has nothing to do with the admin panel. Now, the problem is, I don't know how to connect those two parts. I want to add an option in the admin panel that says "build" which will create a file with the native c/c++ code and then compile it into an .exe as a final product. Something like a chicken that lays an egg, if you know what I mean. Well, the egg will be the .exe file in my case. The problem is, how can I make the chicken to lay an egg an not a smelly, black thing that he lays every few hours? :)

The admin panel will be in .NET technology (C# or C++) and the .exe file will be in native c/c++ an win32 api code. I know how to write text into a file, so that's not a problem. The problem is, how to implement an auto compiler that will be able to compile that newly written file without any problems and without a user intervention? The newly generated code is 100% correct, because it compiles clean in Visual Studio, so no problem there. And I would like that the compiling of that file would be independent from the users configuration. I mean, they will still have to have windows and .net installed, but I don't want to make them to install platform sdk and .net sdk.


I AM NOT LOOKING FOR A CODE ABOUT THIS. - This is for those who skim the text so they can see that I am not looking for a code solution. What I need is some guidelines to how to do it.
First, I was thinking about packing the whole VC++ compiler into my application and then to start it in the background with console commands to the cl.exe so it can make an .exe. While this idea is accepted in some way, the problem is with packing all the libraries for the win32 api dll's and then all the files cl.exe is dependent from. I am affraid that it will take away a lot of MB's, since the win32 api dll's are a few MB's already, and I don't know if I can redistribute cl.exe and all the other libraries for free.
The second option was the C++ redistributable package. The problem is, I never worked with it, and I don't know if it supports compiling and how. Though, I have a few versions of the c++ redistributable package already installed on my system from different games and applications. If you worked with this package and if you think that that's the right solution, speak up and save me from my misery. :)
I was also looking at some free compilers, namely, borland c++, but it is ~7MB, and I don't know if I need to pack all the 7MB into my application or not, and if I do, then how should I use it?

So, as you see, I am on a road toward something, but I think I am lost and I need somebody to give me a clue which way to go now.


Can anybody help me??? :)
Aug 4 '10 #1
8 2018
balabaster
797 Expert 512MB
I think I need some clarification on exactly what the logical relationship between your control panel and your application is.

Does the control panel write the configuration used by the executable? Or does the control panel generate the executable based on some kind of configuration?

In the case of the latter, I would imagine that the control panel would be in the first sense modifying some cs or cpp files (depending on the project type) and modifying an app.config for values that can be modified by the customer. It could then push the generated project through the compiler to produce the executable which could then be shipped along with the modified app.config.

In the case of the former, you're just generating an app.config which can be shipped with a prebuilt executable.

Or am I missing your point?
Aug 4 '10 #2
Actually, the idea was that a control panel writes a custom cpp or cs file from beginning to end, and then pushes that file through a compiler to produce an .exe file which a user can ship to whoever he wants. Just the way as the code editors works ... I think. :)

With app.config, you have to ship two files, the app.config and the .exe ... or am I wrong about this, because I didn't used app.config yet, but I saw that it's an xml page which holds properties of different things. And with an app.config file, won't a user be able to manually edit it and get new things without even starting up the admin panel? Or can I include that file in my executable without any compilation from a user side and take it out if I need to change it? Because if that's possible, than my problem is solved :) But I think it's not that ease. :)

By the way, thank you for replying, balabaster! And what are you doing in the coding community? You should be working as a fortune teller, because your guessing skills are very good! I mean, you guessed right away what my problem is even though you were not sure. :)
Aug 4 '10 #3
Joseph Martell
198 Expert 128KB
You can use a CSharpCodeProvider class to give you the facilities to compile a source file a runtime. MSDN has a pretty good example of how to use it here.

I'm not sure on the legality of distributing what is essentially the VS C# compiler though. I would heavily investigate that if I were you.
Aug 4 '10 #4
balabaster
797 Expert 512MB
Okay, I have two thoughts about this:

1). If features of your application are going to be enabled/disabled via the app.config then you should look at encryption routines for the app.config. I've not used them, but there's plenty of documentation regarding this. You can encrypt sections of your app.config and your executable can still read the section without anyone else being able to.

2). You could only write the features the user should be able to access to the cs/cpp files pre compile. Your control panel could fire up a background process which uses csc.exe (The csharp compiler) to compile the code that was generated. The app.config can then be reserved strictly for user modifyable settings and you don't even have to include non-configurable application settings in the app.config but generate them as part of the control panel process into the cs/cpp files directly prior to execution.

My initial instinct might be to go with option 1, your user won't be able to modify these settings, but there's more potential they could completely break your application causing unnecessary support calls which could cost you in other ways. Consequently, I think you'd be safer to go with option 2.
Aug 4 '10 #5
balabaster
797 Expert 512MB
@jbm1313

I'm not sure he's suggesting distributing the csharp compiler. He implied the control panel that generates the executable for each of the clients is something that only he uses, only the resulting executable and configuration file would be distributed. Unless I misinterpreted.
Aug 4 '10 #6
Joseph Martell
198 Expert 128KB
There are a few lines in the question that suggest that the users are to compile programs for themselves:

"Part 1. is an admin panel where a user will be able to select some options. "

"...and I don't know if I can redistribute cl.exe and all the other libraries for free."

I may be drawing the wrong conclusion though.

What about it AlienAdy? Are you trying to create a distributable program that compiles new programs in the field, or is Part 1 going to reside on your machine alone? To extend your analogy, are you going to sell the chicken, or just the eggs?
Aug 4 '10 #7
jbm1313, I am going to sell the chicken which will lay eggs to the user who has the chicken, and he can then give the eggs to somebody else :) - just to follow up my analogy

jbm1313, if that CSharpCodeProvider really compiles a pure .cs file and the only thing he needs is a System.dll which is available on every windows computer or I think that .dll is already packed with the compiled application ... in that case, my problem is solved the way I imagined. :) Well, according to MSDN article, it does looks like a magic stick that turns every .cs file into an .exe file. I don't know if it can actually put other files in that .exe as a VS compiler would do, but that would only be a flavor on a cake, because I already have what I need.

Well ... not exactly ... because I need to compile a .cpp code to .exe. I am sorry for not telling you this before. Is there something out there that can do the job? Honestly, I am killing myself coding in c++.net because the VS support for that language is very bad. Not to mention the code page it generates ... I would rather code in c#, but I can't do it now, because I need to do a project in c++. And the cpp file that a compiler will need to turn to .exe is not c++.net but native c++ windows application.

About cl.exe: Yes, I wanted to distribute the whole package with all the libraries. I thought that it would be a bad idea because it's not free, but my next candidate is a 7MB big Borland c++ compiler, if somebody won't help me and suggest a lot smaller thing that can solve my problem.

balabaster, thank you for the good tips about the app.config! It is one of my options, if nothing else works out. I don't know if c++ native code have a support for config files, but even without that, I can create a "config" file with the basic i/o stuff, and I can even encrypt it and then uncrypt it in the application and use the data. And of course, a separate fresh copy of the config file will be in the .exe in case a user "accidentally" deletes the config file and can't start a software.
BUT ... the above option is the last solution in the solution tree. For now, I will wait and maybe some easier solution comes up.

THANK YOU ALL FOR HELPING ME!!! Since all of you guys are giving me so much new and good information, I am afraid that I can't choose the best answer, because all the answers so far are good in one way or another. I hope this won't stop you from helping me.
Aug 4 '10 #8
Plater
7,872 Expert 4TB
I am pretty sure if you have the .NET framework you have the "compiler" you need.
The WMICodeCreater software works in this way. You pick a bunch of options and it shows you all the code that it is going to compile and run
Aug 10 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Vio | last post by:
I would like to know if executing: c = compile('a=5\nprint a','<string>','exec') on a Linux box, then pickling+beaming the result on a Windows box, will give me the expecting result: >>>...
2
by: Alexander Bartzas | last post by:
I'm trying to compile route.cpp part of the NetBench Suite (UCLA) and...: > g++ packet.cpp radix.cpp route.cpp -o route There is no problem in the compilation of the code but when I try to run...
3
by: Steve Franks | last post by:
I'm using Visual Studio 2005 RC and cannot figure out how to produce a "release" build. Am I doing something wrong? I'm wondering if perhaps MS locked out the ability to produce a release build...
59
by: Jeff Bowden | last post by:
For ease of configuration and other reasons, I would like for my single-user GUI app to be able to use postgresql in-process as a library accessing a database created in the users home directory. ...
5
by: Graham Charles | last post by:
I've got several generic "library" routines that are used by many of my controls & applications (things like string manipulation, generic error handling, an "about" box generator, etc.). As I...
7
by: relient | last post by:
Question: Why can't you access a private inherited field from a base class in a derived class? I have a *theory* of how this works, of which, I'm not completely sure of but makes logical sense to...
11
by: Jan | last post by:
I'm using the CSharpCodeProvider to buils some assemblies @ runtime which are never saved as files (cp.GenerateInMemory = true;). The generated assemblies are hierachically dependent on each other...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
1
by: joecch | last post by:
If I have many jar files used to compile my java application, can I use wildcard (the example is shown below) in order to eliminating the full paths for each jar files that make the command clumsy? ...
11
by: Grzesiek | last post by:
Hi I have Main.cpp and Hello.cpp files in my Dev C++ project. Main.cpp #include "Hello.cpp"
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.