Static and Shared Library in Makefile


 
Thread Tools Search this Thread
Top Forums Programming Static and Shared Library in Makefile
# 1  
Old 09-14-2010
Static and Shared Library in Makefile

I am having a devil of a time with a very simple make file. The program needs two shared and one static library. If I link the shared libraries only like below the mysql test app works

------------------------------------------------------------------------------------------------------------------------
Code:
CXX := g++
CXXFLAGS := -I/usr/include/mysql -I /usr/include/mysql++
LDFLAGS := -L /usr/lib64 -lmysqlclient -lmysqlpp -L /usr/lib64/mysql
 EXECUTABLE := DigArchive

all: $(EXECUTABLE)

-----------------------------------------------------------------------------------------------
If I try to bring in the static library as shown below, I suddenly get an error:
/usr/bin/ld: cannot find -lmysqlpp

------------------------------------------------------------------------------------------------
Code:
CXX := g++
CXXFLAGS := -I/usr/include/mysql -I /usr/include/mysql++
LDFLAGS := -L /usr/lib64 -lmysqlclient -lmysqlpp -L /usr/lib64/mysql -static -L./ -lRmtDirTree
EXECUTABLE := DigArchive

all: $(EXECUTABLE)

-----------------------------------------------------------------------------------------------

The static library is in the same folder as the program. I must be doing something wrong with the command structure.
BTW: Having the same issue trying to use scons to do this

Any ideas?

Last edited by pludi; 09-15-2010 at 07:59 AM..
# 2  
Old 09-16-2010
Error

You shoud not need the -static flag. I assume that libRmtDirTree.a is the static lib you try to add? If removing the -static flag does not help, try to simply add ./libRmtDirTree.a at the end of the linker command.

HtH, Andre.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Need help changing a makefile to static linking

Hi all, I'm having a hard time compiling a plugin (softhddevice) for the video disk recorder software (vdr). Unfortunately the last official version of the plugin was published back in 2013 and even worse it has to be compiled against ffmpeg. The last working version of ffmpeg was 2.8.x,... (0 Replies)
Discussion started by: ACorner
0 Replies

2. Shell Programming and Scripting

Help understanding makefile: static pattern rules

Hi all, I'm reading the GNU Make book I cannot understand the following syntax from the book. objects = foo.o bar.o all : $(objects) $(objects) : %.o : %.c $(CC) -c $(CFLAGS) $< -o $@ If I run: make, I get the output: cc -c foo.c cc -o foo foo.o I think I... (3 Replies)
Discussion started by: santiagorf
3 Replies

3. 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

4. Programming

Shared library with acces to shared memory.

Hello. I am new to this forum and I would like to ask for advice about low level POSIX programming. I have to implement a POSIX compliant C shared library. A file will have some variables and the shared library will have some functions which need those variables. There is one special... (5 Replies)
Discussion started by: iamjag
5 Replies

5. UNIX for Dummies Questions & Answers

Shared static library

Hello Please what does mean shared static library and LD-Preload? Thank you (3 Replies)
Discussion started by: chercheur857
3 Replies

6. Programming

Even the Static cURL Library Isn't Static

I'm writing a program which uses curl to be run on Linux PCs which will be used by a number of different users. I cannot make the users all install curl on their individual machines, so I have tried to link curl in statically, rather than using libcurl.so. I downloaded the source and created a... (8 Replies)
Discussion started by: BrandonShw
8 Replies

7. Linux

Could static library include static library?

I have some static library(libxxx.a libyyy.a). And I want to generate my library(libzzz.a), libzzz.a will use libxxx.a and libyyy.a I wan't my application only use libzzz.a, (means libzzz.a had include libxxx.a, libyyy.a), how can I do that? Thank you. example: I have zzz.c. I do ... (4 Replies)
Discussion started by: freemagic
4 Replies

8. Programming

Adding a Static Library (libtimer.a) to the Makefile

Hi, The following is my Makefile, I wanted to add a staic library named libtimer.a. I'm using the following Makefile. Please let me know how to add this static library: Makefile:- It produces "usbserial" executable. Thanks, S (1 Reply)
Discussion started by: suryaemlinux
1 Replies

9. Programming

Makefile shared library g++

I'm having trouble with my makefile, I'm trying to code a shared library to be used by another program *EDIT* Found the solution: CC = g++ MODULES= readconfig.o ReadConfigLib.o OBJECTS= RCLOBJECTS= ReadConfigLib.cpp readconfig.cpp configDefinitions.h readconfig.h ReadConfigLib.h... (0 Replies)
Discussion started by: james2432
0 Replies

10. 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
Login or Register to Ask a Question