C++ :: Program Needs To Compile Various Source Files At Runtime
Oct 30, 2014
My program needs to compile various source files at runtime.What is the most elegant way to compile cross platform with g++ from within my program? Is there a gcc-library I can use? I know that I could use popen() to open a Unix pipe and call g++ as command line tool. But first it isn't really cross platform and second it doesn't seem elegant to me.
I want to start developing Android apps in C++, but I do not know what I could use to compile the source code into an apk. I know that C++ is probably not the best choice for Android development, but I already know it and I do not want to learn Java.
Is it possible to create a program like Robocode, a game controlled at runtime by an external source file in visual c ++? For example create a checkers game where there would be an external source file, read at runtime, which would play automatically, with artificial intelligence. You can? If yes, how?
I've recently been learning GTK (though this question is not specific to GTK), and came across a situation that I was unsure how to best handle. Essentially, I've defined several pointers in one source file, and I want to access those pointers from other source files.
The structure of my GTK programs generally follow this pattern:
- "main.c": Define the main window and run GTK main - "create_window.c": Create and arrange widget pointers in the main window - "program_functions.c": All other source code for the project (several source files in reality)
In "create_window.c", I declare and define all my widget pointers (e.g. label). If I need to modify those widgets in "program_functions.c" for any reason (say, to change the value of a label), I need access to the pointers created in "create_window.c".
My first thought was to create a global struct of pointers in "create_window.c", and extern that struct to the other source files that need access to the pointers. The thing I don't like about this approach is spreading globals across my program.
My second idea was to create access functions in "create_window.c" where the necessary pointers are statically stored. The first time I call this function (immediately after creating a widget), a static copy of that pointer is stored in the function. Each time afterwards when I call that function (from other source files), I simply use that static pointer to access the widget of interest.
I was created a dynamic library (Used win32 App) & compiled with no error.
Then i was created my main application (MFC) & paste the .h,.lib,.dll files from the source path(dll App Path) to destination path(Main App Path). If i used the below command in my app means the project working good.
Code: #include "Alg.h" #Progma Command(lib, "VTAlg.lib") & also paste the VTAlg.dll in my app path.
here Alg.h contains the some methods , In future i will edit the function like below for my client requirement but no function name & Arguments change. The changes made in inside function(Logically changed) only.
My client contains only .exe file + .dll file.
My requirement, So after change the method i will send only .dll file to my client
If i change my lib file name VTAlg2.lib instead of VTAlg1.lib (But Same Function name & Arg type)means how can i edit the code below
In general, my problem is that I've been trying to reorganize the project I and my group are working on into separate project files. Everything was working perfectly fine before, but now I'm facing the wrath of undefined reference errors when I try to call my DLL functions.
I have them declared and included in the central header file here :
Code:
/* DLL functions */ typedef void ( * t_wait )( int milliseconds, const int frames_per_seconds ); typedef clock_t ( * ft_timer )( int command, t_timer * timer_object ); /* clock_t is usually defined as long */ typedef void ( * t_SDL_errorexit )( const char * message ); typedef SDL_Surface * ( * t_load_image )( char * image_path, unsigned is_transparent );
[Code]...
Then I have them imported here :
Code: /* ******************************************************** */ /* ********* win_error( char *, bool ) ********* */ /* ******************************************************** */ /* - Displays a GUI for a windows specific error message, */ /* pass true to it to have it exit the program, pass false */ /* to have it continue */ /* ******************************************************** */ extern void win_error( char * message, bool is_exit ) { /* Note : win_error uses the Win32 Api */ /* ********************************** */ char buffer[BUFSIZ] = { 0 }; /*
[code]...
This doesn't work, as my compiler sees it that I am trying to call invalid functions, whereas I have made sure to import the functions before calling. Obviously my compiler can't tell that, and is trying to protect me from calling them.
The source files are compiled as C++, but I'm using C-style code instead of true C++ code.
Obviously I'm using Windows style DLL linking, but if the only ways to share imported functions are non-standard, only post ways that will work on as low as Windows XP.
I have tried to statically link them before, but that led to a problem that I posted a while back. Which led me to dynamically linking, which was problem-free until I separated my code into separate files.
I know it sounds strange but I've seen things that have files which contain source code (usually in something in Python or such) and how this is read on run-time?
I am currently coding a 2D game in Visual Studio 2013. All of the .png graphics are saved in an absolute directory (for example, "C:/gfx/example.png"). Although this works for testing the application on my own system, I would one day like to release it (although it won't be commercial, as I am just learning). I could put all the of the image files in a relative folder, but I do not like the idea of my graphics being out in the open like that.
Is it possible to compile these images into the application itself? I had been researching resource files on Google, but I am still not completely sure if this is what I need to be using. Even if it is, I am using the express version of VS, so I do not have access to the editor. If resource files are what I am looking for, do I have to purchase an upgraded version of Visual Studio, or can I use another editor?
I'm writing a program that needs to parse executable files. I've got an "executable" base-class, and currently an "elf" class which inherits from it for parsing ELF files, and I will add more parsers (COM, MZ, PE, a.out, MACH-O, whatever) later on.
I want the program to automatically detect which kind of executable it's loading at runtime. It should be easy because every executable format I'm aware of/plan to support starts with a magic number. But because I can't have the parsers not check the file type (what if I re-use the code?), and I don't want to check each file twice (not just for performance, but also because only the ELF parser should know that ELF files start with "x7fELF", etc.) so I've come up with a pretty lazy solution: just try to parse the file with each known parser and have them throw an exception ("exe_type_error") if they can't parse it. If that exception gets thrown, try the next parser; if not, stop.
The remaining problem is how, at runtime, my program will know what parsers are available. I don't want to hard-code it in the main function; instead, I'd like the parsers to "register" themselves as available. That way, if I decide to go down the route of adding new parsers via dynamic linking, I will only have to add an API for dynamic libraries to register their parser, without recompiling any of the main program's code. I also want to do the same thing for another key part of the program (it's a static executable optimizer; it will run a series of "tests" (e.g. "is xor eax, eax faster than mov eax, 0 on this machine?") and optimizations ("if yes, change all mov eax, 0 to xor eax, eax") and I want to load those at runtime too).
I have heard that people should implement their class member functions in files that are different from their class declaration files. But in cases there are multiple classes that are inter-related to each other, how will you review the source code ?
I'm trying to make sure my code is written in smaller modules, so my first step is to create my initialization process in and external file to load the necessary data from external sources and set up things like the content of drop down list boxes.
My first attempt failed to give me access to the combobox items add function so I moved that code back into the form1.h file:
Code: public: Form1(void) { InitializeComponent(); // //TODO: Add the constructor code here // } void AddDate(char *date, int ID) { this->comboBox1->Items->Add("line 1"); }
It compiles fine, but the call to it in my Initialize.cpp file
Code: MarketView::Form1::AddDate("abs",1); Gives error C2352: 'MarketView::Form1::AddDate' : illegal call of non-static member function
OK, so I change "void AddDate" to "static void AddDate" and now get the error that "static member functions do not have 'this' pointers" so I go back to the "MarketView::Form1::comboBox1" situation where there is no legal syntax after "Box1 to get me to Items->Add
I've been an old fashion programmer for over 47 years. It seems as is the concept of programming computers has changed from the concepts of logic to memorization of complex syntax.
There has to be a simple answer to do this other than to write thousands of lines of code in one Form1.h file. I refuse to believe that the new programming concepts will not allow you to write code in smaller more manageable modules.
What is the proper syntax for breaking up the larger file into more manageable chucks?
I am writing a program to hide files behind other files using Alternate Data Streams in Windows NTFS file systems.
The program is as follows:
Code:
#include <stdio.h> #include <stdlib.h> int main(void){ char hostfile[75], hiddenfile[75], hiddenFileName[15] ; printf("Enter the name(with extension) and path of the file whose behind you want to hide another file: "); scanf("%75s", hostfile);
[Code]...
The complier is showing error as "Extra Perimeter in call to system" but I am not getting where?
I am trying to make a simple program for encrypting a char* with the XOR operator. The code compiles and links perfectly, but I get an Access violation runtime error:
#include <iostream> #include <cstdlib> #include <cstdio> #include <string> #include <fstream> using namespace std; int main(int argc, char** argv) {
I am currently learning C and im in the middle of completing my assignment. It has to calculate parking whilst account for a few values here is the assignment sheet for specifics. Design Specifications Write, compile and test a C program with appropriate use..It's practically error less yet when i compile it doesn't come up with what i need.
I hate vague errors where I don't even know where to start looking for an error. Error happens immediately and it says "Unhandled exception at 0x5981c9c7 (msvcr100d.dll) in experiment.exe: 0xC0000005: Access violation reading location 0xabababab."