FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 02-03-2011, 05:39 PM
Mark Knecht
 
Default Linking to a non-standard library installed using portage

Hi,
This is going to be trivial for anyone who actually programs.
Thanks in advance.

How do I link to a library I installed using portage? If someone
could show me an example make file that would be great. I've no real
experience in C and what I did have was in Windows years ago so I'm
undertaking some study here. I wrote a simple little test program that
calculates a simple moving average using ta-lib:

mark@c2stable ~/CODE/CUDA/Mark $ cat ta-lib-ma.cu
#include <stdlib.h>
#include <ta-lib/ta_libc.h>

#define VECTOR_LEN 100

int main(int argc, char **argv)
{
int i;
double MyData[VECTOR_LEN];
double MySMA[VECTOR_LEN];
TA_Integer outBeg;
TA_Integer outNbElement;

for (i = 0; i < VECTOR_LEN; i++)
{
MyData[i] = (i*i)/(10*i);
}

TA_SMA(0, VECTOR_LEN-1, MyData, 10, &outBeg, &outNbElement, MySMA);

for ( i=0; i< outNbElement; i++ ) printf("Bar %d = %f
", outBeg+1,
MySMA[i]);
return 0;
}
mark@c2stable ~/CODE/CUDA/Mark $


The program compiles fine using NVidia CUDA compiler nvcc creating an
object file ta-lib-ma.o:

mark@c2stable ~/CODE/CUDA/Mark $ nvcc -c ta-lib-ma.cu
mark@c2stable ~/CODE/CUDA/Mark $ ls -al ta-lib-ma.*
-rw-r--r-- 1 mark users 477 Feb 3 10:08 ta-lib-ma.cu
-rw-r--r-- 1 mark users 17184 Feb 3 10:12 ta-lib-ma.o
mark@c2stable ~/CODE/CUDA/Mark $

However I cannot figure out how to link it to the ta-lib files
installed by portage:

mark@c2stable ~/CODE/CUDA/Mark $ equery files ta-lib
[ Searching for packages matching ta-lib... ]
* Contents of sci-libs/ta-lib-0.4.0:
/usr
/usr/bin
/usr/bin/ta-lib-config
/usr/include
/usr/include/ta-lib
/usr/include/ta-lib/ta_abstract.h
/usr/include/ta-lib/ta_common.h
/usr/include/ta-lib/ta_defs.h
/usr/include/ta-lib/ta_func.h
/usr/include/ta-lib/ta_libc.h
/usr/lib64
/usr/lib64/libta_lib.a
/usr/lib64/libta_lib.la
/usr/lib64/libta_lib.so -> libta_lib.so.0.0.0
/usr/lib64/libta_lib.so.0 -> libta_lib.so.0.0.0
/usr/lib64/libta_lib.so.0.0.0
mark@c2stable ~/CODE/CUDA/Mark $

What do I link to?

I've tried various things like this but none seem to find the library correctly:

mark@c2stable ~/CODE/CUDA/Mark $ nvcc -L/usr/lib64/libta_lib
ta-lib-ma.cu -o ta-lib-ma
/tmp/tmpxft_00000a8b_00000000-13_ta-lib-ma.o: In function `main':
tmpxft_00000a8b_00000000-1_ta-lib-ma.cudafe1.cpp.text+0x9f):
undefined reference to `TA_SMA'
collect2: ld returned 1 exit status
mark@c2stable ~/CODE/CUDA/Mark $

Thanks in advance for any pointers.

Cheers,
Mark
 
Old 02-03-2011, 06:16 PM
Mike Gilbert
 
Default Linking to a non-standard library installed using portage

On Thu, Feb 3, 2011 at 1:39 PM, Mark Knecht <markknecht@gmail.com> wrote:
> What do I link to?
>
> I've tried various things like this but none seem to find the library correctly:
>
> mark@c2stable ~/CODE/CUDA/Mark $ nvcc -L/usr/lib64/libta_lib
> ta-lib-ma.cu -o ta-lib-ma
> /tmp/tmpxft_00000a8b_00000000-13_ta-lib-ma.o: In function `main':
> tmpxft_00000a8b_00000000-1_ta-lib-ma.cudafe1.cpp.text+0x9f):
> undefined reference to `TA_SMA'
> collect2: ld returned 1 exit status

I haven't used nvcc, but I assume it works like gcc. If so, you'll
want to use the -L option for the library path and the -l option to
specify the library name. For example:

nvcc ta-lib-ma.cu -o ta-lib-ma -L/usr/lib64 -lta_lib
 
Old 02-03-2011, 06:42 PM
Mark Knecht
 
Default Linking to a non-standard library installed using portage

On Thu, Feb 3, 2011 at 10:39 AM, Mark Knecht <markknecht@gmail.com> wrote:
<SNIP>
>
> * How do I link to a library I installed using portage?
<SNIP>

And in this case it was simple once I found the right examples:

nvcc -lta_lib ta-lib-ma.cu -o ta-lib-ma

Sorry for the noise.

Cheers,
Mark
 
Old 02-03-2011, 06:46 PM
Paul Hartman
 
Default Linking to a non-standard library installed using portage

On Thu, Feb 3, 2011 at 12:39 PM, Mark Knecht <markknecht@gmail.com> wrote:
> Hi,
> * This is going to be trivial for anyone who actually programs.
> Thanks in advance.
>
> * How do I link to a library I installed using portage? If someone
> could show me an example make file that would be great.

Don't know about nvcc but with gcc you'd use -l (that's a lower-case letter L):

-lyourlibname

So in your case maybe something like this might work:

nvcc -L/usr/lib64/libta_lib ta-lib-ma.cu -o ta-lib-ma -lta_lib
 

Thread Tools




All times are GMT. The time now is 03:29 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org