Sign in Join

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

Mailing lists / fpc-pascal / 2000-12

Need help on LinkLib

7 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Andre Wohnig

Hi all!

I want to Link a library to my program. I tried "{LinkLib gpiblib.a}". In this library it exists a function "int ibfind(char *name)". Therefor i insert the following line into my interface section in my unit: "Function ibfind(name : PChar) : LongInt; cdecl; external". I tried to use it with "nr := ibfind(device);" where nr is a LongInt and device is PChar. When i try to run the program i get the following error: "Error: undefined reference to `ibfind' "

What i am doing wrong? Could somebody help me?

I will be verry thankfull for every help i can get.

tia
Andre´

Thiesen | André Wohnig hardware- & software- design GmbH | Im Tiegel 9 | www.thiesen.com 36367 Wartenberg | tel. +49 (0) 6641 979-142 fax -299

Reply by email

Matt Emson

If it were Delphi code, I'd say you were missing the reference to the library you were calling ibfind from (but then again I could be wrong)

You'd need to find something in Free Pascal that does the same as:

procedure DoSomething; external 'MYLIB.DLL';
{this is straight out of Delphi's help, so it's not linux geared}

Maybe (I am guessing here, so don't assume I know what I'm talking about)

Function ibfind(name : PChar) : LongInt; cdecl; external "gpiblib.a";
// or maybe
//Function ibfind(name : PChar) : LongInt; cdecl; external "gpiblib";

That would work in Object Pascal anyway.

Hope that helps,

Matt

Show quoted text 9 lines
I want to Link a library to my program. I tried "{LinkLib gpiblib.a}". In this library it exists a function "int ibfind(char *name)". Therefor i insert the following line into my interface section in my unit: "Function ibfind(name : PChar) : LongInt; cdecl; external". I tried to use it with "nr := ibfind(device);" where nr is a LongInt and device is PChar. When i try to run the program i get the following error: "Error: undefined reference to `ibfind' " What i am doing wrong? Could somebody help me?

Reply by email

Peter Vreman
Show quoted text 7 lines
Hi all! I want to Link a library to my program. I tried "{LinkLib gpiblib.a}". In this library it exists a function "int ibfind(char *name)". Therefor i insert the following line into my interface section in my unit: "Function ibfind(name : PChar) : LongInt; cdecl; external". I tried to use it with "nr := ibfind(device);" where nr is a LongInt

an> d

device is PChar. When i try to run the program i get the following error: "Error: undefined reference to `ibfind' " What i am doing wrong? Could somebody help me?

It is {$Linklib gpiblib.a}. (Maybe it's only a typo in the email)

Reply by email

Andre Wohnig
to Matt Emson: If it were Delphi code, I'd say you were missing the reference to the library you were…
Matt Emson wrote 20 lines
If it were Delphi code, I'd say you were missing the reference to the library you were calling ibfind from (but then again I could be wrong) You'd need to find something in Free Pascal that does the same as: procedure DoSomething; external 'MYLIB.DLL'; {this is straight out of Delphi's help, so it's not linux geared} Maybe (I am guessing here, so don't assume I know what I'm talking about) Function ibfind(name : PChar) : LongInt; cdecl; external "gpiblib.a"; // or maybe //Function ibfind(name : PChar) : LongInt; cdecl; external "gpiblib"; That would work in Object Pascal anyway. Hope that helps, Matt

Thanx a lot Matt!

This seems to be the right way. I changed the line to "Function ibfind(name : PChar) : LongInt; cdecl; external ´gpiblib.a´ ". The "undefined" error don´t appear annylonger. But now i get a lot of other errors like "/usr/src/linux-gpib/lib/ibFind.c(36) Error: undefined reference to `getenv' ". I think i have to set a path varable or something like that. Or must all the *.c files in the same directory with my program (but i think this could not be the answer)?
Any suggestions?

tia
Andre´

Thiesen | André Wohnig hardware- & software- design GmbH | Im Tiegel 9 | www.thiesen.com 36367 Wartenberg | tel. +49 (0) 6641 979-142 fax -299

Reply by email

Johann Glaser
to Andre Wohnig

Hi Andre!

Show quoted text 8 lines
This seems to be the right way. I changed the line to "Function ibfind(name : PChar) : LongInt; cdecl; external ´gpiblib.a´ ". The "undefined" error don´t appear annylonger. But now i get a lot of other errors like "/usr/src/linux-gpib/lib/ibFind.c(36) Error: undefined reference to `getenv' ". I think i have to set a path varable or something like that. Or must all the *.c files in the same directory with my program (but i think this could not be the answer)? Any suggestions?

As FPC does not compile C-files I think, this error is coming from the linker.

I assume that you will need to link a few more libraries to your program to get gpiblib running. Please look in the documentation of it which libraries you have to link with a normal C program when using gpiblib. There you might need the same libs as for FPC.

Bye
Hansi

Johann Glaser Vienna University of Technology Electrical Engineering http://stud3.tuwien.ac.at/~e9825761/index.html

Reply by email

Marco van de Voort
to Andre Wohnig: Thanx a lot Matt! This seems to be the right way. I changed the line to "Function…
Show quoted text 8 lines
This seems to be the right way. I changed the line to "Function ibfind(name : PChar) : LongInt; cdecl; external �gpiblib.a� ". The "undefined" error don�t appear annylonger. But now i get a lot of other errors like "/usr/src/linux-gpib/lib/ibFind.c(36) Error: undefined reference to `getenv' ". I think i have to set a path varable or something like that. Or must all the *.c files in the same directory with my program (but i think this could not be the answer)? Any suggestions?

The problem is that the library you are using (ibfind) uses other libraries, and the linker can't resolve the references to those libraries.

The missing library is probably C's runtime library, so try {$linklib C} just below the other $linklib directive.

Marco van de Voort ( or )

Reply by email

Peter Vreman
Show quoted text 18 lines
> > > No it was not just a typo. I forgott the "$". But if i add this, i > > > the > > > following error (error over error but i don� t give up): > > > "sh:/root/arbeit/gpib2/test: No such file or directory" -> > > > stderr > > > > > > from test. > > > What could this be? > > > > What is test ? is this a shell script ? > > No, its my program (it�s called test.pas). But there is no program ? Does the file 'test' exist ? According to the above message, it does not exist; so the compiler failed to create an executable; can you send the output of the compiler ?

It tried to link the library dynamicly and it isn't found when the executable is started, thus resulting in the No such file or directory message.

You can try to rename the library to 'libgpi.a' and include {$linklib gpi}.

This is again the problem that linklib doesn't know if the specified library is shared or static. Currently only shared library is supported and not the specification of a static library with it's full name. Maybe that will work with {$l gpilib.a} only. Can't test it myself.

Peter

Reply by email