LinuxQuestions.org
Register a domain and help support LQ
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, 06:36 AM   #1
webquinty
Member
 
Registered: Apr 2008
Location: Espaņa
Distribution: Suse
Posts: 218

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, 08:45 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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, 10:33 AM   #3
webquinty
Member
 
Registered: Apr 2008
Location: Espaņa
Distribution: Suse
Posts: 218

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


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


All times are GMT -5. The time now is 07:38 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration