Wireshark mailing list archives

Re: mix of c and C++


From: sagar Guledagudda <sagu072 () gmail com>
Date: Tue, 19 Jul 2011 14:58:10 +0530

Thank you, i have solved the problem by compling with   -DHAVE_CONFIG_H flag
.
Regards
Sagar.
On Tue, Jul 19, 2011 at 11:53 AM, Helge Kruse <Helge.Kruse-nospam () gmx net>wrote:

Am 19.07.2011 07:10, schrieb sagar Guledagudda:

I am compiling it for linux ( xxx.so file )

Includes files are as below

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include<stdio.h>
#include<glib.h>
#include<epan/packet.h>
//      fastfix API
#include<fastapi.h>
#include<string.h>



CC   = g++

CFLAGS = $(INCS)  -fPIC

$(PLUGIN) : $(OBJS)
        mkdir -p $(PLUGIN_DIR)
        $(CC) -shared $(OBJS) $(LIBS)-o $@
%.o : %.cpp
        $(CC) $(CFLAGS) $(LIBS) $<  -o $@


A Unix shared library exports all non-private symbols while a Windows
dynamic link library exports only the symbols that are defined in the export
list. To access variables in the Wireshark.so you need to declare the symbol
'extern'. You need to declare the symbol as '__declspec(dllimport) extern'
to access it in the Wireshark.dll.
The config.h defines a macro WS_VAR_IMPORT with the appropriate definition.

If you don't include the config.h WS_VAR_IMPORT is not replaced with
anything and your compiler gets confused. If your curious you can check this
by *temporarily* change the actual compiler flags and replace -c by -E to
get a preprocessed source file. Look for WS_VAR_IMPORT or _NEED_VAR_IMPORT_
in that file.

To solve your problem you should define HAVE_CONFIG_H, probably with

  CFLAGS = $(INCS) -fPIC -DHAVE_CONFIG_H

But the makefiles are usually autogenerated.

@all: What is the sense behind the HAVE_CONFIG_H if I need it anyway?


______________________________**______________________________**
_______________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/**lists/wireshark-dev<http://www.wireshark.org/lists/wireshark-dev>
Unsubscribe: 
https://wireshark.org/mailman/**options/wireshark-dev<https://wireshark.org/mailman/options/wireshark-dev>
           mailto:wireshark-dev-request@**wireshark.org<wireshark-dev-request () wireshark org>
?subject=**unsubscribe

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe

Current thread: