Ola, td bom com vcs?

Estou tentando linkar codigo escrito para freepascal com uma funcao em C e 
estou tendo alguns problemas, vcs podem me ajudar?

No fonte em pascal em estou definindo:

------arquivo teste.pas---------------
{$L testec.o}

program teste_linker;
uses Crt, Linux;

procedure teste_em_c; cdecl; external;

Begin
        teste_em_c;
end.
------eof(teste.pas)------------------

E no programa em C esta a funcao teste_em_c, assim:

------arquivo testec.c----------------

#include <stdio.h>

void teste_em_c()
{
        printf("Ola Mundo\n");
}

------eof(testec.c)-------------------

Existe uma explicacao sobre como fazer esse tipo de link em
http://www.freepascal.org/docs-html/prog/node6.html
mas como a linha de comando exemplo que tem lah (usando o switch -Sv) dah 
erro de opcao obsoleta, eu estou tentando compilar desta forma:

tX mauricio@main:link$ gcc -c testec.c
tX mauricio@main:link$ fpc teste.pas

Free Pascal Compiler version 1.0.4 [2001/01/22] for i386
Copyright (c) 1993-2000 by Florian Klaempfl
Target OS: Linux for i386
Compiling teste.pas
Assembling teste_linker
Linking teste
testec.o: In function `teste_em_c':
testec.o(.text+0x9): undefined reference to `printf'
teste.pas(10,4) Warning: Error while linking
Closing script ppas.sh
9 Lines compiled, 0.0 sec

Eu jah tentei tambem usar uma diretiva do FPC que teoricamente serviria pra 
linkar a lib padrao C e nao houve resultado... (se nao me engano opcao -Xc)

Outra coisa que tambem nao deu certo foi usar um arquivo que ele gera chamado 
link.res com o seguinte conteudo:

------------------------------------------------
SEARCH_DIR(/lib/)
SEARCH_DIR(/usr/lib/)
SEARCH_DIR(/usr/X11R6/lib/)
SEARCH_DIR(/usr/lib/gcc-lib/i386-slackware-linux/egcs-2.91.66/)
SEARCH_DIR(/usr/local/lib/fpc/1.0.4/units/linux/rtl/)
SEARCH_DIR(/usr/local/lib/fpc/1.0.4/units/linux/paszlib/)
SEARCH_DIR(/usr/local/lib/fpc/1.0.4/units/linux/api/)
SEARCH_DIR(/usr/local/lib/fpc/1.0.4/units/linux/fcl/)
SEARCH_DIR(/usr/local/lib/fpc/1.0.4/units/linux/)
SEARCH_DIR(/usr/local/lib/fpc/1.0.4/)
INPUT(
/usr/local/lib/fpc/1.0.4/units/linux/rtl/prt0.o
/usr/local/lib/fpc/1.0.4/units/linux/rtl/strings.o
/usr/local/lib/fpc/1.0.4/units/linux/rtl/linux.o
/usr/local/lib/fpc/1.0.4/units/linux/rtl/crt.o
/usr/local/lib/fpc/1.0.4/units/linux/rtl/syslinux.o
teste.o
testec.o
)
------------------------------------------------

eu tentei linka-lo direto com o gcc e obtive a seguinte mensagem de erro:

tX mauricio@main:link$ gcc link.res
/usr/local/lib/fpc/1.0.4/units/linux/rtl/prt0.o: In function `_start':
/usr/local/lib/fpc/1.0.4/units/linux/rtl/prt0.o(.text+0x0): multiple 
definition of `_start'
/usr/lib/crt1.o(.text+0x0): first defined here
collect2: ld returned 1 exit status

Por favor alguem tem alguma ideia de onde eu estou errando?
Alguem jah teve esse problema? Como conseguiram resolver? 
Agradeco antecipado qualquer ajuda :-)

[]'s
Mauricio

PS Desculpem pelo email meio longo... :-) Eh que fazem duas semanas que eu to 
quebrando a cabeca com esse compilador :-(

Assinantes em 13/08/2001: 2280
Mensagens recebidas desde 07/01/1999: 127646
Historico e [des]cadastramento: http://linux-br.conectiva.com.br
Assuntos administrativos e problemas com a lista: 
            mailto:[EMAIL PROTECTED]

Responder a