【问题标题】:Error when building veins_inet subproject构建venes_inet 子项目时出错
【发布时间】:2017-06-06 08:59:59
【问题描述】:

在 Omnet++ 中导入静脉 4.5 项目(通过选择“搜索嵌套项目”)时,我已经导入了静脉_inet 子项目。 我已经建立了静脉并且可以运行 Erlangen 示例。

但是,我无法构建venes_inet 项目。 来源可以在这里找到:https://github.com/sommer/veins/tree/master/subprojects/veins_inet
我收到以下错误:

make MODE=debug all 
make[1]: Entering directory '/home/XX/omnetpp-5.1.1/samples/veins/subprojects/veins_inet/src'
veins_inet/VeinsInetManager.cc
veins_inet/VeinsInetManager.cc:21:41: fatal error: veins_inet/VeinsInetManager.h: No such file or directory
compilation terminated.
Makefile:97: recipe for target '../out/gcc-debug/src/veins_inet/VeinsInetManager.o' failed
make[1]: Leaving directory '/home/XX/omnetpp-5.1.1/samples/veins/subprojects/veins_inet/src'
Makefile:12: recipe for target 'all' failed
make[1]: *** [../out/gcc-debug/src/veins_inet/VeinsInetManager.o] Error 1
make: *** [all] Error 2

头文件好像没有被包含进去。

我可以通过手动将所有必要的 *.h 文件复制到 Veins_inet/src/veins_inet 文件夹并编辑 *.cc 和 *.h 文件来绕过“没有这样的文件或目录”错误,以便编译器找到所需的头文件。
我猜问题出在 Makefile 中,或者更确切地说是在生成 Makefile 的配置文件中。

veins_inet/配置:

#!/usr/bin/env python

"""
Creates Makefile(s) for building Veins_INET.
"""

import os
import sys
import subprocess
from logging import warning, error
from optparse import OptionParser


# Option handling
parser = OptionParser()
parser.add_option("--with-veins", dest="veins", help="link Veins_INET with a version of Veins installed in PATH [default: do not link with Veins]", metavar="PATH", default="../..")
parser.add_option("--with-inet", dest="inet", help="link Veins_INET with a version of the INET Framework installed in PATH [default: do not link with INET]", metavar="PATH", default="../../../inet")
(options, args) = parser.parse_args()

if args:
    warning("Superfluous command line arguments: \"%s\"" % " ".join(args))


# Start with default flags
makemake_flags = ['-f', '--deep', '--no-deep-includes', '--make-so', '-I', '.', '-o', 'veins_inet', '-O', 'out']
run_libs = [os.path.join('src', 'veins_inet')]
run_neds = [os.path.join('src', 'veins_inet')]


# Add flags for Veins
if options.veins:
    check_fname = os.path.join(options.veins, 'src/veins/package.ned')
    expect_version = '4'
    if not os.path.isfile(check_fname):
        error('Could not find Veins (by looking for %s). Check the path to Veins (--with-veins=... option) and the Veins version (should be version %s)' % (check_fname, expect_version))
        sys.exit(1)

    veins_header_dirs = [os.path.join(os.path.relpath(options.veins, 'src'), 'src')]
    veins_includes = ['-I' + s for s in veins_header_dirs]
    veins_link = ["-L" + os.path.join(os.path.relpath(options.veins, 'src'), 'src'), "-lveins"]
    veins_defs = []

    makemake_flags += veins_includes + veins_link + veins_defs
    run_libs = [os.path.relpath(os.path.join(options.veins, 'src', 'veins'))] + run_libs
    run_neds = [os.path.relpath(os.path.join(options.veins, 'src', 'veins'))] + run_neds


# Add flags for INET
if options.inet:
    fname = os.path.join(options.inet, '_scripts/get_version')
    expect_version = '3.4.0'
    try:
        print 'Running "%s" to determine INET version.' % fname
        version = subprocess.check_output(fname).strip()
        if not version == expect_version:
            warning('Unsupported INET Version. Expecting %s, found "%s"' % (expect_version, version))
        else:
            print 'Found INET version "%s". Okay.' % version
    except OSError as e:
        error('Could not determine INET Version (by running %s): %s. Check the path to INET (--with-inet=... option) and the INET version (should be version %s)' % (fname, e, expect_version))
        sys.exit(1)

    inet_header_dirs = [os.path.join(os.path.relpath(options.inet, 'src'), 'src')]
    inet_includes = ['-I' + s for s in inet_header_dirs]
    inet_link = ["-L" + os.path.join(os.path.relpath(options.inet, 'src'), 'src'), "-lINET"]
    inet_defs = ["-DINET_IMPORT"]

    makemake_flags += inet_includes + inet_link + inet_defs
    run_libs = [os.path.relpath(os.path.join(options.inet, 'src', 'INET'))] + run_libs
    run_neds = [os.path.relpath(os.path.join(options.inet, 'src'))] + run_neds


# Start creating files
if not os.path.isdir('out'):
    os.mkdir('out')

f = open(os.path.join('out', 'config.py'), 'w')
f.write('run_libs = %s\n' % repr(run_libs))
f.write('run_neds = %s\n' % repr(run_neds))
f.close()

subprocess.check_call(['env', 'opp_makemake'] + makemake_flags, cwd='src')

print 'Configure done. You can now run "make".'

veins_inet/Makefile

.PHONY: all makefiles clean cleanall doxy

# if out/config.py exists, we can also create command line scripts for running simulations
ADDL_TARGETS =
ifeq ($(wildcard out/config.py),)
else
    ADDL_TARGETS += run debug memcheck
endif

# default target
all: src/Makefile $(ADDL_TARGETS)
    @cd src && $(MAKE)

# command line scripts
run debug memcheck: % : src/scripts/%.in.py out/config.py
    @echo "Creating script \"./$@\""
    @head -n1 "$<" > "$@"
    @cat out/config.py >> "$@"
    @tail -n+2 "$<" >> "$@"
    @chmod a+x "$@"

# legacy
makefiles:
    @echo
    @echo '====================================================================='
    @echo 'Warning: make makefiles has been deprecated in favor of ./configure'
    @echo '====================================================================='
    @echo
    ./configure
    @echo
    @echo '====================================================================='
    @echo 'Warning: make makefiles has been deprecated in favor of ./configure'
    @echo '====================================================================='
    @echo

clean: src/Makefile
    cd src && $(MAKE) clean
    rm -f run debug memcheck

cleanall: src/Makefile
    cd src && $(MAKE) MODE=release clean
    cd src && $(MAKE) MODE=debug clean
    rm -f src/Makefile
    rm -f run debug memcheck

src/Makefile:
    @echo
    @echo '====================================================================='
    @echo '$@ does not exist.'
    @echo 'Please run "./configure" or use the OMNeT++ IDE to generate it.'
    @echo '====================================================================='
    @echo
    @exit 1

out/config.py:
    @echo
    @echo '====================================================================='
    @echo '$@ does not exist.'
    @echo 'Please run "./configure" to generate it.'
    @echo '====================================================================='
    @echo
    @exit 1

# autogenerated documentation
doxy:
    doxygen doxy.cfg

doxyshow: doxy
    xdg-open doc/doxy/index.html

veins_inet/src/Makefile

#
# OMNeT++/OMNEST Makefile for $(LIB_PREFIX)veins_inet
#
# This file was generated with the command:
#  opp_makemake --make-so -f --deep -KINET_PROJ=../../../../inet -KVEINS_PROJ=../../.. -L$$\(INET_PROJ\)/out/$$\(CONFIGNAME\)/src -L$$\(VEINS_PROJ\)/out/$$\(CONFIGNAME\)/src -lINET -lveins
#

# Name of target to be created (-o option)
TARGET = $(LIB_PREFIX)veins_inet$(SHARED_LIB_SUFFIX)

# C++ include paths (with -I)
INCLUDE_PATH =

# Additional object and library files to link with
EXTRA_OBJS =

# Additional libraries (-L, -l options)
LIBS = $(LDFLAG_LIBPATH)$(INET_PROJ)/out/$(CONFIGNAME)/src $(LDFLAG_LIBPATH)$(VEINS_PROJ)/out/$(CONFIGNAME)/src  -lINET -lveins

# Output directory
PROJECT_OUTPUT_DIR = ../out
PROJECTRELATIVE_PATH = src
O = $(PROJECT_OUTPUT_DIR)/$(CONFIGNAME)/$(PROJECTRELATIVE_PATH)

# Object files for local .cc, .msg and .sm files
OBJS = $O/veins_inet/VeinsInetManager.o $O/veins_inet/VeinsInetMobility.o

# Message files
MSGFILES =

# SM files
SMFILES =

# Other makefile variables (-K)
INET_PROJ=../../../../inet
VEINS_PROJ=../../..

#------------------------------------------------------------------------------

# Pull in OMNeT++ configuration (Makefile.inc)

ifneq ("$(OMNETPP_CONFIGFILE)","")
CONFIGFILE = $(OMNETPP_CONFIGFILE)
else
ifneq ("$(OMNETPP_ROOT)","")
CONFIGFILE = $(OMNETPP_ROOT)/Makefile.inc
else
CONFIGFILE = $(shell opp_configfilepath)
endif
endif

ifeq ("$(wildcard $(CONFIGFILE))","")
$(error Config file '$(CONFIGFILE)' does not exist -- add the OMNeT++ bin directory to the path so that opp_configfilepath can be found, or set the OMNETPP_CONFIGFILE variable to point to Makefile.inc)
endif

include $(CONFIGFILE)

# Simulation kernel and user interface libraries
OMNETPP_LIBS = -loppenvir$D $(KERNEL_LIBS) $(SYS_LIBS)
ifneq ($(TOOLCHAIN_NAME),clangc2)
LIBS += -Wl,-rpath,$(abspath $(INET_PROJ)/out/$(CONFIGNAME)/src) -Wl,-rpath,$(abspath $(VEINS_PROJ)/out/$(CONFIGNAME)/src)
endif

COPTS = $(CFLAGS) $(IMPORT_DEFINES)  $(INCLUDE_PATH) -I$(OMNETPP_INCL_DIR)
MSGCOPTS = $(INCLUDE_PATH)
SMCOPTS =

# we want to recompile everything if COPTS changes,
# so we store COPTS into $COPTS_FILE and have object
# files depend on it (except when "make depend" was called)
COPTS_FILE = $O/.last-copts
ifneq ("$(COPTS)","$(shell cat $(COPTS_FILE) 2>/dev/null || echo '')")
$(shell $(MKPATH) "$O" && echo "$(COPTS)" >$(COPTS_FILE))
endif

#------------------------------------------------------------------------------
# User-supplied makefile fragment(s)
# >>>
# <<<
#------------------------------------------------------------------------------

# Main target
all: $O/$(TARGET)
    $(Q)$(LN) $O/$(TARGET) .

$O/$(TARGET): $(OBJS)  $(wildcard $(EXTRA_OBJS)) Makefile $(CONFIGFILE)
    @$(MKPATH) $O
    @echo Creating shared library: $@
    $(Q)$(SHLIB_LD) -o $O/$(TARGET) $(OBJS) $(EXTRA_OBJS) $(AS_NEEDED_OFF) $(WHOLE_ARCHIVE_ON) $(LIBS) $(WHOLE_ARCHIVE_OFF) $(OMNETPP_LIBS) $(LDFLAGS)
    $(Q)$(SHLIB_POSTPROCESS) $O/$(TARGET)

.PHONY: all clean cleanall depend msgheaders smheaders

.SUFFIXES: .cc

$O/%.o: %.cc $(COPTS_FILE) | msgheaders smheaders
    @$(MKPATH) $(dir $@)
    $(qecho) "$<"
    $(Q)$(CXX) -c $(CXXFLAGS) $(COPTS) -o $@ $<

%_m.cc %_m.h: %.msg
    $(qecho) MSGC: $<
    $(Q)$(MSGC) -s _m.cc $(MSGCOPTS) $?

%_sm.cc %_sm.h: %.sm
    $(qecho) SMC: $<
    $(Q)$(SMC) -c++ -suffix cc $(SMCOPTS) $?

msgheaders: $(MSGFILES:.msg=_m.h)

smheaders: $(SMFILES:.sm=_sm.h)

clean:
    $(qecho) Cleaning...
    $(Q)-rm -rf $O
    $(Q)-rm -f $(TARGET)
    $(Q)-rm -f $(call opp_rwildcard, . , *_m.cc *_m.h *_sm.cc *_sm.h)

cleanall: clean
    $(Q)-rm -rf $(PROJECT_OUTPUT_DIR)

# include all dependencies
-include $(OBJS:%.o=%.d)

有人解决了这个问题吗?

【问题讨论】:

  • 看起来像一个标准问题,标头未安装在标准 include 目录中,或者 configure 添加为 -I 路径的任何位置 Makefile .告诉我们您猜测问题出在这些文件中是没有意义的,而不发布它们是什么。
  • 好的。添加了configure和Makefile文件的内容。
  • 我通过修改venes_inet/src/Makefile成功构建了项目,如下所示:INCLUDE_PATH = -I/home/XX/omnetpp-5.1.1/samples/veins/subprojects/veins_inet/src / -I /home/XX/omnetpp-5.1.1/samples/veins/src -I /home/XX/omnetpp-5.1.1/samples/inet/src.但是应该如何修改配置文件以反映这些更改?
  • 可能不应该,因为项目的构建设置应该按照项目的预期进行,如果你需要用其他路径做其他事情,你应该在本地覆盖而不是破解项目自己的文件。因此,您应该使用添加到您的configure 调用的站点文件或-I 参数。请参阅stackoverflow.com/questions/7467910/…,这可能(现在)是重复的。
  • 感谢您的帮助。我在以下位置添加了这些路径:右键单击 Venes_inet 项目 >> 属性 >> Omnet++(向下箭头) >> Makemake >> 选择 src:makemake .... >> 单击选项 >> 转到编译选项卡 >>包括3个必需的目录......在我的例子中:/home/XX/omnetpp-5.1.1/samples/veins/subprojects/veins_ine‌​t/src /home/XX/omnetpp-5.1.1/samples/veins/src /home/XX/omnetpp-5.1.1/samples/inet/src 这些将在编译期间添加。问题解决了。谢谢!

标签: c++ makefile omnet++ veins


【解决方案1】:

为了解决这个问题,我不得不在项目属性中添加缺少的“包含路径”:
1. 选择你的venes_inet项目并在Omnet++中点击Project&gt;&gt;Properties
2. 在新窗口中展开OMNeT++ 条目并选择Makemake
3.选择src:makemake(deep,recurse)--&gt;veins_inet(dynamic lib)
4.点击Options...按钮
它应该是这样的:Properties for veins_inet window
5. 在打开的窗口中转到Compile 标签
6.输入缺少的包含目录:

[workspace]/veins/subprojects/veins_ine‌​‌​t/src
[workspace]/veins/src
[workspace]/inet/src

你应该得到类似的结果:Makemake Options window
7. 在两个窗口中单击“确定”
8. 你应该可以无错误地构建venes_inet 项目

【讨论】:

    【解决方案2】:

    如果您使用 omnet++ 5.0 版本: IDE Project->properties->OMNET++ -> Makemake -> select src -> build makemake selected options button -> compile -> check [add all source folder under this deep makefile] :: 然后刷新构建项目..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-02
      • 2013-04-09
      相关资源
      最近更新 更多