LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-09-2009, 05:43 AM   #1
vessper
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Rep: Reputation: 0
Red face unable to link against a 'c' shared library


Hello everybody.

This is my first post here and I have a problem that I am not able to solve for some time now.

I have written a piece of software on a MAC and have been attempting to port it to SuSe 11.1. The problem is that one of the libraries that is used by the code refuses to link. It could be because it doesn't like very much, but I am hoping that the explanation is simpler.

The library is called vl (http://www.vlfeat.org/). It is made in c and compiles fine. Thereafter I copy libvl.so to /usr/local/lib and the header files in /usr/local/include. My source compiles fine. The offending command is:

Quote:
g++ -L"/home/vess/phd/cpppoj/SFM/extern/libs" -L/usr/local/lib -L/usr/lib -o"SFM" [...object files here ...] -llog4cplus -llapack -lANN -lIL -lvl -lc -lILU
Quote:
undefined reference to `vl_sift_new(int, int, int, int, int)'
undefined reference to `vl_sift_process_first_octave...
undefined reference to `vl_sift_process_next_octave...
undefined reference to `vl_sift_detect(_VlSiftFilt*)'
[...]
collect2: ld returned 1 exit status
make: *** [SFM] Error 1
Running nm reports that all simbols are there. For example:
Quote:
$ nm /usr/local/lib/libvl.so | grep vl_sift_new
0000f030 T vl_sift_new
I am running the compilation from Eclipse where I have included all necessary paths, and /usr/local/lib is in /etc/ld.so.conf.

Please let me know what I am missing.

I will appreciate any help.
Cheers
 
Old 11-09-2009, 08:12 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Did you check versioning of the libraries? Perhaps the interfaces have changed between versions, messing up the linking.
Not a g++ expert, but does the order of the parameters matter for the g++ command above? ie do you not need to put the -l options
before the .o files?
Might want to have a look at LD_LIBRARY_PATH environment variable too.
 
Old 11-09-2009, 10:16 AM   #3
maslik
Member
 
Registered: Nov 2009
Location: Czech republic
Distribution: Ubuntu
Posts: 43

Rep: Reputation: 17
Is your software written in C or C++? I had a similar problem while I was trying to link a C++ program against C ffmpeg library. As a solution I had to use wrap the includes with extern "C" to make it work. But it looks like, that your piece of software is written in C, because the compiler doesn't try to link against the functions with C++ decorations. As mentioned above it may really be because of different compiler versions.
 
Old 11-09-2009, 10:47 AM   #4
vessper
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Yes, yes, yes! That is it! My software is C++ while the library is C. I just added:

Quote:
extern "C" {
#include "vl/sift.h"
}
And it compiled. Finally! It is an issue of using a C library into a C++ code. Half an hour ago i deiscoverd this link http://developers.sun.com/solaris/articles/mixing.html. It explains a lot about mixing C and C++.

Thanks a lot maslik!
 
Old 11-09-2009, 10:49 AM   #5
maslik
Member
 
Registered: Nov 2009
Location: Czech republic
Distribution: Ubuntu
Posts: 43

Rep: Reputation: 17
I'm glad I could help you .
 
  


Reply

Tags
linking


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
Unable to load a shared library vipulspn Linux - Newbie 7 08-26-2009 07:29 AM
unable to step through function in shared object library using gdb markhod Programming 2 01-03-2009 02:00 AM
gcc link shared library against another shared library qcp Linux - Newbie 1 07-25-2008 11:15 AM
Link shared library in Kdevelop neikinfology Linux - Software 0 07-12-2007 03:35 AM
GNU based c++ cross compiler unable to link c library k_taid Programming 1 06-29-2005 09:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:10 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
Open Source Consulting | Domain Registration