C++ linking library to a library

linker, programming

Thread Tools Search this Thread
# 1  
Old 11-03-2017
C++ linking library to a library

Hi All,

My application main engine will use a shared library where we do many operation. We are trying to implement the linear algebra operation on the shared library for that I need to link my shared library to the lapack library in /usr/lib.

Below is my make file. Can you please let me know where can I link the lblas lib to this make file



# ---- Constants definitions
#               OPT_CPP                 - C++ Compiler Options
#               OPT_C                   - C Compiler Options
# ---------------------------------------------------------------------



# C++ Compiler


# C Compiler
# ----------

.SUFFIXES: .cpp .o .c

        make -f GNUmakefile_64 $(YESBAN_BIN_64)/lib$(LIBNAME).a

        make -f GNUmakefile_64 $(YESBAN_BIN_64)/lib$(LIBNAME).a

        make -f GNUmakefile_64 $(YESBAN_BINDBG_64)/lib$(LIBNAME).a

        $(YESBAN_AR) -r $@ $(OBJECTS)

        $(YESBAN_AR) -r $@ $(DBGOBJECTS)

# --> C++ compilation
$(YESBAN_BIN_64)/%.o : %.cpp
        $(YESBAN_CC_64)  $(OPT_CPP) $< -o $@
# --> C compilation.
$(YESBAN_BIN_64)/%.o : %.c
        $(YESBAN_CC_64)  $(OPT_CPP) $< -o $@
# --> C++ compilation
$(YESBAN_BINDBG_64)/%.o : %.cpp
        $(YESBAN_CC_64) $(YESBAN_CCDEBUG)  $(OPT_CPP) $< -o $@

# --> C compilation.
$(YESBAN_BINDBG_64)/%.o : %.c
        $(YESBAN_CC_64) $(YESBAN_CDEBUG)  $(OPT_CPP) $< -o $@

Below is the error I am getting when I try to link by in make file above as below


g++: -llapack: linker input file unused because linking not done

Last edited by arunkumar_mca; 11-03-2017 at 01:47 PM..
# 2  
Old 11-03-2017
Let me understand.

You want to add your shared library module to an existing lapack library (or archive?). Aside from the fact that this is a really bad idea, short answer is: this cannot be done.

You will have to use LD_PRELOAD. Google for examples: interposing libraries.

If you have an lapack archive (.o) file then you can add another archive file to the lapack distribution, which is still a bad idea.
This User Gave Thanks to jim mcnamara For This Post:
arunkumar_mca (11-03-2017)
# 3  
Old 11-03-2017
Thanks . Below is my scenario. I am to do it in either , I don't want shared library to add to lapack. I want lapack to added to my shared library

MY engine (C++) ----> Use shared library -----using lapack (which is my new addition)

Now we are implementing a function in shared library which need to use lapack. All my lapack function reside in my shared library. Now the issue is when my engine require the lapack function it will access through share library. I am facing problem with this . The compiller complaining that it cannot link the lapack library on the shared library.

I linked the lapack to the engine at the execution time it is complaining that the lapack needs to be linked with my shared library Which I am not able to do


Last edited by arunkumar_mca; 11-03-2017 at 04:31 PM..

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Add shared members from library to same library in a different directory kneemoe AIX 5 08-25-2012 09:21 AM
./configure problem for libsf library due to apparently missing libdb library. vectrum Linux 4 08-05-2011 10:55 AM
Linking to a shared library Valgrinder OS X (Apple) 0 02-18-2011 07:19 AM
Library linking with GMP bluejayek Programming 3 06-29-2010 10:51 AM
Could static library include static library? freemagic Linux 4 04-07-2010 04:55 AM
How to change a Makefile from building static library to shared library? cpthk Shell Programming and Scripting 1 08-26-2009 03:23 AM
Help while linking the library in AIX rishisoft1 AIX 0 06-21-2009 04:31 PM
C++ library in C smanu Programming 2 12-29-2008 06:26 AM
GD library? thehaapyappy UNIX for Dummies Questions & Answers 4 05-07-2008 07:44 AM
Link error while linking a shared library in unix arunkumar_mca UNIX for Dummies Questions & Answers 3 02-15-2007 09:59 AM
C library Hitori Programming 7 09-01-2006 05:54 AM
Linking problem while linking to shared library laho Programming 6 03-16-2004 10:01 AM