Recent

Author Topic: link a static library  (Read 12960 times)

angman

  • Jr. Member
  • **
  • Posts: 58
link a static library
« on: October 16, 2006, 11:17:45 am »
I want to build a lazarus console program that use a static thirty part library of wich only the static version exixts for linux.

I added the {$linklib dscud5} to my source program and then added
the path in the compiler option library path.

Why when I build the project get the error:
/usr/bin/ld: cannot find -ldscud5.

Maybe I' m wronging something, but not understand wath:

May you help me.

Thanks Angman

 :shock:

matthijs

  • Hero Member
  • *****
  • Posts: 537
RE: link a static library
« Reply #1 on: October 16, 2006, 04:51:46 pm »
This is an error from the linker. Make sure dscud5 library is in the search path of ld.
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

angman

  • Jr. Member
  • **
  • Posts: 58
link a static library
« Reply #2 on: October 17, 2006, 10:27:30 am »
Yes it is and show otions in compiler options is:
-S2cgi -OG1 -gl -vewnhi -l -Fllib/gcc3/dscud5/ -Fu.

the directory contains the library libdscud5.a

and in my source I added the directive

{$linklib dscud5}

Is it correct or there is something that I am wronging?

Thanks,  Angman :?:

RudieD

  • Full Member
  • ***
  • Posts: 234
RE: link a static library
« Reply #3 on: October 17, 2006, 11:00:55 am »
There has been a previous post in connection with .a files and as far as I can remember, theire not supported by freepascal (yet).
The FRED Trainer. (Training FRED with Lazarus/FPC)

angman

  • Jr. Member
  • **
  • Posts: 58
link a static library
« Reply #4 on: October 17, 2006, 11:13:30 am »
I believe the opposite, there are many notices in freepascal manuals that tells how to link aganinst a static .a library. I already tried to link a console freepascal program with the same static library, and not considearging other problem emerged, it at least find the library.

bye,  angman

 :(

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
RE: link a static library
« Reply #5 on: October 17, 2006, 12:45:11 pm »
Yes, I also read that .a libraries are supported.

Maybe it´s better if you ask this on the Free Pascal mailling list. There you will find better answers.

This forum is more dedicated to the Lazarus IDE and the Lazarus Component Library, not compiler issues.

angman

  • Jr. Member
  • **
  • Posts: 58
link a static library
« Reply #6 on: October 17, 2006, 01:39:16 pm »
I know this, but my question is why lazarus does not find the library ?? while freepascal does.

Thanks, angman

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: link a static library
« Reply #7 on: October 17, 2006, 01:44:49 pm »
Quote from: "angman"
I know this, but my question is why lazarus does not find the library ?? while freepascal does.


What command do you use to compile your program on the command-line?

Is this different from the command Lazarus is using?

Lazarus simply calls FreePascal to do the compilation job, so it's just a question of setting the right compiler options.

angman

  • Jr. Member
  • **
  • Posts: 58
link a static library
« Reply #8 on: October 17, 2006, 02:59:27 pm »
I dont use a command, I compile directli within the ide.
and show otions in compiler options is:
-S2cgi -OG1 -gl -vewnhi -l -Fllib/gcc3/dscud5/ -Fu.

The lib/gcc3/dscud5 path is relative to the project directory.

It is all rright, or there is something wrong?

angman

angman

  • Jr. Member
  • **
  • Posts: 58
link a static library
« Reply #9 on: October 17, 2006, 06:51:57 pm »
excuse me, I dah'nt understood your thinking.

The commad taht I use to compile in freepascal is:

fpc -Fllib/gcc3/msduc5 prConsLaz.lpr.

Thanks very much, Angman

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
RE: link a static library
« Reply #10 on: October 17, 2006, 08:41:38 pm »
Open your project on Lazarus, go to the Menu Project --> Compiler Options

Open the Tab "Others".

And put -Fllib/gcc3/msduc5 on the custom options field.

Does it work?

angman

  • Jr. Member
  • **
  • Posts: 58
link a static library
« Reply #11 on: October 18, 2006, 03:55:02 pm »
I am a newby with lazarus, and maybe the problem couls be an other.

I saw that the menu command build project in linux does'nt work, so I am executing the menu command build file.  Could the problem is inerent to this?

angman :?:

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: link a static library
« Reply #12 on: October 18, 2006, 04:23:56 pm »
Quote from: "angman"
I saw that the menu command build project in linux does'nt work,


What do you mean by "doesn´t work"?

Does it give an error message? If so, what is the message? If not, what did you expect to see that you did not?

Did you test the solution I passed to you on my other post? Did it work?

angman

  • Jr. Member
  • **
  • Posts: 58
link a static library
« Reply #13 on: October 18, 2006, 05:48:27 pm »
I mean that The ide does not any eror, but not generate any executable, without give any link error.

But if I do the command build file, I get then link error  cannot find -ldscud5

I also tried under windows, in wich the command build project work, but also get then link error.

In both I setted the options as you suggest.

angman

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
RE: link a static library
« Reply #14 on: October 18, 2006, 09:12:47 pm »
Ok, you really should ask this to the compiler experts on the Free Pascal mailling list =)

 

TinyPortal © 2005-2018