LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-02-2003, 09:43 AM   #1
linuxeco
LQ Newbie
 
Registered: Oct 2002
Posts: 9

Rep: Reputation: 0
Mixing Shared and Dynamic Libraries


I have been working on a c++ program that consists of several source files. I am trying to compile them each into objects and then links them afterwards. This is working just fine except I would like the one object to staically include the libraries that it uses. I have ....

class.cc conf.cc html.cc libsql.cc main.cc sql.cc

sql.cc is the only object that requires mysql and mysql++. Although mysql may be common, mysql++ is not as common. I would like to be able to produce a final binary that does not need the dynamic libraries that relate to -lsqlplus and -lmysqlclient. This will make it easier for me to use the program on multiple machines without having to install additional libs. This is what the section of my makefile looks like. I tried going over the libtool documentation but I seem to be missing something. I am fresh out of ideas so maybe someone can help me.


Code:
CXX =  /usr/bin/c++
CFLAGS = -O2 -march=`uname -m` -funroll-loops
DEBUG = -g -Wall
MYSQL_LIB = -lmysqlclient -lsqlplus
MYSQL_INC = -I/usr/include/mysql -L/usr/lib/mysql
LIBTOOL = libtool
INSTALL = install
DESTDIR =
LOGO = logo.jpg
WEB_PATH = /home/public/public_html/apache
CONF = /etc/logview.conf

# Limits specifies teh maximum length of a string in the config file.
LIMIT = 100

all:
    ${CXX} -c conf.cc -DCONF=\"${CONF}\" -DLIMIT=${LIMIT}
    ${CXX} -static -c libsql.cc -DSQL ${MYSQL_INC}
    ar cru libsql.la libsql.o
    ranlib libsql.la
    ${CXX} -c main.cc
    ${CXX} -c html.cc
    ${CXX} -c class.cc
    ${LIBTOOL} ${CXX} ${CFLAGS} ${DEBUG} class.o main.o conf.o html.o lib.la -o logview \
${MYSQL_INC} ${MYSQL_LIB} -Wl,--rpath
 
Old 02-02-2003, 09:04 PM   #2
linuxeco
LQ Newbie
 
Registered: Oct 2002
Posts: 9

Original Poster
Rep: Reputation: 0
Solved

Well I figured it out, but if anyone has any comments or alternative ways to handle this, I am interested in hearing them

Code:
CXX =  /usr/bin/c++
CXXFLAGS = -O2 -march=`uname -m` -funroll-loops
DEBUG = -g -Wall
MYSQL_LIB = -lmysqlclient
MYSQL_API_LIB = -lsqlplus
MYSQL_INC = -I/usr/include/mysql -L/usr/lib/mysql
LIBTOOL = libtool
INSTALL = install
DESTDIR =
LOGO = logo.jpg
WEB_PATH = /home/public/public_html/apache
CONF = /etc/logview.conf

# Limits specifies teh maximum length of a string in the config file.
LIMIT = 100

all:
        ${CXX} -c conf.cc -DCONF=\"${CONF}\" -DLIMIT=${LIMIT}
        ${CXX} -c sql.cc -DSQL ${MYSQL_INC}
        ${CXX} -c main.cc
        ${CXX} -c html.cc
        ${CXX} -c class.cc
        ${LIBTOOL} ${CXX} ${CXXFLAGS} ${DEBUG} class.o main.o conf.o html.o sql.o -o logview \
                /usr/lib/libsqlplus.a -lz ${MYSQL_INC} ${MYSQL_LIB} -W1,--rpath
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
error while loading shared libraries: libstdc++.so.5: cannot open shared object file: Franziss Linux - Newbie 10 06-28-2010 05:47 AM
Urgent !!! rpm: error while loading shared libraries: libelf.so.1: cannot open shared tinaa Linux - Software 5 12-02-2008 03:19 PM
error while loading shared libraries: libdb-4.1.so: cannot open shared object file putquery8581 Linux - Software 1 10-01-2004 07:03 AM
mixing static and dynamic ip addresses bobwall Linux - Networking 5 07-21-2004 07:47 PM
mplayer: error while loading shared libraries: libdvdread.so.3: cannot open shared ob Bruce Hill Slackware 6 12-11-2003 08:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration