Re: Linking agent against a C++ application

Raffles <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
OK I've fixed it. All you need to be able to link the agent in to a C++ 
application, is a small change to the Makefiles in the agent and apps 
directories. When linking the Makefile needs to give g++ as the first 
"argument" to libtool, rather than gcc. Below is a patch file for fixing 
the two make files. Note this isn't a patch on the NetSNMP distribution, 
but on the Makefiles themselves, so you'll need to run the patch twice - 
once on each of the two Makefiles. Note also that the NetSNMP Makefiles 
are autogenerated by the ./configure command, so you'll need to repatch 
the makefiles every time you do ./configure.

Given the number of times that C++ has come up before on this list, I 
hope this fix will be useful to folk!

The real fix for this needs the code which autogenerates the Makefiles 
to be changed, so that ./configure produces the patched version of the 
Makefiles. Once that's done, NetSNMP should work with C++ out of the 
box. All the application developer then needs to do is provide a C 
wrapper interface around the C++ application, which the agent can then use.

I hope this helps. Cheers

Raffles

--- Makefile	2006-01-27 11:28:49.245467235 +0000
+++ Makefile.bis	2006-01-27 11:29:57.149984444 +0000
@@ -51,6 +51,7 @@

  # Misc Compiling Stuff
  CC	        = gcc
+LINKCC	        = g++

  # use libtool versioning the way they recommend.
  # The (slightly clarified) rules:
@@ -68,11 +69,11 @@
  LIBAGE      = 0
  LIBREVISION = 0

-LIB_LD_CMD      = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) -rpath 
$(libdir) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) -o
+LIB_LD_CMD      = $(LIBTOOL) --mode=link $(LINKCC) $(CFLAGS) -rpath 
$(libdir) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) -o
  LIB_EXTENSION   = la
  LIB_VERSION     =
  LIB_LDCONFIG_CMD = $(LIBTOOL) --mode=finish $(libdir)
-LINK		= $(LIBTOOL) --mode=link $(CC)
+LINK		= $(LIBTOOL) --mode=link $(LINKCC)
  # RANLIB 	= ranlib
  RANLIB		= :


Raffles wrote:
> Hi There,
> 
> I'm trying to use NetSNMP to monitor a software system which is written 
> in C++.
> 
> I've created a C wrapper for the API to the C++ application, and written 
> a mib2c config file to generate code which calls the API to get/set the 
> information it needs. I've stuck the mib2c output into the 
> agent/mibgroup directory and ./configured NetSNMP to use my MIBs.
> 
> When I do the top level make, everything compiles fine, but it doesn't 
> link. The problem is that the linker is wondering what on earth "new" 
> and "delete" are, not to mention autogenerated identifiers to do with 
> virtual tables. As far as I can see the only problem here is that the 
> makefile needs to do C++ linking, not C linking. However, I couldn't see 
> any way to specify the linker in the config file.
> 
> I noticed that the linktool file is auto-generated, so presumably there 
> is a way to fix this in the configure script (which presumably 
> auto-generates it)? Any other solutions also welcome.
> 
> I tried trawling through the archives, and found lots of C++ type 
> questions, but none which answered this one. If I missed it, just point 
> me =)
> 
> Thanks in advance.
> 
> Raffles
> 

-- 

Visit our website at www.roke.co.uk

Roke Manor Research Ltd, Roke Manor, Romsey, Hampshire SO51 0ZN, UK.

The information contained in this e-mail and any attachments is proprietary to
Roke Manor Research Ltd and must not be passed to any third party without
permission. This communication is for information only and shall not create or
change any contractual relationship.



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.