|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Make file for shared objects
dear Experts, please help, actually i am trying to create a .so(shared object through make file through ld) i am not understaning how to proceed i have tried like through command like i can do it in 2 step like my progam :test2.c Code:
$gcc -fPIC -c test2.c $ld -shared -soname test2.so -o test2.so -lc test2.o this gives me so but same thing i am trying to achiee through Makefile Code:
PROGRAM = test2.c INCLUDEDIRS = \ -I$(ARCENGINEHOME)/include \ -I/usr/X11R6/include LIBDIRS = \ -L$(ARCENGINEHOME)/bin \ -L/usr/X11R6/lib LIBS = -larcsdk //here it is giving me error CXXSOURCES = test2.c # list of source files CXXOBJECTS = $(CXXSOURCES:.c=.o) # expands to list of object files CXXFLAGS = -DESRI_UNIX $(INCLUDEDIRS) CXX = g++ LDFLAGS = $(LIBDIRS) $(LIBS) all: $(PROGRAM) $(PROGRAM): $(CXXOBJECTS) $(CXX) -o $@ $(CXXOBJECTS) $(LDFLAGS) basic_sample.o: basic_sample.cpp basic_sample.h $(CXX) $(CXXFLAGS) -c -o basic_sample.o basic_sample.cpp clean: $(RM) -f $(CXXOBJECTS) $(PROGRAM) run: ./$(PROGRAM) [/code] but here i want to add test.a which takes the object files like Code:
ar -ur test2.a test2.o and through this i want to create test2.so please help me how to achieve this. expecting your help. |
| Sponsored Links | |
|
|
|
#2
|
|||
|
|||
|
I think this would be better placed in the High Level Programming - The UNIX and Linux Forums forum. I assume Code:
PROGRAM = test2.c should be something like Code:
PROGRAM = test2 Since you already have the commands to create static and shared libraries, all you have to do is add to the makefile the library as a target, the object files as dependencies and put this command as the rule, e.g. Code:
test2.so: test2.o
ld -shared -soname test2.so -o test2.so -lc test2.o
test2.a: test2.o
ar -ur test2.a test2.oand then run make test2.a test2.so to see if it works. You can then (and perhaps should) generalise the rules with automatic variables and so on. |
| Sponsored Links | ||
|
|
![]() |
| Tags |
| linux commands |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| g++ with -frepo and shared objects... | Elric of Grans | Programming | 0 | 05-06-2008 08:42 PM |
| debugging shared objects | yakari | UNIX for Advanced & Expert Users | 0 | 10-03-2006 12:14 PM |
| Shared Objects | Yura | UNIX for Advanced & Expert Users | 3 | 09-02-2005 12:25 PM |
| Linking with shared objects | disclaimer | Programming | 2 | 05-03-2005 03:11 AM |
| Shared Objects | mrgubbala | UNIX for Dummies Questions & Answers | 3 | 03-02-2005 01:35 AM |
|
|