C++ linking library to a library


 
Thread Tools Search this Thread
Top Forums Programming C++ linking library to a library
# 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
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..
# 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:
# 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

Thanks
Arun

Last edited by arunkumar_mca; 11-03-2017 at 04:31 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. AIX

Add shared members from library to same library in a different directory

I'm trying to install libiconv to AIX 7.1 from an rpm off of the perzl site. The rpm appears to install but I get this error message. add shr4.o shared members from /usr/lib/libiconv.a to /opt/freeware/lib/libiconv.a add shr.o shared members from /usr/lib/libiconv.a to ... (5 Replies)
Discussion started by: kneemoe
5 Replies

2. Linux

./configure problem for libsf library due to apparently missing libdb library.

Hello, ./configure script fails to configure libsf. Please check the following last few lines of configure script error. checking for db1/db.h... no checking for db.h... yes checking for dbopen in -ldb1... no configure: error: No libdb? No libsf. But find command shows the following; ... (4 Replies)
Discussion started by: vectrum
4 Replies

3. OS X (Apple)

Linking to a shared library

I'm trying to get Valgrind to work with an openmpi application in OS X. However I want to hardcode the path to a shared library called libmpiwrap-amd64-darwin.so into my application so that it is available at runtime. In Linux this is relatively simple, I would just add the option... (0 Replies)
Discussion started by: Valgrinder
0 Replies

4. Programming

Library linking with GMP

I am trying to set up the gnu multiple precision arithmetic library for some c++ programming I have to do. I am using a system with mac osx 10.6.3 and do NOT have root user access. I'm trying to use gmp 5.0.1. Since I don't have root user access, I had to install to a different directory Thus... (3 Replies)
Discussion started by: bluejayek
3 Replies

5. Shell Programming and Scripting

How to change a Makefile from building static library to shared library?

Hi: I have a library that it only offers Makefile for building static library. It built libxxx.a file. How do I in any way build a shared library? (either changin the Makefile or direct script or command to build shared library) Thanks. (1 Reply)
Discussion started by: cpthk
1 Replies

6. AIX

Help while linking the library in AIX

Hi, I have one library(libfoo.a) that is folder /home/xyz and my c program is in /home/xyz/cprog. Whenever I issue cc command cc -o test test.c -lfoo , i get the error /usr/bin/ld: cannot find -lfoo. echo $PATH has already listing of /home/xyz variable, even LIBPATH also has same entry... (0 Replies)
Discussion started by: rishisoft1
0 Replies

7. UNIX for Dummies Questions & Answers

Link error while linking a shared library in unix

Getting the following error , ld: /opt/syncsort39/lib/libsyncsort.sl: Mismatched ABI. 64-bit PA shared library found in 32-bit link. Is there any difference in the ld options in opt file while linking a 64 bit shared library ? Or is the problem because we are trying to link both 32 bit and 64... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

8. Programming

Linking problem while linking to shared library

Hi I'm getting ld: fatal: option -h and building a dynamic executable are incompatible ld: fatal: Flags processing errors When I run ld -shared -L/usr/dt/lib -lDtSvc -o builtin.so Workspace.o after running gcc -fPIC -I/usr/X11R6/include -I/usr/dt/include -c Workspace.c I'm... (6 Replies)
Discussion started by: laho
6 Replies
Login or Register to Ask a Question