Unix/Linux Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

C++ linking library to a library

Programming


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 11-03-2017   -   Original Discussion by arunkumar_mca
arunkumar_mca's Unix or Linux Image
arunkumar_mca arunkumar_mca is offline
Registered User
 
Join Date: Oct 2004
Last Activity: 11 December 2017, 10:01 AM EST
Posts: 395
Thanks: 61
Thanked 2 Times in 2 Posts
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


Code:
IP_INCLUDE=../iplib
MKLIB_INCLUDE=../lib



LIBNAME=shared
YESBANVER=$(YESBAN_PRODUCT_MAJ)$(YESBAN_PRODUCT_MIN)
YESBANBLD=$(YESBAN_PRODUCT_BUILD_VER)
ARMAD=/home/armadillo3.4.4/armadillo-3.4.4/include
LLPAT=/usr/lib64

INCLUDEDIR=-I$(YESBAN_RWPATH_64)  -I$(YESBAN_RWINCLUDECTPATH_64) -I$(YESBAN_RWINCLUDEPATH_64) \
        -I$(YESBAN_SYBINCLUDE_64) -I$(IMS_INCLUDE) -I$(PFLIB_INCLUDE) -I. -I$(ARMAD) -I$(LLPAT)


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


#CPPOPTS=-D_OS_LINUX -DHPaCC -DSYB_LP64 -D_THREAD_SAFE -D__HPACC_THREAD_SAFE_RB_TREE

CPPOPTS=

# C++ Compiler

OPT_CPP=$(YESBAN_CCOPT) $(_OPT_CPP) $(INCLUDEDIR) $(YESBAN_RW_OPTS) -D_FILE_OFFSET_BITS=64 -DARMA_DONT_USE_WRAPPER


# C Compiler
# ----------
OPT_C=$(YESBAN_COPT) $(_OPT_C) $(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 -DARMA_DONT_USE_WRAPPER


.SUFFIXES: .cpp .o .c

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

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

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

$(YESBAN_BIN_64)/lib$(LIBNAME).a: $(OBJECTS)
        $(YESBAN_AR) -r $@ $(OBJECTS)

$(YESBAN_BINDBG_64)/lib$(LIBNAME).a: $(DBGOBJECTS)
        $(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



Code:
OPT_CPP=$(YESBAN_CCOPT) $(_OPT_CPP) $(INCLUDEDIR) $(YESBAN_RW_OPTS) -D_FILE_OFFSET_BITS=64 -DARMA_DONT_USE_WRAPPER -llapack


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

Last edited by arunkumar_mca; 11-03-2017 at 01:47 PM..
Sponsored Links
    #2  
Old Unix and Linux 11-03-2017   -   Original Discussion by arunkumar_mca
jim mcnamara's Unix or Linux Image
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 15 January 2018, 9:34 AM EST
Location: NM
Posts: 11,284
Thanks: 581
Thanked 1,127 Times in 1,038 Posts
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.
The Following User Says Thank You to jim mcnamara For This Useful Post:
arunkumar_mca (11-03-2017)
Sponsored Links
    #3  
Old Unix and Linux 11-03-2017   -   Original Discussion by arunkumar_mca
arunkumar_mca's Unix or Linux Image
arunkumar_mca arunkumar_mca is offline
Registered User
 
Join Date: Oct 2004
Last Activity: 11 December 2017, 10:01 AM EST
Posts: 395
Thanks: 61
Thanked 2 Times in 2 Posts
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

Thanks
Arun

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
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
Help while linking the library in AIX rishisoft1 AIX 0 06-21-2009 04:31 PM
Link error while linking a shared library in unix arunkumar_mca UNIX for Dummies Questions & Answers 3 02-15-2007 09:59 AM
Linking problem while linking to shared library laho Programming 6 03-16-2004 10:01 AM



All times are GMT -4. The time now is 11:55 AM.