Visit Our UNIX and Linux User Community


Makefile shared library g++


 
Thread Tools Search this Thread
Top Forums Programming Makefile shared library g++
# 1  
Old 12-16-2009
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:
Code:
CC = g++
MODULES= readconfig.o ReadConfigLib.o
OBJECTS=
RCLOBJECTS= ReadConfigLib.cpp readconfig.cpp configDefinitions.h readconfig.h ReadConfigLib.h readconfig.h configDefinitions.h
LDFLAGS = -Wl,-rpath,/usr/lib
LIBS = -L/usr/local/lib -lReadToueiConfig

all: libReadToueiConfig.so

#readconfig.o: $(RCOBJECTS)
	#$(CC) -fPIC -o readconfig $(RCOBJECTS)
libReadToueiConfig.so: $(MODULES)
	$(CC) -shared $(MODULES) -o libReadToueiConfig.so

readconfig.o: $(RCLOBJECTS)
	$(CC) -O2 -fpic -c readconfig.cpp -o readconfig.o

ReadConfigLib.o: $(RCLOBJECTS)
	$(CC) -O2 -fpic -c ReadConfigLib.cpp -o ReadConfigLib.o
	

install:
	cp libReadToueiConfig.so /usr/local/lib

count:
	wc *.c *.cc *.C *.cpp *.h *.hpp

clean:
	rm -f *.o
	rm -f libReadToueiConfig.so

.PHONY: all
.PHONY: count
.PHONY: clean
.PHONY: install


Last edited by james2432; 12-16-2009 at 08:19 PM.. Reason: Found solution, you may delete if mods think its worth deleting

Previous Thread | Next Thread
Test Your Knowledge in Computers #500
Difficulty: Easy
Comments in code provide a high-level description of what a block of code, function, or program does.
True or False?

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

3. Programming

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 ... (1 Reply)
Discussion started by: jadsys
1 Replies

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

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

Shared memory for shared library

I am writing a shared library in Linux (but compatible with other UNIXes) and I want to allow multiple instances to share a piece of memory -- 1 byte is enough. What's the "best" way to do this? I want to optimize for speed and portability. Obviously, I'll have to worry about mutual exclusion. (0 Replies)
Discussion started by: otheus
0 Replies

7. Programming

shared library not found

Hello, On a Centos 5.0 box, I have two versions of a library (sqlite): (1) in /usr/lib that was installed using yum (maybe from php but I am not really sure) (2) in /usr/local/lib that I installed myself by compiling from the source code. My C++ program contains the following lines: ... (12 Replies)
Discussion started by: JCR
12 Replies

8. Programming

Shared memory in shared library

I need to create a shared library to access an in memory DB. The DB is not huge, but big enough to make it cumbersome to carry around in every single process using the shared library. Luckily, it is pretty static information, so I don't need to worry much about synchronizing the data between... (12 Replies)
Discussion started by: DreamWarrior
12 Replies

9. UNIX for Advanced & Expert Users

shared library

What is the primary difference between static library and dynamic library? and how to write static shared library? (1 Reply)
Discussion started by: areef4u
1 Replies

10. Programming

Shared Library

hello all I want to work in shared libraries how can i work in Linux Environment ? (2 Replies)
Discussion started by: rajashekaran
2 Replies

Featured Tech Videos