Hey zusammen,
zunächst einmal solltet ihr wissen, dass ich normalerweise für Console programmiere und ich deshalb relativ wenig Ahnung C++ Builder, insbesondere von WINAPI Programmierung und Objektdateien habe.
Für ein Projekt würde ich gerne ein ursprünglich für Console geschriebenes Programm in ein C++Builder Formular bringen.
Das habe ich soweit schon hinbekommen (es lief schon!), aber jetzt meckert der Compiler immer wegen Linkerfehler:
[Linker Fehler] Unresolved external 'TForm1::' referenced from C:\PROGRAMME\BORLAND\CBUILDER6\PROJECTS\PROJECT1.O BJ
Kann mir jemand helfen, dieses Problem zu lösen? Ich bin so langsam echt am durchdrehen...
Am Kern des Programmes sollte eigentlich kein Fehler (von der ein oder anderen Stilmacke vielleicht abgesehen) sein - die Konsolenversion lief auf DevC++ einwandfrei.
Angepasst wurden lediglich die Eingabe (Button) und die Ausgabe (Edit).
Allen im Voraus ganz herzlichen Dank!
Ich hoffe ihr könnt mir helfen...
Lg Jonas
Hier ist die *.cpp:
[highlight=c++]
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
#include <cstdlib>
#include <iostream>
#include <random.h> //Importierte Header
#include <stdio.h>
#include <conio.h>
#include <unistd.h>
#include <sstream>
#include <string.h>
//---------------------------------------------------------------------------
using namespace std;
int count_switch, i; //Vars-Init
int *K, *_E, *K_neu, *E_neu, *solverNo, *T1, *T2;
string _S, Aufgabe, Loesung, TASK, RLT;
AnsiString Buffer;
//---------------------------Importfunktionen--------------------------------
void Ableitung(int a, int b)
{
K_neu[i] = b*a;
E_neu[i] = b - 1;
}
//--------------------------------------------
string Streaming(string a, int b, int b2, int c, int Typ)
{
string Saver;
stringstream sstr;
if(Typ == 0)
{
if(i == count_switch && a != "-")
{
a = "";
}
if(b != 0 && c > 1)
{
sstr << a << b << "x^" << c;
}
else if(b != 0 && c == 1)
{
sstr << a << b << "x";
}
else if(b == 0)
{
sstr << "";
}
else if(c == 0)
{
sstr << a << b;
}
else
{
sstr << "";
}
sstr >> Saver;
}
else
{
if(i == count_switch && a != "-")
{
a = "";
}
if(b != 0 && c > 1)
{
sstr << a << "(" << b << "/" << b2 << ")" << "x^" << c;
}
else if(b != 0 && c == 1)
{
sstr << a << "(" << b << "/" << b2 << ")" << "x";
}
else if(b == 0)
{
sstr << "";
}
else if(c == 0)
{
sstr << a << "(" << b << "/" << b2 << ")";
}
else
{
sstr << "";
}
sstr >> Saver;
}
return Saver;
}
//--------------------------------------------
int get_typ()
{
return (rand() % 2 + 1);
}
//--------------------------------------------
void solver()
{
int RS;
count_switch = rand() % 6 + 1;
K = new int [count_switch];
_E = new int [count_switch];
K_neu = new int [count_switch];
E_neu = new int [count_switch];
solverNo = new int [count_switch];
T1 = new int [count_switch];
T2 = new int [count_switch];
for(i=count_switch; i>=0; i--)
{
solverNo[i] = get_typ();
if(solverNo[i] == 1)
{
K[i] = rand() % 20;
_E[i] = i;
RS = rand() % 2 + 1;
switch(RS)
{
case 1: _S= "+";
break;
case 2: _S = "-";
break;
}
Ableitung(K[i],_E[i]);
TASK = TASK + Streaming(_S,K[i],0,_E[i],0);
RLT = RLT + Streaming(_S,K_neu[i],0,E_neu[i],0);
}
else
{
T1[i] = rand() % 5 + 1;
T2[i] = rand() % 12 + 2;
_E[i] = i;
RS = rand() % 2 + 1;
switch(RS)
{
case 1: _S= "+";
break;
case 2: _S = "-";
break;
}
Ableitung(T1[i],_E[i]);
TASK = TASK + Streaming(_S, T1[i], T2[i], _E[i],1);
RLT = RLT + Streaming(_S, K_neu[i], T2[i], E_neu[i],1);
}
}
}
//--------------------------------------------
bool Destructor()
{
delete K, _E, K_neu, E_neu;
return true;
}
//--------------------------------------------
String Ansiconvert(const string& myString)
{
return String(myString.c_str());
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Aufgabe_buttonClick(TObject *Sender)
{
solver();
Aufgabe->Text = "";
Aufgabe->Text = Ansiconvert(TASK);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Loesung_buttonClick(TObject *Sender)
{
Loesung->Text = "";
Loesung->Text = Ansiconvert(RLT);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ResetClick(TObject *Sender)
{
Aufgabe->Text = "";
Loesung->Text = "";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
srand(time(NULL)/* + getpid()*/);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//**************************Ende des Skripts*********************************
[/highlight]
zunächst einmal solltet ihr wissen, dass ich normalerweise für Console programmiere und ich deshalb relativ wenig Ahnung C++ Builder, insbesondere von WINAPI Programmierung und Objektdateien habe.
Für ein Projekt würde ich gerne ein ursprünglich für Console geschriebenes Programm in ein C++Builder Formular bringen.
Das habe ich soweit schon hinbekommen (es lief schon!), aber jetzt meckert der Compiler immer wegen Linkerfehler:
[Linker Fehler] Unresolved external 'TForm1::' referenced from C:\PROGRAMME\BORLAND\CBUILDER6\PROJECTS\PROJECT1.O BJ
Kann mir jemand helfen, dieses Problem zu lösen? Ich bin so langsam echt am durchdrehen...
Am Kern des Programmes sollte eigentlich kein Fehler (von der ein oder anderen Stilmacke vielleicht abgesehen) sein - die Konsolenversion lief auf DevC++ einwandfrei.
Angepasst wurden lediglich die Eingabe (Button) und die Ausgabe (Edit).
Allen im Voraus ganz herzlichen Dank!
Ich hoffe ihr könnt mir helfen...
Lg Jonas
Hier ist die *.cpp:
[highlight=c++]
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
#include <cstdlib>
#include <iostream>
#include <random.h> //Importierte Header
#include <stdio.h>
#include <conio.h>
#include <unistd.h>
#include <sstream>
#include <string.h>
//---------------------------------------------------------------------------
using namespace std;
int count_switch, i; //Vars-Init
int *K, *_E, *K_neu, *E_neu, *solverNo, *T1, *T2;
string _S, Aufgabe, Loesung, TASK, RLT;
AnsiString Buffer;
//---------------------------Importfunktionen--------------------------------
void Ableitung(int a, int b)
{
K_neu[i] = b*a;
E_neu[i] = b - 1;
}
//--------------------------------------------
string Streaming(string a, int b, int b2, int c, int Typ)
{
string Saver;
stringstream sstr;
if(Typ == 0)
{
if(i == count_switch && a != "-")
{
a = "";
}
if(b != 0 && c > 1)
{
sstr << a << b << "x^" << c;
}
else if(b != 0 && c == 1)
{
sstr << a << b << "x";
}
else if(b == 0)
{
sstr << "";
}
else if(c == 0)
{
sstr << a << b;
}
else
{
sstr << "";
}
sstr >> Saver;
}
else
{
if(i == count_switch && a != "-")
{
a = "";
}
if(b != 0 && c > 1)
{
sstr << a << "(" << b << "/" << b2 << ")" << "x^" << c;
}
else if(b != 0 && c == 1)
{
sstr << a << "(" << b << "/" << b2 << ")" << "x";
}
else if(b == 0)
{
sstr << "";
}
else if(c == 0)
{
sstr << a << "(" << b << "/" << b2 << ")";
}
else
{
sstr << "";
}
sstr >> Saver;
}
return Saver;
}
//--------------------------------------------
int get_typ()
{
return (rand() % 2 + 1);
}
//--------------------------------------------
void solver()
{
int RS;
count_switch = rand() % 6 + 1;
K = new int [count_switch];
_E = new int [count_switch];
K_neu = new int [count_switch];
E_neu = new int [count_switch];
solverNo = new int [count_switch];
T1 = new int [count_switch];
T2 = new int [count_switch];
for(i=count_switch; i>=0; i--)
{
solverNo[i] = get_typ();
if(solverNo[i] == 1)
{
K[i] = rand() % 20;
_E[i] = i;
RS = rand() % 2 + 1;
switch(RS)
{
case 1: _S= "+";
break;
case 2: _S = "-";
break;
}
Ableitung(K[i],_E[i]);
TASK = TASK + Streaming(_S,K[i],0,_E[i],0);
RLT = RLT + Streaming(_S,K_neu[i],0,E_neu[i],0);
}
else
{
T1[i] = rand() % 5 + 1;
T2[i] = rand() % 12 + 2;
_E[i] = i;
RS = rand() % 2 + 1;
switch(RS)
{
case 1: _S= "+";
break;
case 2: _S = "-";
break;
}
Ableitung(T1[i],_E[i]);
TASK = TASK + Streaming(_S, T1[i], T2[i], _E[i],1);
RLT = RLT + Streaming(_S, K_neu[i], T2[i], E_neu[i],1);
}
}
}
//--------------------------------------------
bool Destructor()
{
delete K, _E, K_neu, E_neu;
return true;
}
//--------------------------------------------
String Ansiconvert(const string& myString)
{
return String(myString.c_str());
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Aufgabe_buttonClick(TObject *Sender)
{
solver();
Aufgabe->Text = "";
Aufgabe->Text = Ansiconvert(TASK);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Loesung_buttonClick(TObject *Sender)
{
Loesung->Text = "";
Loesung->Text = Ansiconvert(RLT);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ResetClick(TObject *Sender)
{
Aufgabe->Text = "";
Loesung->Text = "";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
srand(time(NULL)/* + getpid()*/);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//**************************Ende des Skripts*********************************
[/highlight]
Comment