LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 02-04-2009, 05:36 AM   #1
webquinty
Member
 
Registered: Apr 2008
Location: Espaņa
Distribution: Suse
Posts: 227

Rep: Reputation: 32
Problem using shared library........


Hello,

I have developed a shared library, and it compile fine.

Quote:
cc src/libpcican.c -fPIC -shared -O2 -Wall -Wl,-soname,libpcican.so.0 -lc -I. -o libpcican.so.0.6
ln -sf libpcican.so.0.6 libpcican.so
And later, install it...

Quote:
cp libpcican.so.0.6 /usr/lib64/libpcican.so.0.6
ln -sf /usr/lib64/libpcican.so.0.6 /usr/lib64/libpcican.so.0
ln -sf /usr/lib64/libpcican.so.0 /usr/lib64/libpcican.so
cp libpcican.h /usr/include/libpcican.h
chmod 644 /usr/include/libpcican.h
/sbin/ldconfig
But my problem is when I want to use it. I have a easy program, and when I compile with -lpcican, compiler return me this message:

Quote:
gcc -c -m32 -pipe -c -g -O2 -Wall -W -D_REENTRANT -L/lib -L/usr/lib -L/usr/local/lib -I/usr/include -I. -Itc1_task -Itc2_task -Itc3_task -Itc4_task -o taskman.o taskman.c
gcc -c -m32 -pipe -c -g -O2 -Wall -W -D_REENTRANT -L/lib -L/usr/lib -L/usr/local/lib -I/usr/include -I. -Itc1_task -Itc2_task -Itc3_task -Itc4_task -o "tc1_task/tc1_task1.o" "tc1_task/tc1_task1.c"
gcc -c -m32 -pipe -c -g -O2 -Wall -W -D_REENTRANT -L/lib -L/usr/lib -L/usr/local/lib -I/usr/include -I. -Itc1_task -Itc2_task -Itc3_task -Itc4_task -o "tc1_task/tc1_task1_init.o" "tc1_task/tc1_task1_init.c"
gcc -c -m32 -pipe -c -g -O2 -Wall -W -D_REENTRANT -L/lib -L/usr/lib -L/usr/local/lib -I/usr/include -I. -Itc1_task -Itc2_task -Itc3_task -Itc4_task -o "tc1_task/tc1_task2.o" "tc1_task/tc1_task2.c"
gcc -c -m32 -pipe -c -g -O2 -Wall -W -D_REENTRANT -L/lib -L/usr/lib -L/usr/local/lib -I/usr/include -I. -Itc1_task -Itc2_task -Itc3_task -Itc4_task -o "tc1_task/tc1_task2_init.o" "tc1_task/tc1_task2_init.c"
gcc -c -m32 -pipe -c -g -O2 -Wall -W -D_REENTRANT -L/lib -L/usr/lib -L/usr/local/lib -I/usr/include -I. -Itc1_task -Itc2_task -Itc3_task -Itc4_task -o "tc1_task/tc1_task3.o" "tc1_task/tc1_task3.c"
gcc -c -m32 -pipe -c -g -O2 -Wall -W -D_REENTRANT -L/lib -L/usr/lib -L/usr/local/lib -I/usr/include -I. -Itc1_task -Itc2_task -Itc3_task -Itc4_task -o "tc1_task/tc1_task3_init.o" "tc1_task/tc1_task3_init.c"

g++ -m32 -g -O2 -Wall -L/lib -L/usr/lib -L/usr/local/lib -o cyclic_can-v1 taskman.o tc1_task/tc1_task1.o tc1_task/tc1_task1_init.o tc1_task/tc1_task2.o tc1_task/tc1_task2_init.o tc1_task/tc1_task3.o tc1_task/tc1_task3_init.o tc2_task/tc2_task1.o tc2_task/tc2_task2.o tc2_task/tc2_task3.o tc3_task/tc3_task1.o tc3_task/tc3_task2.o tc3_task/tc3_task3.o tc4_task/tc4_task1.o tc4_task/tc4_task2.o tc4_task/tc4_task3.o -lrt -ldl -lpthread -lpcican
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libpcican.so when searching for -lpcican
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib/libpcican.so when searching for -lpcican
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/../lib/libpcican.so when searching for -lpcican
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../libpcican.so when searching for -lpcican
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib64/libpcican.so when searching for -lpcican
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libpcican.so when searching for -lpcican
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: cannot find -lpcican
collect2: ld returned 1 exit status
make: *** [cyclic_can-v1] Error 1
any advice????

Thank you very much.
 
Old 02-04-2009, 07:45 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
g++ -m32 -g -O2 -Wall -L/lib -L/usr/lib -L/usr/local/lib <omitted> -lrt -ldl -lpthread -lpcican
Maybe... you have installed the shared library in /usr/lib64, but among the compiler options that directory is not specified as a search path. Have you tried to add the -L/usr/lib64 option in the compiler flags?
Code:
skipping incompatible /usr/lib/libpcican.so when searching for -lpcican
Moreover this error message can be triggered from a 32-bit version of libpcican in /usr/lib which is incompatible because it is an ELF 32-bit object, when a ELF 64-bit is expected. Just a guess.
 
Old 02-04-2009, 09:33 AM   #3
webquinty
Member
 
Registered: Apr 2008
Location: Espaņa
Distribution: Suse
Posts: 227

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by colucix View Post
Code:
g++ -m32 -g -O2 -Wall -L/lib -L/usr/lib -L/usr/local/lib <omitted> -lrt -ldl -lpthread -lpcican
Maybe... you have installed the shared library in /usr/lib64, but among the compiler options that directory is not specified as a search path. Have you tried to add the -L/usr/lib64 option in the compiler flags?
Code:
skipping incompatible /usr/lib/libpcican.so when searching for -lpcican
Moreover this error message can be triggered from a 32-bit version of libpcican in /usr/lib which is incompatible because it is an ELF 32-bit object, when a ELF 64-bit is expected. Just a guess.
You are right, that is the problem.
I have compiled library with -m32 too, and install in correct folder, and now works fine.

Thanks a lot.
 
  


Reply



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
gcc link shared library against another shared library qcp Linux - Newbie 1 07-25-2008 11:15 AM
Help::Shared Library Problem ypankaj Programming 3 04-21-2008 02:33 AM
Shared library problem - really need your help! tatchan Programming 4 01-04-2007 04:49 PM
shared library problem nhatkhang Programming 2 11-28-2006 07:15 AM
shared library problem jdb04 Linux - Newbie 2 06-11-2006 01:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:01 PM.

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
Open Source Consulting | Domain Registration