LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 12-23-2012, 06:50 AM   #1
dalal
LQ Newbie
 
Registered: Dec 2012
Posts: 17

Rep: Reputation: Disabled
error in running a code


I wrote a c code
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

#include <plasma.h>
#include <cblas.h>
#include <lapacke.h>
#include <core_blas.h>

#ifndef max
#define max(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef min
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif

int check_orthogonality(int, int, int, PLASMA_Complex32_t*);
int check_factorization(int, int, PLASMA_Complex32_t*, PLASMA_Complex32_t*, int, PLASMA_Complex32_t*);

int IONE=1;
int ISEED[4] = {0,0,0,1}; /* initial seed for clarnv() */

int main ()
{

int cores = 2;
int M = 15;
int N = 10;
int LDA = 15;
int K = min(M, N);
int info;
int info_ortho, info_factorization;
int i,j;
int LDAxN = LDA*N;

PLASMA_Complex32_t *A1 = (PLASMA_Complex32_t *)malloc(LDA*N*sizeof(PLASMA_Complex32_t));
PLASMA_Complex32_t *A2 = (PLASMA_Complex32_t *)malloc(LDA*N*sizeof(PLASMA_Complex32_t));
PLASMA_Complex32_t *Q = (PLASMA_Complex32_t *)malloc(LDA*N*sizeof(PLASMA_Complex32_t));
PLASMA_desc *T;
/* Check if unable to allocate memory */
if ((!A1)||(!A2)||(!Q)){
printf("Out of Memory \n ");
return EXIT_SUCCESS;
}
/* Plasma Initialization */
PLASMA_Init(cores);
printf("-- PLASMA is initialized to run on %d cores. \n",cores);
/* Allocate T */


and compile it by
icc -c pt.c -I/home/usr/plasma-installer_2.5.0/plasma-installer_2.5.0b1/install/include
then when I wrote icc -o pt pt.o
it give me the error
pt.o: In function `main':
pt.c.text+0x7b): undefined reference to `PLASMA_Init'
pt.c.text+0x9f): undefined reference to `PLASMA_Alloc_Workspace_cgeqrf'
[dalal@c4hdn ~]$

Last edited by dalal; 12-23-2012 at 10:19 AM.
 
Old 12-23-2012, 10:03 AM   #2
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
You need to specify some plasma library at link time.

I looked through some online plasma documentation and saw no indication of the name of the library nor instructions for linking against it. Either that is in some instructions I didn't see or plasma is very badly documented.

What did you do to install plasma? Are you running Linux or Windows? (Even for Linux, your question is in the wrong forum within LQ and some moderator should move it).

For Linux, the library you need to link against is some .so file or .a file that was created when you installed plasma. For Windows, it would be a .lib file.
 
Old 12-23-2012, 10:20 AM   #3
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Quote:
Originally Posted by dalal View Post
then when I wrote icc -o pt pt.o
it give me the error
In an icc command for linking, you use a -L option to specify the directory for .a or .so files and a -l (lower case L) option for the name of a .a or .so.

Assuming your lib directory is consistent with your include directory, the first of those options looks like:

-L/home/usr/plasma-installer_2.5.0/plasma-installer_2.5.0b1/install/lib

and the second

-lplasma

But that is just the library to directly resolve the missing symbols you mentioned. Once that is found, the linker will almost certainly need more libraries (at least more -l options, and maybe more -L)

Plasma depends on several lower level matrix packages and there are various choices for which ones you might have installed. I expect you are using MKL for part of that, so you would need a -L option for where you have the MKL lib directory and one or more -l option for parts of MKL. But I think you need some other parts between plasma and MKL.

Do you have any documentation or examples giving you a working version of the link command (which out to be better than my estimate based on online info of a product I've never used)?

Last edited by johnsfine; 12-23-2012 at 10:35 AM.
 
Old 12-23-2012, 10:27 AM   #4
dalal
LQ Newbie
 
Registered: Dec 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
you mean
icc -o pt pt.o -L/home/dalal/plasma-installer_2.5.0/plasma-installer_2.5.0b1/install/lib -Iplasma
but there is still a problem
 
Old 12-23-2012, 10:33 AM   #5
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Quote:
Originally Posted by dalal View Post
you mean
icc -o pt pt.o -L/home/dalal/plasma-installer_2.5.0/plasma-installer_2.5.0b1/install/lib -Iplasma
but there is still a problem
Edit: I wrote below before I looked closely at your post.

In -lplasma, the letter after the - must be a lower case L not an upper case i).
--------------------------------------------
Yes that looks like what I meant and I was sure there would still be a problem.

Is the problem that it can't find the plasma library (meaning some detail in those options is wrong)? Or is the problem that adding those options replaced the undefined symbol errors you had with different undefined symbol errors? That would be progress. I know you need more -l options (and probably more -L) for those other undefined symbols. Reread what I wrote earlier.

Last edited by johnsfine; 12-23-2012 at 10:35 AM.
 
Old 12-23-2012, 11:04 AM   #6
dalal
LQ Newbie
 
Registered: Dec 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
give the following error in compiling
/home/dalal/plasma-installer_2.5.0/plasma-installer_2.5.0b1/install/lib/libplasma.a(control.o): In function `plasma_parallel_section':
control.c.text+0x29a): undefined reference to `QUARK_Worker_Loop'
/home/dalal/plasma-installer_2.5.0/plasma-installer_2.5.0b1/install/lib/libplasma.a(control.o): In function `PLASMA_Finalize':
control.c.text+0x31c): undefined reference to `QUARK_Free'
control.c.text+0x388): undefined reference to `pthread_join'
control.c.text+0x3fc): undefined reference to `pthread_setconcurrency'
control.c.text+0x418): undefined reference to `QUARK_Waitall'
 
Old 12-23-2012, 11:13 AM   #7
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Is libquark.a in the same lib directory with libplasma.a ?

If so, add -lquark to resolve the two QUARK undefined symbols.

I think the pthread symbols are resolved by

-L/usr/lib -lpthread

For other libs you might need, try google of
"-lplasma" "-lquark"
(I had to then click on a link saying I really meant the spelling I typed, because on that search google defaulted to fixing what it though was a typo in my search).
That will find posts in many other forums about others linking the same kind of thing you are linking. Any of the libs they needed might be libs you need.

Last edited by johnsfine; 12-23-2012 at 11:20 AM.
 
Old 12-23-2012, 11:19 AM   #8
dalal
LQ Newbie
 
Registered: Dec 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
yes quark in the same library of libplasma.a , I add -lquark, but there are still a lot of errors
/home/dalal/plasma-installer_2.5.0/plasma-installer_2.5.0b1/install/lib/libplasma.a(control.o): In function `PLASMA_Finalize':
control.c.text+0x388): undefined reference to `pthread_join'
control.c.text+0x3fc): undefined reference to `pthread_setconcurrency'
/home/dalal/plasma-installer_2.5.0/plasma-installer_2.5.0b1/install/lib/libplasma.a(control.o): In function `PLASMA_Init_Affinity':
control.c.text+0x5cc): undefined reference to `pthread_setconcurrency'
control.c.text+0x651): undefined reference to `pthread_create'
 
Old 12-23-2012, 11:20 AM   #9
dalal
LQ Newbie
 
Registered: Dec 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
and also these errors
/home/dalal/plasma-installer_2.5.0/plasma-installer_2.5.0b1/install/lib/libquark.a(quark.o): In function `QUARK_New':
quark.c.text+0x1db7): undefined reference to `pthread_create'
/home/dalal/plasma-installer_2.5.0/plasma-installer_2.5.0b1/install/lib/libquark.a(quark.o): In function `quark_process_completed_tasks':
quark.c.text+0x3061): undefined reference to `pthread_mutex_trylock'
/home/dalal/plasma-installer_2.5.0/plasma-installer_2.5.0b1/install/lib/libquark.a(quark.o): In function `quark_work_main_loop':
quark.c.text+0x3c47): undefined reference to `pthread_mutex_trylock'
/home/dalal/plasma-installer_2.5.0/plasma-installer_2.5.0b1/install/lib/libquark.a(quark.o): In function `QUARK_Delete':
quark.c.text+0x4d30): undefined reference to `pthread_join'
[
 
Old 12-23-2012, 11:21 AM   #10
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Reread my post above. I added info about the pthread undefined symbols.
 
1 members found this post helpful.
Old 12-23-2012, 11:26 AM   #11
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
I just checked my icc documentation and it suggests using just
-pthread
instead of -L/usr/lib -lpthread

pthread is a special library from the compiler's perspective so -pthread (without the l) tells the compiler to understand it as such.

For anyone else reading this, most icc options in Linux were chosen for gcc compatibility, so instructions when using gcc won't be very different from what I am suggesting here for icc (but check your gcc documentation to be sure).

Last edited by johnsfine; 12-23-2012 at 11:30 AM.
 
1 members found this post helpful.
Old 12-23-2012, 11:33 AM   #12
dalal
LQ Newbie
 
Registered: Dec 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
Thank you, for compiling no problems but when icc -o pt pt.o to link it give the following error
pt.o: In function `main':
pt.c.text+0x7d): undefined reference to `PLASMA_Init'
 
Old 12-23-2012, 11:36 AM   #13
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
All of those options I suggested were for your link command, not for your compile command.

In post #4 you seemed to understand that. Now suddenly you're back to the original link command?

Last edited by johnsfine; 12-23-2012 at 11:37 AM.
 
1 members found this post helpful.
Old 12-23-2012, 11:43 AM   #14
dalal
LQ Newbie
 
Registered: Dec 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
yes sorry I did this by wronge. Thank you soooooooooooooo much it work now.
 
Old 12-23-2012, 02:13 PM   #15
dalal
LQ Newbie
 
Registered: Dec 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
what this error mean?how Im can solve it?

icc: error #10014: problem during multi-file optimization compilation (code 4)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error while running perl code to access Oracle spreadsheet umesh_linuxq Linux - Software 1 04-12-2012 08:37 PM
Error while signing a compiled code for Exadigm PoS running Arm-Linux sunnyben Linux - Newbie 0 05-02-2010 02:29 PM
Facing error while running "g++ 3.4.4" code in "g++ 4.3.3" Suranjit Ubuntu 2 10-09-2009 12:22 AM
Error in Perl Code : Bad switch statement(Problem in code block)? near ## line # suyog255 Programming 4 02-20-2008 06:35 PM


All times are GMT -5. The time now is 11:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration