The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Cross-language development
Discuss Cross-language development in the C Programming forum on Dev Shed. Cross-language development C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

March 9th, 2003, 03:56 AM
|
|
Contributing User
|
|
Join Date: Oct 2000
Location: Back in the real world.
|
|
|
Cross-language development
I am trying to move some of my Delphi code to C for speeding it up as time (and my boss) doesnīt allow porting the whole project.
I did something similar already years ago with Turbo Pascal and C, iirc then i linked the Pascal file against the C compilerīs .o file and i could use the functions. (It was Turbo C then, maybe this is why it did work?)
Now i am using Delphi and DevCPP (gcc 2.9x). What i am trying is:
Code:
Delphi:
program pTest_C_Lib;
{$APPTYPE CONSOLE}
{$LINK libtest.o}
function Test(m:Integer):Integer; stdcall; external 'libtest.o';
begin
Test(10);
Readln;
end.
And
Code:
C:
#include <stdio.h>
int test(int max) {
int i;
for (i=0;i<max;i++) {
printf("Test %d",i);
}
return 0;
}
for testing. But when compiling, Delphi keeps telling me that the .o file is in the wrong format.
DevCPP is setup for making a static library. (i also get the libXXXXX.a file, but i have no idea how to import this to Delphi)
Am i doing something wrong or did things change so that this way is not possible anymore?
Do i really have to make a .DLL of it? (i donīt want to... but if you tell me that i have to, i will  )
Tia,
M.Hirsch
|

March 9th, 2003, 02:45 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
|
Last edited by Scorpions4ever : March 9th, 2003 at 03:04 PM.
|

March 9th, 2003, 05:03 PM
|
|
Contributing User
|
|
Join Date: Oct 2000
Location: Back in the real world.
|
|
Thank you very much.
Iīll try that tomorrow, tonight itīs already too late.
Scorpions, just in case you are interested - this is still the same project i asked for algorithms and other stuff earlier... my 3D engine. I have a hard time convincing my boss to convert to C because he also knows some basic delphi and he wants to "keep control" of the project  itīs not always logic that makes projects go the way they go... i fear it seldomly is...
iīm up to moving all speed critical functions to C (C++) now and use the STL as you suggested. Hope my collision detection routines will perform better then. If not, i still have the option of optimizing the C code which i can profile (i didnīt find a way yet to profile Delphi code...)
Next thing will be finding common data structures for C and Delphi. Iīm already looking forward to this  but i have some links, so i am confident this will be done in a few hours...
Iīll convert to gcc3 soon, after i found out about the differences (i have some urls about that, just didnīt find the time yet to read.)
Again, thanks vm.
Iīll keep you up to date about my progress...
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|