Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2007-03

using generated obj files with vs or gcc in fpc?

11 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Roozbeh GHolizadeh

So,how should i use them?
i mean i have to create a unit and do header
translation,and declare variables and function as
external?

also if that obj uses procedures like malloc or other sdtlibc funcions,does that make any problems?

regards,
roozbeh

____________________________________________________________________________________ It's here! Your new message!
Get new email alerts with the free Yahoo! Toolbar. http://tools.search.yahoo.com/toolbar/features/mail/

Reply by email

Yury Sidorov
to Roozbeh GHolizadeh

From: "Roozbeh GHolizadeh"

So,how should i use them? i mean i have to create a unit and do header translation,and declare variables and function as external?

Yes.

also if that obj uses procedures like malloc or other sdtlibc funcions,does that make any problems?

Ideally C obj files or libraries must not contain C rtl calls. Like zlib. Otherwise it is problematic to use them.

Yury Sidorov.

Reply by email

Roozbeh GHolizadeh

Well testing it with evc4,i get this error

test2.pas(5) Error: Failed reading coff file, illegal reloctype $000F while read
ing my.o

and well if it work,does .lib files work too?

____________________________________________________________________________________ Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center. http://autos.yahoo.com/green_center/

Reply by email

Yury Sidorov
to Roozbeh GHolizadeh

From: "Roozbeh GHolizadeh"

Show quoted text 5 lines
Well testing it with evc4,i get this error test2.pas(5) Error: Failed reading coff file, illegal reloctype $000F while read ing my.o

Try external linker.

and well if it work,does .lib files work too?

.lib files should work.

Yury Sidorov.

Reply by email

Roozbeh GHolizadeh

Well everything is now ok,but in my .c source i've used 'toupper' function,
now when i try to declare it in my pascal file like

function toupper(ch : integer):integer;cdecl;

still i get undefined symbol toupper error from
compiler.
i guess there is a problem in linker,ie you cant use external pascal functions in c sources.

____________________________________________________________________________________ Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center. http://autos.yahoo.com/green_center/

Reply by email

Daniël Mantione
to Roozbeh GHolizadeh

Op Sun, 11 Mar 2007, schreef Roozbeh GHolizadeh:

Show quoted text 10 lines
Well everything is now ok,but in my .c source i've used 'toupper' function, now when i try to declare it in my pascal file like function toupper(ch : integer):integer;cdecl; still i get undefined symbol toupper error from compiler. i guess there is a problem in linker,ie you cant use external pascal functions in c sources.

The problem is the name mangling. Try to declare it like:

function toupper(ch : integer):integer;cdecl;external name 'toupper';

... if the external name is 'toupper'. It might also be '_toupper'. You can check this with objdump.

Daniël

Reply by email

Roozbeh GHolizadeh
>The problem is the name mangling. Try to declare it

like:

> >function toupper(ch :
integer):integer;cdecl;external name 'toupper';
> >... if the external name is 'toupper'. It might also

be '_toupper'. You =

> >can check this with objdump. > >Dani=EBl

Well actually my problem is c object files use toupper function and i want to declare it in my pascal file. (i know it is very easy to being implemented in c..but now just for curusity.)

so declaring external is reverse of what i want to do. I also tried with _toupper.didnt work,although i
turned off underscoring of exporting function in c compiler.

also tobjdump says unknown file.i cant dump c compiler generated .obj files.

regards,
roozbeh

____________________________________________________________________________________ 8:00? 8:25? 8:40? Find a flick in no time
with the Yahoo! Search movie showtime shortcut.
http://tools.search.yahoo.com/shortcuts/#news

Reply by email

Daniël Mantione
to Roozbeh GHolizadeh

Op Sun, 11 Mar 2007, schreef Roozbeh GHolizadeh:

Show quoted text 25 lines
>>The problem is the name mangling. Try to declare it like: >> >>function toupper(ch : integer):integer;cdecl;external name 'toupper'; >> >>... if the external name is 'toupper'. It might also be '_toupper'. You = >> >>can check this with objdump. >> >>Dani=EBl Well actually my problem is c object files use toupper function and i want to declare it in my pascal file. (i know it is very easy to being implemented in c..but now just for curusity.) so declaring external is reverse of what i want to do. I also tried with _toupper.didnt work,although i turned off underscoring of exporting function in c compiler. also tobjdump says unknown file.i cant dump c compiler generated .obj files.

Ok, that can be done too, declare it like this:

function toupper(ch : integer):integer;cdecl;public;alias:'toupper';

Daniël

Reply by email

Evgeniy Ivanov
to Roozbeh GHolizadeh: like: integer):integer;cdecl;external name 'toupper'; be '_toupper'. You = Well actually…
Roozbeh GHolizadeh wrote 26 lines
>> The problem is the name mangling. Try to declare it like: >> >> function toupper(ch : integer):integer;cdecl;external name 'toupper'; >> >> ... if the external name is 'toupper'. It might also be '_toupper'. You = >> >> can check this with objdump. >> >> Dani=EBl Well actually my problem is c object files use toupper function and i want to declare it in my pascal file. (i know it is very easy to being implemented in c..but now just for curusity.) so declaring external is reverse of what i want to do. I also tried with _toupper.didnt work,although i turned off underscoring of exporting function in c compiler. also tobjdump says unknown file.i cant dump c compiler generated .obj files.

I didn't read any mails before this, but I have some experience with C obj. files (.o generated with gcc --> fpc).
I don't remember what I've been doing a half year ago (the way is not like today), but smth was with _NAME. I think it is gpc style. About "true method" you may read in
ftp://ftp.freepascal.org/pub/fpc/docs-pdf/CinFreePascal.pdf And I saw some information in fpc docs.

Best regards E.I.

Reply by email