Difference between revisions of "FAQ:Compiling 07"

From Net-SNMP Wiki
Jump to: navigation, search
(Move FAQ text to a template page & 5.4 release synchronisation)
m (Latest FAQ revision - preparing for 5.5 release)
 
Line 1: Line 1:
= Why is the project workspace empty under Visual C++? =  
+
= How can I compile the project to use static linking? =  
  
 
<!-- NB:
 
<!-- NB:
Line 7: Line 7:
 
   Compiling section.
 
   Compiling section.
 
  -->
 
  -->
{{FAQ:Compiling_10}}
+
{{FAQ:Compiling_09}}
  
 
     [[FAQ:Compiling]]
 
     [[FAQ:Compiling]]
 
     {{FAQ:Compiling}}
 
     {{FAQ:Compiling}}

Latest revision as of 16:16, 19 July 2009

How can I compile the project to use static linking?

For totally static net-snmp executables, use

       configure --with-ldflags=-Bstatic

To compile your application with static libraries (eg for easier debugging), and to link to a non-installed build directory, try the following Makefile fragment:

 NETSNMPDIR=/usr/local/build/snmp/full-clean-cvs-V5-1-patches
 NETSNMPCONFIG=$(NETSNMPDIR)/net-snmp-config
NETSNMPBASECFLAGS := $(shell $(NETSNMPCONFIG) --base-cflags) NETSNMPINCLUDES := $(shell $(NETSNMPCONFIG) --build-includes $(NETSNMPDIR)) # base flags after build/src include, in case it has /usr/local/include NETSNMPCFLAGS=$(NETSNMPINCLUDES) $(NETSNMPBASECFLAGS)
NETSNMPBASELIBS := $(shell $(NETSNMPCONFIG) --base-agent-libs) NETSNMPEXTLIBS := $(shell $(NETSNMPCONFIG) --external-agent-libs) NETSNMPLIBDIRS := $(shell $(NETSNMPCONFIG) --build-lib-dirs $(NETSNMPDIR)) NETSNMPLIBDEPS := $(shell $(NETSNMPCONFIG) --build-lib-deps $(NETSNMPDIR)) LIB_DEPS=$(NETSNMPLIBDEPS) LIBS=$(NETSNMPLIBDIRS) -Wl,-Bstatic $(NETSNMPBASELIBS) -Wl,-Bdynamic $(NETSNMPEXTLIBS)
STRICT_FLAGS = -Wall -Wstrict-prototypes CFLAGS=-I. $(NETSNMPCFLAGS) $(STRICT_FLAGS)

This replaces the standard Makefile section, which will used installed libraries:

 NETSNMPCONFIG=net-snmp-config
# uncomment this if you have GNU make #NETSNMPCFLAGS := $(shell $(NETSNMPCONFIG) --base-cflags) #NETSNMPLIBS := $(shell $(NETSNMPCONFIG) --agent-libs) NETSNMPCFLAGS=`$(NETSNMPCONFIG) --base-cflags` NETSNMPLIBS=`$(NETSNMPCONFIG) --agent-libs`
LIBS=$(NETSNMPLIBS)
   FAQ:Compiling
   
  1. How do I control the environment used to compile the software?
  2. How do I control the environment used to compile the software under Windows?
  3. Why does the compilation complain about missing libraries?
  4. How can I reduce the memory footprint?
  5. How can I reduce the installation footprint or speed up compilation?
  6. How can I compile the project for use on an embedded system?
  7. How can I compile the project to use static linking?
  8. Why does 'make test' skip various tests?
  9. Why does 'make test' complain about a pid file?