SOT: make/build question

W

woodbrian77

Up till now I've just been building a static library.
Now I want to also create a shared library.
I'm trying to figure out how to compile the files
without the fpic option for the static library and
then add fpic and recompile the files for the shared
library. I'd like to do this from one makefile.
I've been duckduckgoing --
https://duckduckgo.com -- for a couple of hours,
but haven't figured it out. (Currently I have it
building both a static and shared library, but the
files that go into the static library were compiled
with fpic. http://webEbenezer.net/misc/makefile )


I was reading this thread about libraries:

https://groups.google.com/forum/?fr...ynamic/comp.lang.c++/WdiIeG8yftQ/zx1KYYJ6j_oJ

Is there a shared lib revival in the data center?
It seems some of the difficulties regarding shared
libs mentioned in that thread vanish in a data center.
Thanks in advance.


Brian
Ebenezer Enterprises - in G-d we trust.
http://webEbenezer.net
 
J

Jorgen Grahn

Up till now I've just been building a static library.
Now I want to also create a shared library.
I'm trying to figure out how to compile the files
without the fpic option for the static library and
then add fpic and recompile the files for the shared
library. I'd like to do this from one makefile.

What have you tried? I'd start with building to separate
directories:

libfoo.a: static/bar.o
libfoo.so: shared/bar.o
static/%.o: %.c
shared/%.o: %.c

And so on.

/Jorgen
 
W

woodbrian77

What have you tried? I'd start with building to separate

directories:



libfoo.a: static/bar.o

libfoo.so: shared/bar.o

static/%.o: %.c

shared/%.o: %.c



And so on.

I saw something like CXXFLAGS+=-fpic, but I couldn't
get that to work.
 
J

Jorgen Grahn

I saw something like CXXFLAGS+=-fpic, but I couldn't
get that to work.

It does work (assuming you use Gnu Make and have read the manual). The
'target: VAR+=stuff' syntax is intended for just that: to tweak the
way certain targets are built.

I use it that way. You can also customize those rules completely when
needed. After you have created a clear way of pointing out certain
build steps which have something in common ('static/%.o: %.c' above),
Make is on your side.

/Jorgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Request for build feedback 47
OT: Problem building libc++ 7
Compiler related topics 3
Incremental build systems, infamake 20
Marshalling asymmetry 8
About build static library 2
Installation of tioga 2
Newbie Question 9

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top