Autor Beitrag
ub60
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 765
Erhaltene Danke: 130



BeitragVerfasst: So 02.11.08 17:35 
Hallo Leute,

gibt es eine Möglichkeit, mehrere vorhandene OBJ-Dateien in eine Ressourcendatei auszulagern o.ä.?

Mein Problem: Viele Units (z.B. die PNG-Library) liefern mehrere OBJ-Dateien mit (10 Stück bei der PNG-Lib), die man dann immer im aktuellen (oder einem anderen) Ordner bereit stellen müssen. Ich würde gerne diese (vielen) OBJ-Dateien in eine RES-Datei speichern oder sie zur Laufzeit aus Daten-Zeilen einer Unit erzeugen (statt RES).

Geht das und wenn ja, wie steuert man das an, statt {$L datei.obj}?

ub60
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 02.11.08 18:09 
Du musst hier unterscheiden, ob die OBJ-Files Code bereitstellen ($L) oder ob sie Daten bereitstellen (Ressource).

Wenn ersteres, dann Compiliert Delphi die OBJ-Files in deine EXE direkt ein und du brauchst diese später nicht weitergeben.

Bei zweiterem Fall musst Du mal in die entsprechenden Units schauen, wie die das Lesen dieser OBJ-Files realisieren.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
ub60 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 765
Erhaltene Danke: 130



BeitragVerfasst: So 02.11.08 19:00 
Wie oben bereits geschrieben werden die OBJ-Dateien mit
{$L datei.obj} eingebunden.
Ich weiß auch, dass sie mit compiliert werden und nicht weitergegeben werden müssen.
Was mich interessiert, ist eine Möglichkeit, alle OBJ-Dateien irgendwie in eine Datei einzubinden, also z.B. in eine RES oder auch so etwa in der Art:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
asm
  DB      hier ein Byte aus der OBJ
  DB      hier wieder ein Byte aus der OBJ
  ...

ub60
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 02.11.08 20:17 
Du könntest versuchen, aus allen OBJ-Files eine zu machen (objcopy) und dann nur eine Unit bauen, die alle von der OBJ bereitgestellten Daten zur Verfügung stellt ... Das ist aber eher kontraproduktiv ...

Ansonsten kannst Du eine OBJ-File ganz normal, wie jede andere Binärdatei auch, in eine RES-File verpacken und dann mit einem TResourceStream wieder auslesen in deiner App.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
ub60 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 765
Erhaltene Danke: 130



BeitragVerfasst: Mo 03.11.08 16:20 
Mein Weg bis jetzt:
1. RC-Datei schreiben (OBJ.RC):
ausblenden Quelltext
1:
OBJ1 RCDATA obj1.obj					

2. RES-Datei erzeugen:
ausblenden Quelltext
1:
BRCC32 OBJ.RC					

3. RES-Datei einbinden:
ausblenden Quelltext
1:
{$R obj.res}					

Aber wie schreibe ich jetzt die Zeile um, die vorher
function ErstesObjekt(Irgendwas): Integer;  external;
hieß?
Denn external ist es ja jetzt nicht mehr.
Beim TResourceStream habe ich keine so richtig sinnvolle Methode gefunden.

ub60
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 03.11.08 20:26 
Das geht nicht, sei denn Du würdest die OBJ-File in eine DLL compilieren und diese DLL dann in deine RES-File integrieren. Das lohnt aber den Aufwand nicht, da du dann für deine DLL sowohl eine Export- als auch eine Import-Unit schreiben müsstest, was doch erheblichen Aufwand macht, da die Import-Unit dynamisch sein müsste.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
ub60 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 765
Erhaltene Danke: 130



BeitragVerfasst: Mo 03.11.08 20:49 
Das klingt doch nach etwas zu viel Aufwand. Also werd ich mir die Sache wohl verkneifen :(

ub60

PS: Jemand noch ne Idee zu meinem "ASM-Vorschlag"?
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 03.11.08 21:35 
user profile iconub60 hat folgendes geschrieben Zum zitierten Posting springen:
PS: Jemand noch ne Idee zu meinem "ASM-Vorschlag"?

Der ist undiskutabel, sonst hätt ich dazu schon was gesagt :mrgreen:

Nene, würde theoretisch funktionieren, ist aber zu viel Handarbeit notwendig und du müsstest zu viel Aufwand treiben, diese OBJ-File mit samt ihrer Deklaration in Delphi-Syntax (automatisiert) zu übersetzen. Lohnt sich einfach nicht.

P.S.: Du kannst aber relative Pfade für $L verwenden ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
ub60 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 765
Erhaltene Danke: 130



BeitragVerfasst: Mo 03.11.08 22:04 
OK, ich gebs auf.
Problem zwar nicht gelöst, aber abgeschlossen.

ub60