Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 11-09-2009, 06:43 AM   #1
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 ( It is made in c and compiles fine. Thereafter I copy to /usr/local/lib and the header files in /usr/local/include. My source compiles fine. The offending command is:

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
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:
$ nm /usr/local/lib/ | 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/

Please let me know what I am missing.

I will appreciate any help.
Old 11-09-2009, 09:12 AM   #2
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, 11:16 AM   #3
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, 11:47 AM   #4
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:

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 It explains a lot about mixing C and C++.

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

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



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

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

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