Recent

Author Topic: (Solved) C library link error...  (Read 2651 times)

Dasun

  • New Member
  • *
  • Posts: 41
(Solved) C library link error...
« on: September 09, 2016, 04:13:27 am »
All, really appreciate your help with this - burned way to much time on something that should be dead simple.  Read through the documentation very carefully, and no joy ... the library file exists, permissions are good, not a symbolic link

/usr/bin/ld: warning: link.res conyains output sections; did you forget -T
/usr/bin/ld: cannot find -l./lib/libavutil

Code (ignore typos - had to manually type

Unit ffmpeg_interface

{$mode objfpc}{$H+}

Interface

Uses
    Classes, CTypes, SysUtils ;

Function avutil_version() ; cuint ; cdecl; external './lib/libavutil.so' ;

Implementation

End.
« Last Edit: September 09, 2016, 06:43:53 am by Dasun »

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: C library link error...
« Reply #1 on: September 09, 2016, 04:58:46 am »
Disclaimer: I am a Windows person.

I suggest that you remove the path from the library name:
libavutil instead of ./lib/libavutil.so

and you might want to try to load the library dynamically to see where it went wrong.

molly

  • Hero Member
  • *****
  • Posts: 2345
Re: C library link error...
« Reply #2 on: September 09, 2016, 05:12:03 am »
Even stronger, i would use a constant for that library name.

This might perhaps be quicker...

Dasun

  • New Member
  • *
  • Posts: 41
Re: C library link error...
« Reply #3 on: September 09, 2016, 05:56:12 am »
Appreciate the replies and help. Basically tried all your suggestions with no joy and lots of stress..just the same error messages...I have tried moving libraries to application, system lib, Lazarus and free Pascal directories. I have tried compiler linklib commands - and all sorts of variations over quite a few hours !!!   

Never had to try and dynamically load a library from a Linux command line before - I will have to look that one up.

The link to the application is interesting and educational - I am trying to roll my own, so I understand how things work.  But this should be easy, have done similar stuff in other languages and never had a problem like this!!   

As an aside : developing on Linux Mint 1.6, FP 3.0.0 but plan to make the application multi-platform - at least windows.

Dasun

  • New Member
  • *
  • Posts: 41
(Solved) Re: C library link error...
« Reply #4 on: September 09, 2016, 06:43:21 am »
Got it to work - drop the path, in my case use libavutil.so as the name (either constant or on the function as a string )...


Now the secret ..

Project -> Options -> Compiler Options -> Compilation

Linking section

Check pass options to linker ...

Add -L ./lib/ (in my case)


Viola = it compiles! How unobvious is this?  Should be in the wiki or something or perhaps it is and I missed it.../

molly

  • Hero Member
  • *****
  • Posts: 2345
Re: C library link error...
« Reply #5 on: September 09, 2016, 06:44:47 am »
Are you sure the filename is "libavutil.so" ? (and perhaps not something like libavutil.so.0 ?)

Are you sure free pascal knows about your library path ? In case you have no idea about the answer then please use compilation with verbosity set to all as the compiler will then show you which paths it attempts to use as well as show you current configuration options).

edit: ah,our posts crossed  :) Glad that you got it solved. fwiw: -va is the key to everything  ;)
« Last Edit: September 09, 2016, 06:48:09 am by molly »

Thaddy

  • Hero Member
  • *****
  • Posts: 9164
Re: (Solved) C library link error...
« Reply #6 on: September 09, 2016, 03:43:17 pm »
That last part can be dropped, Molly. the  dot zero is not necessary unless it is not the default lib.
also related to equus asinus.

molly

  • Hero Member
  • *****
  • Posts: 2345
Re: (Solved) C library link error...
« Reply #7 on: September 09, 2016, 05:22:58 pm »
Thank you for the correction Thaddy.

Indeed only if it is not the default lib. In that regards i was just taking a longshot at TS's issue.