help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Linking to external static (!) library


From: c.
Subject: Re: Linking to external static (!) library
Date: Tue, 19 Apr 2011 20:47:48 +0200

On 19 Apr 2011, at 20:03, Martin Helm wrote:

> Am Dienstag, 19. April 2011, 19:23:53 schrieb TOT:
>> Hi everyone.
>> There is a big static C library (several lib*.a files). It contains
>> references to MPI library (I'm not sure how)
>> There is one header file (c*.h), containing several other header files and
>> so on.
>> This library compiled using gcc (compatible with octave).
>> 
>> Lets assume that in the library "myopen" function exists. I want to call it
>> in the octave and return the value of it (say 1 if everything is OK and -1
>> on error).
>> 
>> I'm tying to use OCT files, but I end up with an error from ld: "recompile
>> with -fPIC".
>> The library is huge, makefiles are huge and -fPIC option to be placed in
>> too many places, so I don't want to do this.
>> 
>> Two questions:
>> 
>> Is there any way to link to this library (via tweaking mkoctfile or by
>> other means, but not recompiling the library)?
>> 
>> Is it the same for matlab?
>> 
>> Regards,
>> Anar.
>> 
> I can be wrong since I never tried it (what you want to try), but I doubt it 
> is possible since the man page of mkoctfile explicitely states
> "mkoctfile is used to compile C, C++, or Fortran source code in to a 
> dynamically loadable .oct file for octave"
> You will have no luck creating a dynamically loadable file when linking 
> against 
> a library built without -fPIC.

Actually it is possible, what needs to be dynamic is the final oct file but it 
can include object code from a static library.
I think we need more information to be able to help. What are the exact 
commands you used to build and link the .oct file?
Have you tried something like:

mkoctfile -c  -I/path_to_your_libray/include octfile.cpp 
mkoctfile octfile.o /path_to_your_libray/lib/libraryname.a -o octfile.oct  

?

HTH,
c.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]