inet-framework / inet

INET Framework for the OMNeT++ discrete event simulator
https://inet.omnetpp.org
Other
437 stars 486 forks source link

Compilation problem in windows with the precompiler headers #213

Closed aarizaq closed 7 years ago

aarizaq commented 8 years ago

File src/makefrag

The precompilation code in makefrag throws error in windows in the file parser.y

Posible solution, check operating system

ifneq ($(OS),Windows_NT)

precompiled header support for GCC and CLANG

ifeq ($(TOOLCHAIN_NAME),gcc) PRECOMPILED_EXT=gch else ifeq ($(TOOLCHAIN_NAME),clang) PRECOMPILED_EXT=pch else PRECOMPILED_EXT= endif

PRECOMPILED_HEADER=inet/common/precompiled.h PRECOMPILED_HEADER_PCH=$(PRECOMPILED_HEADER).$(PRECOMPILED_EXT) PRECOMPILED_HEADER_D=$(PRECOMPILED_HEADER_PCH:%.$(PRECOMPILED_EXT)=%.d) CFLAGS += -include $(PRECOMPILED_HEADER)

Main target

all-pch: | pch msgheaders all

.PHONY: pch clean-pch

pch : $(PRECOMPILED_HEADER_PCH)

$(PRECOMPILED_HEADER_PCH): $(PRECOMPILED_HEADER) ifneq ("$(PRECOMPILED_EXT)","") @echo Creating precompiled header for $(TOOLCHAIN_NAME)... $(Q)$(CXX) -x c++-header $(CXXFLAGS) $(COPTS) -o $@ $< endif

clean: clean-pch clean-defines

clean-pch: $(Q)-rm -f $(PRECOMPILED_HEADER_D) $(PRECOMPILED_HEADER).pch $(PRECOMPILED_HEADER).gch

-include $(PRECOMPILED_HEADER_D)

Create oppdefines.h so important WITH* macros from OMNeT++ can be included as macros from a header file

This helps the IDE to properly enable/disable conditional code in the editor

DEFINES_FILE=inet/opp_defines.h

msgheaders: $(DEFINES_FILE)

clean-defines: $(Q)-rm -f $(DEFINES_FILE)

$(DEFINES_FILE) : $(COPTS_FILE) @echo "// Generated file, do not edit" >$(DEFINES_FILE) ifeq ($(WITH_OSG),yes) @echo "#ifndef WITH_OSG" >>$(DEFINES_FILE) @echo "#define WITH_OSG" >>$(DEFINES_FILE) @echo "#endif" >>$(DEFINES_FILE) endif

dump out the actual compiler and linker command line for easier debugging

ifneq ($(MAKECMDGOALS),clean) $(info * COMPILING with:) $(info $(CXX) -c $(CXXFLAGS) $(COPTS)) $(info * LINKING with:) $(info $(SHLIB_LD) $(WHOLE_ARCHIVE_ON) $(LIBS) $(WHOLE_ARCHIVE_OFF) $(OMNETPP_LIBS) $(LDFLAGS)) $(info Compiling...) endif

endif

aarizaq commented 8 years ago

I include my modified makefrag.

#

TCP implementaion using the Network Simulation Cradle (TCP_NSC feature)

#

WITH_TCP_NSC := $(shell (cd .. && ./inet_featuretool -q isenabled TCP_NSC && echo enabled) ) ifeq ($(WITH_TCP_NSC), enabled) NSC_VERSION= $(shell ls -d ../3rdparty/nsc* 2>/dev/null | sed 's/^.*-//') ifneq ($(NSC_VERSION),) CFLAGS += -I../3rdparty/nsc-$(NSC_VERSION)/sim -DHAVE_NSC LIBS += -Wl,-rpath,abspath ../3rdparty/nsc-$(NSC_VERSION) endif endif

#

pkg-config:

# HAVE_PKGCFG := $(shell pkg-config --version 2>/dev/null) ifeq ($(strip $(HAVE_PKGCFG)),) HAVE_PKGCFG := no else HAVE_PKGCFG := yes PKGCFG := $(shell which pkg-config) endif

#

VoipStream feature:

# WITH_VOIPSTREAM := $(shell (cd .. && ./inet_featuretool -q isenabled VoIPStream && echo enabled) ) ifeq ($(WITH_VOIPSTREAM), enabled) ifeq ($(HAVE_PKGCFG), yes) HAVE_FFMPEG := $(shell $(PKGCFG) --exists libavcodec libavformat libavutil && echo yes || echo no) ifeq ($(HAVE_FFMPEG), yes) LIBS += $(shell $(PKGCFG) --libs libavcodec libavformat libavutil) CFLAGS += $(shell $(PKGCFG) --cflags libavcodec libavformat libavutil) -DHAVE_FFMPEG endif HAVE_FFMPEG_AVRESAMPLE := $(shell $(PKGCFG) --exists libavresample && echo yes || echo no) ifeq ($(HAVE_FFMPEG_AVRESAMPLE), yes) LIBS += $(shell $(PKGCFG) --libs libavresample) CFLAGS += $(shell $(PKGCFG) --cflags libavresample) -DHAVE_FFMPEG_AVRESAMPLE endif endif endif

#

visualization feature requires (optionally) some extra osg and osgEarth libraries

# WITH_VISUALIZERS := $(shell (cd .. && ./inet_featuretool -q isenabled visualization && echo enabled) ) ifeq ($(WITH_VISUALIZERS), enabled) ifeq ($(WITH_OSG), yes) LIBS += -lOpenThreads -losg -losgText -losgDB -losgEarth -losgEarthUtil endif endif

uncomment this if you want to run the NS3 vs INET 802.11 cross validation tests in the 'tests/misc/ns3' folder.

CFLAGS += -DNS3_VALIDATION

disable anoying "... hides overloaded virtual function" warning

CFLAGS += -Wno-overloaded-virtual

#########################################################################

precompiled header support for GCC and CLANG

ifneq ($(OS),Windows_NT)

ifeq ($(TOOLCHAIN_NAME),gcc) PRECOMPILED_EXT=gch else ifeq ($(TOOLCHAIN_NAME),clang) PRECOMPILED_EXT=pch else PRECOMPILED_EXT= endif

PRECOMPILED_HEADER=inet/common/precompiled.h PRECOMPILED_HEADER_PCH=$(PRECOMPILED_HEADER).$(PRECOMPILED_EXT) PRECOMPILED_HEADER_D=$(PRECOMPILED_HEADER_PCH:%.$(PRECOMPILED_EXT)=%.d) CFLAGS += -include $(PRECOMPILED_HEADER)

else

PRECOMPILED_EXT= PRECOMPILED_HEADER= PRECOMPILED_HEADER_PCH=$(PRECOMPILED_HEADER).$(PRECOMPILED_EXT) PRECOMPILED_HEADER_D=$(PRECOMPILED_HEADER_PCH:%.$(PRECOMPILED_EXT)=%.d)

endif

Main target

all-pch: | pch msgheaders all

.PHONY: pch clean-pch

pch : $(PRECOMPILED_HEADER_PCH)

$(PRECOMPILED_HEADER_PCH): $(PRECOMPILED_HEADER) ifneq ("$(PRECOMPILED_EXT)","") @echo Creating precompiled header for $(TOOLCHAIN_NAME)... $(Q)$(CXX) -x c++-header $(CXXFLAGS) $(COPTS) -o $@ $< endif

clean: clean-pch clean-defines

clean-pch: $(Q)-rm -f $(PRECOMPILED_HEADER_D) $(PRECOMPILED_HEADER).pch $(PRECOMPILED_HEADER).gch

-include $(PRECOMPILED_HEADER_D)

Create oppdefines.h so important WITH* macros from OMNeT++ can be included as macros from a header file

This helps the IDE to properly enable/disable conditional code in the editor

DEFINES_FILE=inet/opp_defines.h

msgheaders: $(DEFINES_FILE)

clean-defines: $(Q)-rm -f $(DEFINES_FILE)

$(DEFINES_FILE) : $(COPTS_FILE) @echo "// Generated file, do not edit" >$(DEFINES_FILE) ifeq ($(WITH_OSG),yes) @echo "#ifndef WITH_OSG" >>$(DEFINES_FILE) @echo "#define WITH_OSG" >>$(DEFINES_FILE) @echo "#endif" >>$(DEFINES_FILE) endif

dump out the actual compiler and linker command line for easier debugging

ifneq ($(MAKECMDGOALS),clean) $(info * COMPILING with:) $(info $(CXX) -c $(CXXFLAGS) $(COPTS)) $(info * LINKING with:) $(info $(SHLIB_LD) $(WHOLE_ARCHIVE_ON) $(LIBS) $(WHOLE_ARCHIVE_OFF) $(OMNETPP_LIBS) $(LDFLAGS)) $(info Compiling...) endif

rhornig commented 7 years ago

Hmm. Precompiled headers are supposed to work independent of operating system. 've just tried it on wondows 10 with clang and it was generated successfully. If you have files/patches please attach them as file instead of copying them into the comment because the markdown formatting makes them unusable.