• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

force a library to use only static libraries

Hi,
   I am trying to build a static library in Eclipse.

I want to only use the static versions of the libraries that it depends on. (This is an embedded device, so I would rather not be installing shared libs.

The library builds OK, and links into my application OK.
But when I try to run the app, I get complaints that it cant find some shared library.(Because the shared lib is NOT on the device)

It seems that the build defaults to using shared libs when possible.

Does anyone know how I can tell eclipse to ONLY use static libs.

On a normal executable there is an Linker entry on the configuration page, and you have the option there of forcing 'static' libs. But there is no such item on the 'library' config page.

0
slats52
Asked:
slats52
  • 4
  • 2
  • 2
1 Solution
 
woolmilkporcCommented:
Perhaps

--disable-shared
0
 
slats52Author Commented:
Thanks for your quick response woolmilkporc.

I'm not sure where I would put this though.

The only place I can see that allows me to enter any options is on the miscellaneous page.

When I do this it says
            unrecognized command line option

                       
0
 
parparovCommented:
Can you set build logging to max verbosity and post the log here?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
woolmilkporcCommented:
OK,

what I posted was a "configure" option.

The linker options used to disable linking against shared libraries are

-Bstatic
-dn
-non_shared
-static

I assume that at least one of them should work.

wmp
0
 
slats52Author Commented:
here it is parparov:

**** Full rebuild of configuration Release for project utility ****

make -k clean all
rm -rf  ./UtilityLibrary.o ./XML_FileHandler.o  ./UtilityLibrary.d ./XML_FileHandler.d libutility.a
 
Building file: ../UtilityLibrary.cpp
Invoking: GCC C++ Compiler
/usr/bin/g++ -I/usr/local/include/libxml++-2.6 -I/home/Steve/workspaces/TimeStorm-workspace/ -I/usr/lib/glib-2.0/include -I/usr/lib/glibmm-2.4/include -I/usr/local/lib/libxml++-2.6/include -I/usr/include/glib-2.0 -I/usr/include/glibmm-2.4 -I/home/Steve/workspaces/TimeStorm-workspace/NIFTY_SHEDS/include -O3 -Wall -c -fmessage-length=0 -v -oUtilityLibrary.o ../UtilityLibrary.cpp
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)
 /usr/libexec/gcc/i386-redhat-linux/4.1.2/cc1plus -quiet -v -I/usr/local/include/libxml++-2.6 -I/home/Steve/workspaces/TimeStorm-workspace/ -I/usr/lib/glib-2.0/include -I/usr/lib/glibmm-2.4/include -I/usr/local/lib/libxml++-2.6/include -I/usr/include/glib-2.0 -I/usr/include/glibmm-2.4 -I/home/Steve/workspaces/TimeStorm-workspace/NIFTY_SHEDS/include -D_GNU_SOURCE ../UtilityLibrary.cpp -quiet -dumpbase UtilityLibrary.cpp -mtune=generic -auxbase-strip UtilityLibrary.o -O3 -Wall -version -fmessage-length=0 -o /tmp/ccWoKarc.s
ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/libxml++-2.6
 /home/Steve/workspaces/TimeStorm-workspace/
 /usr/lib/glib-2.0/include
 /usr/lib/glibmm-2.4/include
 /usr/local/lib/libxml++-2.6/include
 /usr/include/glib-2.0
 /usr/include/glibmm-2.4
 /home/Steve/workspaces/TimeStorm-workspace/NIFTY_SHEDS/include
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/i386-redhat-linux
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/backward
 /usr/local/include
 /usr/lib/gcc/i386-redhat-linux/4.1.2/include
 /usr/include
End of search list.
GNU C++ version 4.1.2 20080704 (Red Hat 4.1.2-48) (i386-redhat-linux)
      compiled by GNU C version 4.1.2 20080704 (Red Hat 4.1.2-48).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: c99ff781bd047c28594884be904133f5
 as -V -Qy -oUtilityLibrary.o /tmp/ccWoKarc.s
GNU assembler version 2.17.50.0.6-14.el5 (i386-redhat-linux) using BFD version 2.17.50.0.6-14.el5 20061020
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)
 /usr/libexec/gcc/i386-redhat-linux/4.1.2/cc1plus -E -quiet -v -I/usr/local/include/libxml++-2.6 -I/home/Steve/workspaces/TimeStorm-workspace/ -I/usr/lib/glib-2.0/include -I/usr/lib/glibmm-2.4/include -I/usr/local/lib/libxml++-2.6/include -I/usr/include/glib-2.0 -I/usr/include/glibmm-2.4 -I/home/Steve/workspaces/TimeStorm-workspace/NIFTY_SHEDS/include -P -MM -MG -D_GNU_SOURCE ../UtilityLibrary.cpp -mtune=generic -Wall -w -fmessage-length=0 -O3
ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/libxml++-2.6
 /home/Steve/workspaces/TimeStorm-workspace/
 /usr/lib/glib-2.0/include
 /usr/lib/glibmm-2.4/include
 /usr/local/lib/libxml++-2.6/include
 /usr/include/glib-2.0
 /usr/include/glibmm-2.4
 /home/Steve/workspaces/TimeStorm-workspace/NIFTY_SHEDS/include
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/i386-redhat-linux
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/backward
 /usr/local/include
 /usr/lib/gcc/i386-redhat-linux/4.1.2/include
 /usr/include
End of search list.
Finished building: ../UtilityLibrary.cpp
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)
 /usr/libexec/gcc/i386-redhat-linux/4.1.2/cc1plus -quiet -v -I/usr/local/include/libxml++-2.6 -I/home/Steve/workspaces/TimeStorm-workspace/ -I/usr/lib/glib-2.0/include -I/usr/lib/glibmm-2.4/include -I/usr/local/lib/libxml++-2.6/include -I/usr/include/glib-2.0 -I/usr/include/glibmm-2.4 -I/home/Steve/workspaces/TimeStorm-workspace/NIFTY_SHEDS/include -D_GNU_SOURCE ../XML_FileHandler.cpp -quiet -dumpbase XML_FileHandler.cpp -mtune=generic -auxbase-strip XML_FileHandler.o -O3 -Wall -version -fmessage-length=0 -o /tmp/ccrgL02V.s
ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/libxml++-2.6
 /home/Steve/workspaces/TimeStorm-workspace/
 /usr/lib/glib-2.0/include
 /usr/lib/glibmm-2.4/include
 /usr/local/lib/libxml++-2.6/include
 /usr/include/glib-2.0
 /usr/include/glibmm-2.4
 /home/Steve/workspaces/TimeStorm-workspace/NIFTY_SHEDS/include
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/i386-redhat-linux
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/backward
 /usr/local/include
 /usr/lib/gcc/i386-redhat-linux/4.1.2/include
 /usr/include
End of search list.
GNU C++ version 4.1.2 20080704 (Red Hat 4.1.2-48) (i386-redhat-linux)
      compiled by GNU C version 4.1.2 20080704 (Red Hat 4.1.2-48).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: c99ff781bd047c28594884be904133f5
 
Building file: ../XML_FileHandler.cpp
Invoking: GCC C++ Compiler
/usr/bin/g++ -I/usr/local/include/libxml++-2.6 -I/home/Steve/workspaces/TimeStorm-workspace/ -I/usr/lib/glib-2.0/include -I/usr/lib/glibmm-2.4/include -I/usr/local/lib/libxml++-2.6/include -I/usr/include/glib-2.0 -I/usr/include/glibmm-2.4 -I/home/Steve/workspaces/TimeStorm-workspace/NIFTY_SHEDS/include -O3 -Wall -c -fmessage-length=0 -v -oXML_FileHandler.o ../XML_FileHandler.cpp
 as -V -Qy -oXML_FileHandler.o /tmp/ccrgL02V.s
GNU assembler version 2.17.50.0.6-14.el5 (i386-redhat-linux) using BFD version 2.17.50.0.6-14.el5 20061020
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)
 /usr/libexec/gcc/i386-redhat-linux/4.1.2/cc1plus -E -quiet -v -I/usr/local/include/libxml++-2.6 -I/home/Steve/workspaces/TimeStorm-workspace/ -I/usr/lib/glib-2.0/include -I/usr/lib/glibmm-2.4/include -I/usr/local/lib/libxml++-2.6/include -I/usr/include/glib-2.0 -I/usr/include/glibmm-2.4 -I/home/Steve/workspaces/TimeStorm-workspace/NIFTY_SHEDS/include -P -MM -MG -D_GNU_SOURCE ../XML_FileHandler.cpp -mtune=generic -Wall -w -fmessage-length=0 -O3
ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/libxml++-2.6
 /home/Steve/workspaces/TimeStorm-workspace/
 /usr/lib/glib-2.0/include
 /usr/lib/glibmm-2.4/include
 /usr/local/lib/libxml++-2.6/include
 /usr/include/glib-2.0
 /usr/include/glibmm-2.4
 /home/Steve/workspaces/TimeStorm-workspace/NIFTY_SHEDS/include
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/i386-redhat-linux
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/backward
 /usr/local/include
 /usr/lib/gcc/i386-redhat-linux/4.1.2/include
 /usr/include
End of search list.
Finished building: ../XML_FileHandler.cpp
 
Building target: libutility.a
Invoking: GCC Archiver
/usr/bin/ar -r libutility.a ./UtilityLibrary.o ./XML_FileHandler.o
Finished building target: libutility.a
 
/usr/bin/ar: creating libutility.a
Build complete for project utility

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
I see the --enable-shared in there. But as this is a 'managed' project by the Eclipse CDT, I cant see where I can add/change this option.
0
 
parparovCommented:
There is surely some kind of "Project -> Configuration" dialog where these things are defined.
0
 
slats52Author Commented:
One would think so....

However I've been unable to find them yet.

I did just stumble upon something called 'supplemental makefiles' called makefile.init, makefile.defs, and makefile.targets. But nothing yet as far as what to put in them.

But its time to go home and tackle this Monday...(correction Tuesday).
0
 
slats52Author Commented:
The solution turned out to be in those 3 supplemental makefiles that I found.

I had to put "LIBS += <the static-lib-I wanted> into the makefile.defs file.
These 3 files get read at different points in the automaticllly created makefile.

This caused the archiver (ar), to build that static file into the archive.

woolmilkporc: the options you gave only apply to the linker, but no linking is done to build a static library. So I'm giving at least partial points to parparov for getting me looking in the right place.

Thanks to both of you for your contributions.

                    Steve
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now