Howto link a lib in my Makefile

G

g.vukoman

Hi all!

I have a problem with my Makefile/library.

My library "libmylib.so" includes the header file <boost/regex.hpp>.

My Makefile uses following variables:

CC = gcc
CXX = g++
LD = g++

CCFLAGS =
CXXFLAGS =
LDFLAGS = -Wl,-soname,libsysinfo.so.1 -shared

CP = cp
LN = ln
MD = mkdir
RM = rm

..PHONY: clean
..PHONY: install
..PHONY: uninstall

[...]

A "make install" works great.

BUT...

when I build a binary which uses libmylib I have to enter:

g++ libmylib-test.cc -lmylib -lboost_regex

How can I avoid "-lboost_regex"? The binary only includes libmylib.

So, how can I link libboost_regex into libmylib to avoid later
linking?

Thanks

Goran
 
P

Puppet_Sock

I have a problem with my Makefile/library.
[snip]

That's nice. However, make and similar utilities are off topic here.
Here we only talk about the C++ language. Setting up your keyboard
to write C++ code is off topic also.

You might get better results if you found a group that had something
to do with make, or your operating system, or your compiler. Check
out groups.google.com for a start.
Socks
 
J

James Kanze

I have a problem with my Makefile/library.
My library "libmylib.so" includes the header file <boost/regex.hpp>.
My Makefile uses following variables:

Note that how to invoke the compiler and the associated tools
(which is really what your question is about) is off topic here,
and you really should ask in a group dedicated to your toolset.
However...

[...
when I build a binary which uses libmylib I have to enter:
g++ libmylib-test.cc -lmylib -lboost_regex
How can I avoid "-lboost_regex"? The binary only includes libmylib.

You have to arrange for your library to incorporate the
necessary object files (probably all of them) from the boost
library. How you do this depends very much on your platform;
with the Unix toolset, I think you have to extract the library
into a temporary directory, then add the files from that
directory to your library.
 

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

Members online

No members online now.

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,692
Latest member
JenniferTi

Latest Threads

Top