I have imported the veins_inet subproject when importing the veins 4.5 project (by selecting the "Search for nested projects") in Omnet++.
I have built veins and can run the Erlangen example.
However, I cannot build the veins_inet project.
The sources can be found here: https://github.com/sommer/veins/tree/master/subprojects/veins_inet
I get the following error:
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
It seems like the header files have failed to be included.
I can bypass the "No such file or directory" errors by manually copying all necessary *.h files into the veins_inet/src/veins_inet folder and editing the *.cc and *.h files, such that the compiler finds the required header files.
I guess the issue lies in the Makefiles, or rather in the configure file, which generates the Makefiles.
veins_inet/configure:
#!/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)
Has anybody solved the issue ?
To solve the problem I had to add missing "Include Paths" to the project properties:
1. Select your veins_inet project and click Project>>Properties in Omnet++
2. In the new window expand the OMNeT++ entry and select Makemake
3. select src:makemake(deep,recurse)-->veins_inet(dynamic lib)
4. Click on the Options... button
It should look like this: Properties for veins_inet window
5. Go to the Compile tab in the window that opens
6. Enter the missing include directories:
[workspace]/veins/subprojects/veins_inet/src
[workspace]/veins/src
[workspace]/inet/src
You should end up with something similar: Makemake Options window
7. Click OK in both windows
8. You should be able to build the veins_inet project without errors
if you use omnet++ 5.0 version :
IDE Project->properties->OMNET++ -> Makemake -> select src -> build makemake selected options button -> compile -> check [add all source folders under this deep makefile] :: then refresh and build project ..
Related
I've built a number of projects with Veins on Omnet++ without issues at this stage, and I decided to implement CAM messages into a simulation. However, upon building I arrive at the following error:
12:41:23 **** Incremental Build of configuration release for project v2x ****
make MODE=release all
cd src && make make[1]: Entering directory '/home/veins/workspace.omnetpp/v2x/src'
Creating executable: ../out/clang-release/src/v2x /usr/bin/ld: cannot open output file ../out/clang-release/src/v2x: Is a directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]:
*** [Makefile:117: ../out/clang-release/src/v2x] Error 1 make[1]: Leaving directory '/home/veins/workspace.omnetpp/v2x/src'
make: *** [Makefile:2: all]
Error 2 "make MODE=release all" terminated with exit code 2.
Build might be incomplete.
12:41:24 Build Failed. 3 errors, 0 warnings. (took 549ms)
My Makefile reads:
#
# OMNeT++/OMNEST Makefile for v2x
#
# This file was generated with the command:
# opp_makemake -f --deep -KINET_PROJ=/home/veins/src/inet -KLTE_PROJ=/home/veins/src/simulte -KVEINS_INET_PROJ=/home/veins/src/veins/subprojects/veins_inet -KVEINS_PROJ=/home/veins/src/veins -DINET_IMPORT -DVEINS_IMPORT -DVEINS_INET_IMPORT -I$$\(INET_PROJ\)/src -I$$\(LTE_PROJ\)/src -I$$\(VEINS_INET_PROJ\)/src -I$$\(VEINS_PROJ\)/src -I. -L$$\(INET_PROJ\)/src -L$$\(LTE_PROJ\)/src -L$$\(VEINS_PROJ\)/src -L$$\(VEINS_INET_PROJ\)/src -lINET$$\(D\) -llte$$\(D\) -lveins$$\(D\) -lveins_inet$$\(D\)
#
# Name of target to be created (-o option)
TARGET_DIR = .
TARGET_NAME = v2x$(D)
TARGET = $(TARGET_NAME)$(EXE_SUFFIX)
TARGET_IMPLIB = $(TARGET_NAME)$(IMPLIB_SUFFIX)
TARGET_IMPDEF = $(TARGET_NAME)$(IMPDEF_SUFFIX)
TARGET_FILES = $(TARGET_DIR)/$(TARGET)
# User interface (uncomment one) (-u option)
USERIF_LIBS = $(ALL_ENV_LIBS) # that is, $(TKENV_LIBS) $(QTENV_LIBS) $(CMDENV_LIBS)
#USERIF_LIBS = $(CMDENV_LIBS)
#USERIF_LIBS = $(TKENV_LIBS)
#USERIF_LIBS = $(QTENV_LIBS)
# C++ include paths (with -I)
INCLUDE_PATH = -I$(INET_PROJ)/src -I$(LTE_PROJ)/src -I$(VEINS_INET_PROJ)/src -I$(VEINS_PROJ)/src -I.
# Additional object and library files to link with
EXTRA_OBJS =
# Additional libraries (-L, -l options)
LIBS = $(LDFLAG_LIBPATH)$(INET_PROJ)/src $(LDFLAG_LIBPATH)$(LTE_PROJ)/src $(LDFLAG_LIBPATH)$(VEINS_PROJ)/src $(LDFLAG_LIBPATH)$(VEINS_INET_PROJ)/src -lINET$(D) -llte$(D) -lveins$(D) -lveins_inet$(D)
# 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/v2x/GeneralMessageSerializer.o \
$O/v2x/VeinsInetApplicationBase.o \
$O/v2x/VeinsInetManager.o \
$O/v2x/VeinsInetManagerBase.o \
$O/v2x/VeinsInetManagerForker.o \
$O/v2x/VeinsInetMobility.o \
$O/v2x/VeinsInetSampleApplication.o \
$O/v2x/VeinsInetSampleMessageSerializer.o \
$O/v2x/GeneralMessage_m.o \
$O/v2x/VeinsInetSampleMessage_m.o
# Message files
MSGFILES = \
v2x/GeneralMessage.msg \
v2x/VeinsInetSampleMessage.msg
# SM files
SMFILES =
# Other makefile variables (-K)
INET_PROJ=/home/veins/src/inet
LTE_PROJ=/home/veins/src/simulte
VEINS_INET_PROJ=/home/veins/src/veins/subprojects/veins_inet
VEINS_PROJ=/home/veins/src/veins
#------------------------------------------------------------------------------
# Pull in OMNeT++ configuration (Makefile.inc)
ifneq ("$(OMNETPP_CONFIGFILE)","")
CONFIGFILE = $(OMNETPP_CONFIGFILE)
else
CONFIGFILE = $(shell opp_configfilepath)
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 = $(OPPMAIN_LIB) $(USERIF_LIBS) $(KERNEL_LIBS) $(SYS_LIBS)
ifneq ($(PLATFORM),win32.x86_64)
LIBS += -Wl,-rpath,$(abspath $(INET_PROJ)/src) -Wl,-rpath,$(abspath $(LTE_PROJ)/src) -Wl,-rpath,$(abspath $(VEINS_PROJ)/src) -Wl,-rpath,$(abspath $(VEINS_INET_PROJ)/src)
endif
COPTS = $(CFLAGS) $(IMPORT_DEFINES) -DINET_IMPORT -DVEINS_IMPORT -DVEINS_INET_IMPORT $(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 (if COPTS has changed since last build)
# and make the object files depend on it
COPTS_FILE = $O/.last-copts
ifneq ("$(COPTS)","$(shell cat $(COPTS_FILE) 2>/dev/null || echo '')")
$(shell $(MKPATH) "$O")
$(file >$(COPTS_FILE),$(COPTS))
endif
#------------------------------------------------------------------------------
# User-supplied makefile fragment(s)
-include makefrag
#------------------------------------------------------------------------------
# Main target
all: $(TARGET_FILES)
$(TARGET_DIR)/% :: $O/%
#mkdir -p $(TARGET_DIR)
$(Q)$(LN) $< $#
ifeq ($(TOOLCHAIN_NAME),clang-msabi)
-$(Q)-$(LN) $(<:%.dll=%.lib) $(#:%.dll=%.lib) 2>/dev/null
endif
$O/$(TARGET): $(OBJS) $(wildcard $(EXTRA_OBJS)) Makefile $(CONFIGFILE)
#$(MKPATH) $O
#echo Creating executable: $#
$(Q)$(CXX) $(LDFLAGS) -o $O/$(TARGET) $(OBJS) $(EXTRA_OBJS) $(AS_NEEDED_OFF) $(WHOLE_ARCHIVE_ON) $(LIBS) $(WHOLE_ARCHIVE_OFF) $(OMNETPP_LIBS)
.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 -MD -MP -MF $O/$(basename $<)_m.h.d $(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 $(TARGET)
$(Q)-rm -rf $O
$(Q)-rm -f $(TARGET_FILES)
$(Q)-rm -f $(call opp_rwildcard, . , *_m.cc *_m.h *_sm.cc *_sm.h)
cleanall:
$(Q)$(CLEANALL_COMMAND)
$(Q)-rm -rf $(PROJECT_OUTPUT_DIR)
help:
#echo "$$HELP_SYNOPSYS"
#echo "$$HELP_TARGETS"
#echo "$$HELP_VARIABLES"
#echo "$$HELP_EXAMPLES"
# include all dependencies
-include $(OBJS:%=%.d) $(MSGFILES:%.msg=$O/%_m.h.d)
It's correct in saying that clang-release/src/v2x is a directory, but it has always been so (even before making the recent changes) and it hasn't produced this error.
Other than the MakeFile error, there is no other error in any of the scripts for the project.
You want to create the executable file clang-release/src/v2x but you can't because that file already exists and is a directory.
The name of the file you attempt to create is
v2x$(D)$(EXE_SUFFIX) and nowhere in your Makefile do you have Make variables D or EXE_SUFFIX defined, so they evaluate to empty strings.
Probably you want to make sure you have D and EXE_SUFFIX defined somewhere.
There is a $(CONFIGFILE) you are including, Make finds it but you did not provide the text of it, check if these variables should be defined in there but are not.
This is a strange one (to me).
I'm finding that if I have a project containing multiple cpp files and I am trying to build them on a remote linux host with the Netbeans IDE, it complains about No Rule to make target for the first additional cpp file and then stops. This issue is not present when building the same project locally or when building to a remote Linux host using Netbeans on Linux.
Firstly, some points of note;
I'm using Netbeans on a Mac.
I'm remote building C++ files onto a remote linux host.
This issue only exists when there are multiple cpp files in the project.
This issue does not exist when remote building on a Linux machine.
The issue is the same whether building from the IDE or running make on the remote host.
I can build the project from the command line on the hose using g++[...]
I can only assume the issue is when Netbeans is generating the makefile variables, but for the life of me, cant seem to find where the problem lies and as I say, it's completely fine when doing the same thing on a Linux machine.
To provide some context, we can consider the following small project;
main.cpp
#include <cstdlib>
#include <stdio.h>
#include "other.h"
int main(int argc, char** argv)
{
printf ("hello %d \n",times_two(50));
return 0;
}
other.h
#ifndef OTHER_H
#define OTHER_H
int times_two(int a);
#endif /* OTHER_H */
other.h
int times_two(int a)
{
return a*2;
}
When building from the IDE to the remote Linux host, we get;
CLEAN SUCCESSFUL (total time: 212ms)
Copying project files to /home/plisken/.netbeans/remote/oracle-linux.shared/solaros.local-MacOSX-x86_64 at plisken#oracle-linux.shared
Building project files list...
Checking directory structure...
Checking previously uploaded files...
Checking links...
Uploading changed files:
Checking exec permissions...
Uploading changed files finished successfully.
cd '/home/plisken/.netbeans/remote/oracle-linux.shared/solaros.local-MacOSX-x86_64/Volumes/D_SLAVE/My Documents/My Projects/multiple_cpp_files/multiple_cpp_files'
/usr/bin/gmake -f Makefile CONF=Debug
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory '/home/plisken/.netbeans/remote/oracle-linux.shared/solaros.local-MacOSX-x86_64/Volumes/D_SLAVE/My Documents/My Projects/multiple_cpp_files/multiple_cpp_files'
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk /home/plisken/PROJECTS/bin/multiple_cpp_files
gmake[2]: Entering directory '/home/plisken/.netbeans/remote/oracle-linux.shared/solaros.local-MacOSX-x86_64/Volumes/D_SLAVE/My Documents/My Projects/multiple_cpp_files/multiple_cpp_files'
gmake[2]: *** No rule to make target '/Volumes/D_SLAVE/My Documents/My Projects/multiple_cpp_files/multiple_cpp_files/other.cpp', needed by 'build/Debug/GNU-Linux/_ext/96b75cbb/other.o'. Stop.
gmake[2]: Leaving directory '/home/plisken/.netbeans/remote/oracle-linux.shared/solaros.local-MacOSX-x86_64/Volumes/D_SLAVE/My Documents/My Projects/multiple_cpp_files/multiple_cpp_files'
gmake[1]: *** [nbproject/Makefile-Debug.mk:60: .build-conf] Error 2
gmake[1]: Leaving directory '/home/plisken/.netbeans/remote/oracle-linux.shared/solaros.local-MacOSX-x86_64/Volumes/D_SLAVE/My Documents/My Projects/multiple_cpp_files/multiple_cpp_files'
gmake: *** [nbproject/Makefile-impl.mk:40: .build-impl] Error 2
BUILD FAILED (exit value 2, total time: 224ms)
The makefiles I believe are relevant and automatically generated are as below;
makefile
#
# There exist several targets which are by default empty and which can be
# used for execution of your targets. These targets are usually executed
# before and after some main targets. They are:
#
# .build-pre: called before 'build' target
# .build-post: called after 'build' target
# .clean-pre: called before 'clean' target
# .clean-post: called after 'clean' target
# .clobber-pre: called before 'clobber' target
# .clobber-post: called after 'clobber' target
# .all-pre: called before 'all' target
# .all-post: called after 'all' target
# .help-pre: called before 'help' target
# .help-post: called after 'help' target
#
# Targets beginning with '.' are not intended to be called on their own.
#
# Main targets can be executed directly, and they are:
#
# build build a specific configuration
# clean remove built files from a configuration
# clobber remove all built files
# all build all configurations
# help print help mesage
#
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
# .help-impl are implemented in nbproject/makefile-impl.mk.
#
# Available make variables:
#
# CND_BASEDIR base directory for relative paths
# CND_DISTDIR default top distribution directory (build artifacts)
# CND_BUILDDIR default top build directory (object files, ...)
# CONF name of current configuration
# CND_PLATFORM_${CONF} platform name (current configuration)
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
#
# NOCDDL
# Environment
MKDIR=mkdir
CP=cp
CCADMIN=CCadmin
# build
build: .build-post
.build-pre:
# Add your pre 'build' code here...
.build-post: .build-impl
# Add your post 'build' code here...
# clean
clean: .clean-post
.clean-pre:
# Add your pre 'clean' code here...
.clean-post: .clean-impl
# Add your post 'clean' code here...
# clobber
clobber: .clobber-post
.clobber-pre:
# Add your pre 'clobber' code here...
.clobber-post: .clobber-impl
# Add your post 'clobber' code here...
# all
all: .all-post
.all-pre:
# Add your pre 'all' code here...
.all-post: .all-impl
# Add your post 'all' code here...
# build tests
build-tests: .build-tests-post
.build-tests-pre:
# Add your pre 'build-tests' code here...
.build-tests-post: .build-tests-impl
# Add your post 'build-tests' code here...
# run tests
test: .test-post
.test-pre: build-tests
# Add your pre 'test' code here...
.test-post: .test-impl
# Add your post 'test' code here...
# help
help: .help-post
.help-pre:
# Add your pre 'help' code here...
.help-post: .help-impl
# Add your post 'help' code here...
# include project implementation makefile
include nbproject/Makefile-impl.mk
# include project make variables
include nbproject/Makefile-variables.mk
Makefile-impl.mk
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a pre- and a post- target defined where you can add customization code.
#
# This makefile implements macros and targets common to all configurations.
#
# NOCDDL
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
# and .clean-reqprojects-conf unless SUB has the value 'no'
SUB_no=NO
SUBPROJECTS=${SUB_${SUB}}
BUILD_SUBPROJECTS_=.build-subprojects
BUILD_SUBPROJECTS_NO=
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
CLEAN_SUBPROJECTS_=.clean-subprojects
CLEAN_SUBPROJECTS_NO=
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
# Project Name
PROJECTNAME=multiple_cpp_files
# Active Configuration
DEFAULTCONF=Debug
CONF=${DEFAULTCONF}
# All Configurations
ALLCONFS=Debug Release
# build
.build-impl: .build-pre .validate-impl .depcheck-impl
##echo "=> Running $#... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf
# clean
.clean-impl: .clean-pre .validate-impl .depcheck-impl
##echo "=> Running $#... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf
# clobber
.clobber-impl: .clobber-pre .depcheck-impl
##echo "=> Running $#..."
for CONF in ${ALLCONFS}; \
do \
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \
done
# all
.all-impl: .all-pre .depcheck-impl
##echo "=> Running $#..."
for CONF in ${ALLCONFS}; \
do \
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \
done
# build tests
.build-tests-impl: .build-impl .build-tests-pre
##echo "=> Running $#... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf
# run tests
.test-impl: .build-tests-impl .test-pre
##echo "=> Running $#... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf
# dependency checking support
.depcheck-impl:
#echo "# This code depends on make tool being used" >.dep.inc
#if [ -n "${MAKE_VERSION}" ]; then \
echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES} \$${TESTOBJECTFILES}))" >>.dep.inc; \
echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
echo "include \$${DEPFILES}" >>.dep.inc; \
echo "endif" >>.dep.inc; \
else \
echo ".KEEP_STATE:" >>.dep.inc; \
echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
fi
# configuration validation
.validate-impl:
#if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
then \
echo ""; \
echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \
echo "See 'make help' for details."; \
echo "Current directory: " `pwd`; \
echo ""; \
fi
#if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
then \
exit 1; \
fi
# help
.help-impl: .help-pre
#echo "This makefile supports the following configurations:"
#echo " ${ALLCONFS}"
#echo ""
#echo "and the following targets:"
#echo " build (default target)"
#echo " clean"
#echo " clobber"
#echo " all"
#echo " help"
#echo ""
#echo "Makefile Usage:"
#echo " make [CONF=<CONFIGURATION>] [SUB=no] build"
#echo " make [CONF=<CONFIGURATION>] [SUB=no] clean"
#echo " make [SUB=no] clobber"
#echo " make [SUB=no] all"
#echo " make help"
#echo ""
#echo "Target 'build' will build a specific configuration and, unless 'SUB=no',"
#echo " also build subprojects."
#echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no',"
#echo " also clean subprojects."
#echo "Target 'clobber' will remove all built files from all configurations and,"
#echo " unless 'SUB=no', also from subprojects."
#echo "Target 'all' will will build all configurations and, unless 'SUB=no',"
#echo " also build subprojects."
#echo "Target 'help' prints this message."
#echo ""
Makefile-variables.mk
#
# Generated - do not edit!
#
# NOCDDL
#
CND_BASEDIR=`pwd`
CND_BUILDDIR=build
CND_DISTDIR=dist
# Debug configuration
CND_PLATFORM_Debug=GNU-Linux
CND_ARTIFACT_DIR_Debug=/home/plisken/PROJECTS/bin
CND_ARTIFACT_NAME_Debug=multiple_cpp_files
CND_ARTIFACT_PATH_Debug=/home/plisken/PROJECTS/bin/multiple_cpp_files
CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux/package
CND_PACKAGE_NAME_Debug=multiplecppfiles.tar
CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux/package/multiplecppfiles.tar
# Release configuration
CND_PLATFORM_Release=GNU-MacOSX
CND_ARTIFACT_DIR_Release=dist/Release/GNU-MacOSX
CND_ARTIFACT_NAME_Release=multiple_cpp_files
CND_ARTIFACT_PATH_Release=dist/Release/GNU-MacOSX/multiple_cpp_files
CND_PACKAGE_DIR_Release=dist/Release/GNU-MacOSX/package
CND_PACKAGE_NAME_Release=multiplecppfiles.tar
CND_PACKAGE_PATH_Release=dist/Release/GNU-MacOSX/package/multiplecppfiles.tar
#
# include compiler specific variables
#
# dmake command
ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \
(mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)
#
# gmake command
.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk))
#
include nbproject/private/Makefile-variables.mk
Makefile-debug.mk
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a -pre and a -post target defined where you can add customized code.
#
# This makefile implements configuration specific macros and targets.
# Environment
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
# Macros
CND_PLATFORM=GNU-Linux
CND_DLIB_EXT=so
CND_CONF=Debug
CND_DISTDIR=dist
CND_BUILDDIR=build
# Include project Makefile
include Makefile
# Object Directory
OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
# Object Files
OBJECTFILES= \
${OBJECTDIR}/_ext/96b75cbb/other.o \
${OBJECTDIR}/main.o
# C Compiler Flags
CFLAGS=
# CC Compiler Flags
CCFLAGS=
CXXFLAGS=
# Fortran Compiler Flags
FFLAGS=
# Assembler Flags
ASFLAGS=
# Link Libraries and Options
LDLIBSOPTIONS=
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk /home/plisken/PROJECTS/bin/multiple_cpp_files
/home/plisken/PROJECTS/bin/multiple_cpp_files: ${OBJECTFILES}
${MKDIR} -p /home/plisken/PROJECTS/bin
${LINK.cc} -o /home/plisken/PROJECTS/bin/multiple_cpp_files ${OBJECTFILES} ${LDLIBSOPTIONS}
${OBJECTDIR}/_ext/96b75cbb/other.o: /Volumes/D_SLAVE/My\ Documents/My\ Projects/multiple_cpp_files/multiple_cpp_files/other.cpp
${MKDIR} -p ${OBJECTDIR}/_ext/96b75cbb
${RM} "$#.d"
$(COMPILE.cc) -g -I/Volumes/D_SLAVE/My\ Documents/My\ Projects/multiple_cpp_files/multiple_cpp_files -MMD -MP -MF "$#.d" -o ${OBJECTDIR}/_ext/96b75cbb/other.o /Volumes/D_SLAVE/My\ Documents/My\ Projects/multiple_cpp_files/multiple_cpp_files/other.cpp
${OBJECTDIR}/main.o: main.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$#.d"
$(COMPILE.cc) -g -I/Volumes/D_SLAVE/My\ Documents/My\ Projects/multiple_cpp_files/multiple_cpp_files -MMD -MP -MF "$#.d" -o ${OBJECTDIR}/main.o main.cpp
# Subprojects
.build-subprojects:
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
${RM} -r ${CND_BUILDDIR}/${CND_CONF}
# Subprojects
.clean-subprojects:
# Enable dependency checking
.dep.inc: .depcheck-impl
include .dep.inc
To be clear, if I log onto the remote host where the files are and run;
g++ -o test main.cpp other.cpp
it naturally builds completely fine.
Any suggestions would be greatly appreciated.
this is the only line I changed on the make file, which is adding the "*.cpp" to the line:
SRC = $(wildcard *.c *.cpp)
and this is the clean target of the makefile:
# Target: clean project.
clean: begin clean_list end
clean_list :
#echo
#echo $(MSG_CLEANING)
$(REMOVE) $(OBJDIR)/$(TARGET).hex
$(REMOVE) $(OBJDIR)/$(TARGET).eep
$(REMOVE) $(OBJDIR)/$(TARGET).cof
$(REMOVE) $(OBJDIR)/$(TARGET).elf
$(REMOVE) $(OBJDIR)/$(TARGET).map
$(REMOVE) $(OBJDIR)/$(TARGET).sym
$(REMOVE) $(OBJDIR)/$(TARGET).lss
$(REMOVE) $(OBJ)
$(REMOVE) $(LST)
$(REMOVE) $(OBJDIR)/$(SRC:.c=.s)
$(REMOVE) $(OBJDIR)/$(SRC:.c=.d)
$(REMOVE) $(OBJDIR)/.dep/*
And when I run the makefile, it removes all my .cpp file. What did I do wrong?
Thanks in advance.
Jo
Here is the definition of OBJ and LST:
# Define all object files.
OBJ = $(addprefix $(OBJDIR)/,$(SRC:.c=.o)) $(addprefix $(OBJDIR)/,$(ASRC:.S=.o))
# Define all listing files.
LST = $(addprefix $(OBJDIR)/,$(SRC:.c=.lst)) $(addprefix $(OBJDIR)/,$(ASRC:.S=.lst))
This is the complete make file:
# Hey Emacs, this is a -*- makefile -*-
#----------------------------------------------------------------------------
# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
#
# Released to the Public Domain
#
# Additional material for this makefile was written by:
# Peter Fleury
# Tim Henigan
# Colin O'Flynn
# Reiner Patommel
# Markus Pfaff
# Sander Pool
# Frederik Rouleau
#
#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device, using avrdude.
# Please customize the avrdude settings below first!
#
# make debug = Start either simulavr or avarice as specified for debugging,
# with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
# bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------
#include conf.mk
# MCU name
MCU = atmega328p
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency. You can then use this symbol in your source code to
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
# automatically to create a 32-bit value in your source code.
F_CPU = 8000000
AVRDUDE_PROGRAMMER = stk500v1
# com1 = serial port. Use lpt1 to connect to parallel port.
AVRDUDE_PORT = /dev/cu.wchusbserial1420 # programmer connected to serial device
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
# Target file name (without extension).
TARGET = main
# List C source files here. (C dependencies are automatically generated.)
SRC = $(wildcard *.c *.cpp)
OBJDIR = Builds
# List Assembler source files here.
# Make them always end in a capital .S. Files ending in a lowercase .s
# will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line.
ASRC =
# Optimization level, can be [0, 1, 2, 3, s].
# 0 = turn off optimization. s = optimize for size.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = s
# Debugging format.
# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
# AVR Studio 4.10 requires dwarf-2.
# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
DEBUG = stabs
# List any extra directories to look for include files here.
# Each directory must be seperated by a space.
# Use forward slashes for directory separators.
# For a directory that has spaces, enclose it in quotes.
EXTRAINCDIRS =
# Compiler flag to set the C Standard level.
# c89 = "ANSI" C
# gnu89 = c89 plus GCC extensions
# c99 = ISO C99 standard (not yet fully implemented)
# gnu99 = c99 plus GCC extensions
CSTANDARD = -std=c++11
# Place -D or -U options here
CDEFS = -DF_CPU=$(F_CPU)UL
# Place -I options here
CINCS =
#---------------- Compiler Options ----------------
# -g*: generate debugging information
# -O*: optimization level
# -f...: tuning, see GCC manual and avr-libc documentation
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
# -adhlns...: create assembler listing
CFLAGS = -g$(DEBUG)
CFLAGS += $(CDEFS) $(CINCS)
CFLAGS += -O$(OPT)
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -Wall -Wstrict-prototypes
CFLAGS += -Wa,-adhlns=$(addprefix $(OBJDIR)/,$(<:.c=.lst))
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
CFLAGS += $(CSTANDARD)
CFLAGS += -gstabs
CFLAGS += -gstrict-dwarf
#---------------- Assembler Options ----------------
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create listing
# -gstabs: have the assembler create line number information; note that
# for use in COFF files, additional information about filenames
# and function names needs to be present in the assembler source
# files -- see avr-libc docs [FIXME: not yet described there]
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
# dump that will be displayed for a given single line of source input.
ASFLAGS = -Wa,-adhlns=$(addprefix $(OBJDIR)/,$(<:.S=.lst)),-gstabs,--listing-cont-lines=100
#---------------- Library Options ----------------
# Minimalistic printf version
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
# Floating point printf version (requires MATH_LIB = -lm below)
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
# If this is left blank, then it will use the Standard printf version.
PRINTF_LIB =
#PRINTF_LIB = $(PRINTF_LIB_MIN)
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
# Minimalistic scanf version
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
# If this is left blank, then it will use the Standard scanf version.
SCANF_LIB =
#SCANF_LIB = $(SCANF_LIB_MIN)
#SCANF_LIB = $(SCANF_LIB_FLOAT)
MATH_LIB = -lm
#---------------- External Memory Options ----------------
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
# used for variables (.data/.bss) and heap (malloc()).
#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
# only used for heap (malloc()).
#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
EXTMEMOPTS =
#---------------- Linker Options ----------------
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -Wl,-Map=$(OBJDIR)/$(TARGET).map,--cref
LDFLAGS += $(EXTMEMOPTS)
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
#---------------- Programming Options (avrdude) ----------------
# Programming hardware: alf avr910 avrisp bascom bsd
# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
#
# Type: avrdude -c ?
# to get a full listing.
#
AVRDUDE_WRITE_FLASH = -U flash:w:$(OBJDIR)/$(TARGET).hex
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
# Uncomment the following if you want avrdude's erase cycle counter.
# Note that this counter needs to be initialized first using -Yn,
# see avrdude manual.
#AVRDUDE_ERASE_COUNTER = -y
# Uncomment the following if you do /not/ wish a verification to be
# performed after programming the device.
#AVRDUDE_NO_VERIFY = -V
# Increase verbosity level. Please use this when submitting bug
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.
#AVRDUDE_VERBOSE = -v -v
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
# --------------------------- EDITED BY WIJOYO UTOMO ---------------------------
# This is to modify the baud rate to 19200 when using my Arduino Nano v-3.0 as my ISP programmer
AVRDUDE_FLAGS += -C 19200
#---------------- Debugging Options ----------------
# For simulavr only - target MCU frequency.
DEBUG_MFREQ = $(F_CPU)
# Set the DEBUG_UI to either gdb or insight.
# DEBUG_UI = gdb
DEBUG_UI = insight
# Set the debugging back-end to either avarice, simulavr.
DEBUG_BACKEND = avarice
#DEBUG_BACKEND = simulavr
# GDB Init Filename.
GDBINIT_FILE = __avr_gdbinit
# When using avarice settings for the JTAG
JTAG_DEV = /dev/com1
# Debugging port used to communicate between GDB / avarice / simulavr.
DEBUG_PORT = 4242
# Debugging host used to communicate between GDB / avarice / simulavr, normally
# just set to localhost unless doing some sort of crazy debugging when
# avarice is running on a different computer.
DEBUG_HOST = localhost
#============================================================================
# Define programs and commands.
SHELL = sh
CC = /usr/local/CrossPack-AVR/bin/avr-g++
OBJCOPY = /usr/local/CrossPack-AVR/bin/avr-objcopy
OBJDUMP = /usr/local/CrossPack-AVR/bin/avr-objdump
SIZE = /usr/local/CrossPack-AVR/bin/avr-size
NM = /usr/local/CrossPack-AVR/bin/avr-nm
AVRDUDE = /usr/local/CrossPack-AVR/bin/avrdude
REMOVE = rm -f
COPY = cp
WINSHELL = cmd
# Define Messages
# English
MSG_ERRORS_NONE = Errors: none
MSG_BEGIN = -------- begin --------
MSG_END = -------- end --------
MSG_SIZE_BEFORE = Size before:
MSG_SIZE_AFTER = Size after:
MSG_COFF = Converting to AVR COFF:
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
MSG_FLASH = Creating load file for Flash:
MSG_EEPROM = Creating load file for EEPROM:
MSG_EXTENDED_LISTING = Creating Extended Listing:
MSG_SYMBOL_TABLE = Creating Symbol Table:
MSG_LINKING = Linking:
MSG_COMPILING = Compiling:
MSG_ASSEMBLING = Assembling:
MSG_CLEANING = Cleaning project:
# Define all object files.
OBJ = $(addprefix $(OBJDIR)/,$(SRC:.c=.o)) $(addprefix $(OBJDIR)/,$(ASRC:.S=.o))
# Define all listing files.
LST = $(addprefix $(OBJDIR)/,$(SRC:.c=.lst)) $(addprefix $(OBJDIR)/,$(ASRC:.S=.lst))
# Compiler flags to generate dependency files.
GENDEPFLAGS = -MD -MP -MF $(OBJDIR)/.dep/$(#F).d
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
# Default target.
all: begin gccversion sizebefore clean build program sizeafter end
build: $(OBJDIR) elf hex eep lss sym
elf: $(OBJDIR)/$(TARGET).elf
hex: $(OBJDIR)/$(TARGET).hex
eep: $(OBJDIR)/$(TARGET).eep
lss: $(OBJDIR)/$(TARGET).lss
sym: $(OBJDIR)/$(TARGET).sym
$(OBJDIR):
#mkdir -p $#
# Eye candy.
# AVR Studio 3.x does not check make's exit code but relies on
# the following magic strings to be generated by the compile job.
begin:
#echo
#echo $(MSG_BEGIN)
end:
#echo $(MSG_END)
#echo
# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(OBJDIR)/$(TARGET).hex
ELFSIZE = $(SIZE) --format=avr $(OBJDIR)/$(TARGET).elf
sizebefore:
#if test -f $(OBJDIR)/$(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
2>/dev/null; echo; fi
sizeafter:
#if test -f $(OBJDIR)/$(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
2>/dev/null; echo; fi
# Display compiler version information.
gccversion :
#$(CC) --version
# Program the device.
program: $(OBJDIR)/$(TARGET).hex $(OBJDIR)/$(TARGET).eep
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
# Generate avr-gdb config/init file which does the following:
# define the reset signal, load the target file, connect to target, and set
# a breakpoint at main().
gdb-config:
#$(REMOVE) $(GDBINIT_FILE)
#echo define reset >> $(GDBINIT_FILE)
#echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
#echo end >> $(GDBINIT_FILE)
#echo file $(OBJDIR)/$(TARGET).elf >> $(GDBINIT_FILE)
#echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
ifeq ($(DEBUG_BACKEND),simulavr)
#echo load >> $(GDBINIT_FILE)
endif
#echo break main >> $(GDBINIT_FILE)
debug: gdb-config $(OBJDIR)/$(TARGET).elf
ifeq ($(DEBUG_BACKEND), avarice)
#echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
#$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
$(OBJDIR)/$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
#$(WINSHELL) /c pause
else
#$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
$(DEBUG_MFREQ) --port $(DEBUG_PORT)
endif
#$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
COFFCONVERT=$(OBJCOPY) --debugging \
--change-section-address .data-0x800000 \
--change-section-address .bss-0x800000 \
--change-section-address .noinit-0x800000 \
--change-section-address .eeprom-0x810000
coff: $(OBJDIR)/$(TARGET).elf
#echo
#echo $(MSG_COFF) $(OBJDIR)/$(TARGET).cof
$(COFFCONVERT) -O coff-avr $< $(OBJDIR)/$(TARGET).cof
extcoff: $(OBJDIR)/$(TARGET).elf
#echo
#echo $(MSG_EXTENDED_COFF) $(OBJDIR)/$(TARGET).cof
$(COFFCONVERT) -O coff-ext-avr $< $(OBJDIR)/$(TARGET).cof
# Create final output files (.hex, .eep) from ELF output file.
$(OBJDIR)/%.hex: $(OBJDIR)/%.elf
#echo
#echo $(MSG_FLASH) $#
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $#
$(OBJDIR)/%.eep: $(OBJDIR)/%.elf
#echo
#echo $(MSG_EEPROM) $#
-$(OBJCOPY) -j .eeprom --set-section-flags .eeprom=alloc,load \
--change-section-lma .eeprom=0 -O $(FORMAT) $< $#
# Create extended listing file from ELF output file.
$(OBJDIR)/%.lss: $(OBJDIR)/%.elf
#echo
#echo $(MSG_EXTENDED_LISTING) $#
$(OBJDUMP) -h -S $< > $#
# Create a symbol table from ELF output file.
$(OBJDIR)/%.sym: $(OBJDIR)/%.elf
#echo
#echo $(MSG_SYMBOL_TABLE) $#
$(NM) -n $< > $#
# Link: create ELF output file from object files.
.SECONDARY : $(OBJDIR)/$(TARGET).elf
.PRECIOUS : $(OBJ)
$(OBJDIR)/%.elf: $(OBJ)
#echo
#echo $(MSG_LINKING) $#
$(CC) $(ALL_CFLAGS) $^ --output $# $(LDFLAGS)
# Compile: create object files from C source files.
$(OBJDIR)/%.o : %.c
#echo
#echo $(MSG_COMPILING) $<
$(CC) -c $(ALL_CFLAGS) $(abspath $<) -o $#
# Compile: create assembler files from C source files.
$(OBJDIR)/%.s : %.c
$(CC) -S $(ALL_CFLAGS) $< -o $#
# Assemble: create object files from assembler source files.
$(OBJDIR)/%.o : %.S
#echo
#echo $(MSG_ASSEMBLING) $<
$(CC) -c $(ALL_ASFLAGS) $< -o $#
# Create preprocessed source for use in sending a bug report.
$(OBJDIR)/%.i : %.c
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $#
# Target: clean project.
clean: begin clean_list end
clean_list :
#echo
#echo $(MSG_CLEANING)
$(REMOVE) $(OBJDIR)/$(TARGET).hex
$(REMOVE) $(OBJDIR)/$(TARGET).eep
$(REMOVE) $(OBJDIR)/$(TARGET).cof
$(REMOVE) $(OBJDIR)/$(TARGET).elf
$(REMOVE) $(OBJDIR)/$(TARGET).map
$(REMOVE) $(OBJDIR)/$(TARGET).sym
$(REMOVE) $(OBJDIR)/$(TARGET).lss
$(REMOVE) $(OBJ)
$(REMOVE) $(LST)
$(REMOVE) $(OBJDIR)/$(SRC:.c=.s)
$(REMOVE) $(OBJDIR)/$(SRC:.c=.d)
$(REMOVE) $(OBJDIR)/.dep/*
# Include the dependency files.
-include $(shell mkdir $(OBJDIR)/.dep 2>/dev/null) $(wildcard $(OBJDIR)/.dep/*)
# Listing of phony targets.
.PHONY : all begin finish end sizebefore sizeafter gccversion \
build elf hex eep lss sym coff extcoff \
clean clean_list program debug gdb-config
Since I can't post image, I will explain my directory structure. There is a Builds sub directory that holds the .hex .eep .o .elf .lst of the build (when successful). My source files and header files are not in the Builds sub directory, but in the project directory which contains the Builds directory.
Alan Stokes is correct, except it doesn't matter what value OBJDIR has, because your clean rule is badly written. Consider this line in the clean rule:
$(REMOVE) $(OBJDIR)/$(SRC:.c=.s)
It's a common mistake to think that just by prefixing a variable with another variable, every word in the second will be prefixed by the first, but that's just not true. That's what addprefix is for (or patsubst if you prefer). The above line expands to this (assuming REMOVE is rm -f, OBJDIR is obj, and SRC is foo.c bar.c biz.c baz.c):
rm -f obj/foo.s bar.s biz.s baz.s
You can immediately see this is not what you wanted.
Now consider what happens when you add all the .cpp files, so SRC is now foo.c bar.c biz.c baz.c one.cpp two.cpp three.cpp. The substitution $(SRC:.c=.s) will replace the .c suffixes, BUT it will not touch any words that don't match the pattern. So, the command you run becomes:
rm -f obj/foo.s bar.s biz.s baz.s one.cpp two.cpp three.cpp
So you have two problems: the first is you should be using addprefix (or patsubst) to prefix all the words with the directory, and the second is you should be using the basename function to remove the suffix for all the words. There are multiple ways to do it but something like this will work:
$(REMOVE) $(patsubst %,$(OBJDIR)/%.s,$(basename $(SRC)))
And of course, you have to do the same with your rule for .d files. I strongly recommend you try it first with make -n before you let it rip for real.
I am getting an error.
One of the source files references:
#include <libxml/parser.h>
I am working with a Makefile below, trying to link:
LDFLAGS =-l../../usr/local/sys/usr/lib/libxml2.dylib
Path appears to be correct, and the file is there.
Error details from IDE:
http://clip2net.com/clip/m0/1333837472-clip-29kb.png
http://clip2net.com/clip/m0/1333837744-clip-32kb.png
What am I doing wrong?
#############################################################################
# Makefile for iPhone application (X)
#############################################################################
# Define here the name of your project's main executable, and the name of the
# build directory where the generated binaries and resources will go.
NAME = X
OUTDIR = X.app
# Define here the minimal iOS version's MAJOR number (iOS3, iOS4 or iOS5)
IOSMINVER = 5
# List here your project's resource files. They can be files or directories.
RES = Info.plist icon.png
# Define here the compile options and the linker options for your project.
CFLAGS = -W -Wall -O2 -Icocos2dx/include -Icocos2dx/platform -Icocos2dx/platform/ios -Icocos2dx/effects -Icocos2dx/cocoa -Icocos2dx/support -Icocos2dx/support/image_support -Icocos2dx/support/data_support -Icocos2dx/support/zip_support -Icocos2dx/extensions -Icocos2dx
LDFLAGS =-l../../usr/local/sys/usr/lib/libxml2.2.dylib
#############################################################################
# Except for specific projects, you shouldn't need to change anything below
#############################################################################
# Define which compiler to use and what are the mandatory compiler and linker
# options to build stuff for iOS. Here, use the ARM cross-compiler for iOS,
# define IPHONE globally and link against all available frameworks.
CC = clang
LD = link
CFLAGS += -ccc-host-triple arm-apple-darwin -march=armv6 --sysroot ../../usr/local/sys -integrated-as -fdiagnostics-format=msvc -fconstant-cfstrings -DIPHONE -D__IPHONE_OS_VERSION_MIN_REQUIRED=$(IOSMINVER)0000
LDFLAGS += -lstdc++ $(addprefix -framework , $(notdir $(basename $(wildcard /Frameworks/iOS$(IOSMINVER)/*))))
# List here your source files. The current rule means: ask the shell to build
# a one-liner list of all files in the current directory and its subdirectories
# ending with either .c, .cc, .cpp, .cxx, .m, .mm, .mx or .mxx.
SRC = $(shell find . \( -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.cxx" -o -name "*.m" -o -name "*.mm" -o -name "*.mx" -o -name "*.mxx" \) -printf '%p ')
# Define where the object files should go - currently, just aside the source
# files themselves. We take the source file's basename and just append .o.
OBJ = $(addsuffix .o, $(basename $(SRC)))
###################
# Rules definitions
# This rule is the default rule that is called when you type "make". It runs
# the specified other rules in that order: removing generated output from
# previous builds, compiling all source files into object files, linking them
# all together, codesigning the generated file, copying resources in place
# and then displaying a success message.
all: prune $(OBJ) link codesign resources checksum ipa deb end
# The following rule removes the generated output from any previous builds
prune:
#echo " + Pruning compilation results..."
#rm -f $(OUTDIR)/$(NAME)
# The following rules compile any .c/.cc/.cpp/.cxx/.m/.mm/.mx/.mxx file it
# finds in object files (.o). This is to handle source files in different
# languages: C/C++ (with .c* extension), and Objective-C (.m*).
%.o: %.c
#echo " + Compiling $<..."; $(CC) $(CFLAGS) -o $# -c $<
%.o: %.cc
#echo " + Compiling $<..."; $(CC) $(CFLAGS) -o $# -c $<
%.o: %.cpp
#echo " + Compiling $<..."; $(CC) $(CFLAGS) -o $# -c $<
%.o: %.cxx
#echo " + Compiling $<..."; $(CC) $(CFLAGS) -o $# -c $<
%.o: %.m
#echo " + Compiling $<..."; $(CC) $(CFLAGS) -o $# -c $<
%.o: %.mm
#echo " + Compiling $<..."; $(CC) $(CFLAGS) -o $# -c $<
%.o: %.mx
#echo " + Compiling $<..."; $(CC) $(CFLAGS) -o $# -c $<
%.o: %.mxx
#echo " + Compiling $<..."; $(CC) $(CFLAGS) -o $# -c $<
# The following rule first ensures the output directory exists, creates it if
# necessary, then links the compiled .o files together in that directory
link:
#echo " + Linking project files..."
#test -d $(OUTDIR) || mkdir -p $(OUTDIR)
#$(LD) $(LDFLAGS) -o $(OUTDIR)/$(NAME) $(OBJ)
# The following rule calls Saurik's ldid code pseudo-signing tool to generate
# the SHA checksums needed for the generated binary to run on jailbroken iOS.
codesign:
#echo " + Pseudo-signing code..."
#ldid -S $(OUTDIR)/$(NAME)
#rm -f $(OUTDIR)/.$(NAME).cs
# The following rule takes all the specified resource items one after the
# other (whether they are files or directories) ; files are copied in place
# and directories are recursively copied only if they don't exist already.
resources:
#echo " + Copying resources..."
#for item in $(RES); do \
if [ -d $$item ]; then test -d $(OUTDIR)/$$item || cp -r $$item $(OUTDIR)/; chmod +r $(OUTDIR)/$$item; \
else cp $$item $(OUTDIR)/; chmod +r $(OUTDIR)/$$item; \
fi; \
done
#chmod +x $(OUTDIR)
#chmod -R +r $(OUTDIR)
#chmod +x $(OUTDIR)/$(NAME)
# The following rule takes all files in the target directory and builds the
# _CodeSignature/CodeResource XML file with their SHA1 hashes.
checksum:
#echo " + Generating _CodeSignature directory..."
#echo -n APPL???? > $(OUTDIR)/PkgInfo
#codesigner $(OUTDIR) > .CodeResources.$(NAME)
#test -d $(OUTDIR)/_CodeSignature || mkdir -p $(OUTDIR)/_CodeSignature
#mv .CodeResources.$(NAME) $(OUTDIR)/_CodeSignature/CodeResources
#test -L $(OUTDIR)/CodeResources || ln -s _CodeSignature/CodeResources $(OUTDIR)/CodeResources
# The following rule builds an IPA file out of the compiled app directory.
ipa:
#echo " + Building iTunes package..."
#test -d Packages || mkdir Packages
#rm -f Packages/$(NAME).ipa
#test -d Payload || mkdir Payload
#mv -f $(OUTDIR) Payload
#cp -f iTunesArtwork.jpg iTunesArtwork
#chmod +r iTunesArtwork
#zip -y -r Packages/$(NAME).ipa Payload iTunesArtwork -x \*.log \*.lastbuildstate \*successfulbuild > /dev/null
#rm -f iTunesArtwork
#mv -f Payload/$(OUTDIR) .
#rmdir Payload
# The following rule builds a Cydia package out of the compiled app directory.
deb:
#echo " + Building Cydia package..."
#test -d Packages || mkdir Packages
#rm -f Packages/$(NAME).deb
#test -d $(NAME) || mkdir $(NAME)
#test -d $(NAME)/Applications || mkdir $(NAME)/Applications
#mv -f $(OUTDIR) $(NAME)/Applications
#test -d $(NAME)/DEBIAN || mkdir $(NAME)/DEBIAN
#cp -f cydia-package.cfg $(NAME)/DEBIAN/control
#chmod +r $(NAME)/DEBIAN/control
#echo "#!/bin/bash" > $(NAME)/DEBIAN/postinst
#echo "rm -f /Applications/$(OUTDIR)/*.log /Applications/$(OUTDIR)/*.lastbuildstate /Applications/$(OUTDIR)/*.successfulbuild" >> $(NAME)/DEBIAN/postinst
#echo "chown -R root:admin \"/Applications/$(OUTDIR)\"" >> $(NAME)/DEBIAN/postinst
#echo "find \"/Applications/$(OUTDIR)\"|while read ITEM; do if [ -d \"\$$ITEM\" ]; then chmod 755 \"\$$ITEM\"; else chmod 644 \"\$$ITEM\"; fi; done" >> $(NAME)/DEBIAN/postinst
#echo "chmod +x \"/Applications/$(OUTDIR)/$(NAME)\"" >> $(NAME)/DEBIAN/postinst
#echo "su -c /usr/bin/uicache mobile 2> /dev/null" >> $(NAME)/DEBIAN/postinst
#echo "exit 0" >> $(NAME)/DEBIAN/postinst
#chmod +r+x $(NAME)/DEBIAN/postinst
#dpkg-deb -b $(NAME) > /dev/null 2>&1
#mv -f $(NAME).deb Packages
#mv -f $(NAME)/Applications/$(OUTDIR) .
#rm -rf $(NAME)
# This simple rule displays the success message after a successful build
end:
#echo " + Done. Output directory is \"$(OUTDIR)\", iTunes package is \"Packages\$(NAME).ipa\", Cydia package is \"Packages\$(NAME).deb\"."
# This rule removes generated object files from the project and also temporary
# files ending with ~ or #.
clean:
#echo " + Cleaning project intermediate files..."
#rm -f $(OBJ) *~ *\#
#echo " + Done."
# This rule removes all generated output from any previous builds so as to
# leave an intact source tree (useful for generating source tree releases).
distclean: clean
#echo " + Cleaning project output files..."
#rm -rf $(OUTDIR)
#echo " + Done."
You actually may have two problems. I suggest you try:
Add -I../../usr/local/sys/usr/include to your CFLAGS to make it find the header.
Change the LDFLAGS to -L../../usr/local/sys/usr/lib, add LIBS=-lxml2 and change the linker invocation to $(LD) $(LDFLAGS) -o $(OUTDIR)/$(NAME) $(OBJ) $(LIBS) (i.e. add the -l at the end, the -L at the beginning of the linker command line).
-l is for specifying the library name only. Use -L to add directories where libraries will also be looked for:
LDFLAGS += -L../../usr/local/sys/usr/lib -lxml2
Hope this helps.
I'm trying to run ORTS on my Mac for a school project. It was ostensibly written to be cross-platform, but I don't know if it was ever properly tested on OSX. After a great deal of difficulty, I managed to get it to compile, but it still doesn't quite work.
When I run the ortsg application, which is the OpenGL graphical interface, the terminal output indicates that the game starts up, loads its assets and runs correctly. However, the actual game window never appears. The only possible indication of any problem is the following message:
2011-11-23 16:52:33.513 ortsg[4565:107] GLUT Warning: glutInit being called a second time.
Other than that message, all of the output is exactly the same as what I see when running on my school's Slackware Linux machines, where the game runs fine. (Unfortunately it's rather inconvenient for me to do my work on those machines, hence my attempts to run it on OSX.) I can get rid of that warning by commenting out a call to glutInit in apps/ortsg/src/ortsg_main.C, which doesn't seem to introduce any other problems, but the game window is still never shown.
I can't seem to find reports of anyone having similar problems on Google. I don't expect anyone on SO will be intimately familiar with ORTS, so my questions are as follows:
Are there any common scenarios which might cause a GLUT window to not appear, particularly on OSX?
Does GLUT provide any facilities for debugging such problems?
Edit: As requested by JimN, here is some of the GLUT initialization code...
// From apps/ortsg/src/ortsg_main.C
int main(int argc, char **argv)
{
char mydir[81];
getcwd(mydir, 80);
glutInit(&argc, argv);
chdir(mydir);
// ...
}
// From libs/gfxclient/src/GfxInit.C
void glutVisibilityDebug(int state)
{
if(state == GLUT_VISIBLE)
cout << "Window is visible" << endl;
else if(state == GLUT_NOT_VISIBLE)
cout << "Window is invisible" << endl;
else
cout << "Window state unknown";
}
void GfxModule::init_GLUT_window()
{
cerr << "INITIALIZE GLUT WINDOW" << endl;
GfxGlutAdaptor::set_client(this);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA);
// the window starts near the upper left corner of the screen
glutInitWindowPosition(opt.win_x, opt.win_y);
glutInitWindowSize(opt.win_w, opt.win_h);
// Open a window
glutCreateWindow(opt.title.c_str());
// Register the splash as the draw routing until
glutDisplayFunc (GfxGlutAdaptor::splash);
glutVisibilityFunc(glutVisibilityDebug);
if (opt.full_screen) glutFullScreen();
}
I added the glutVisibilityDebug function to see if I could determine what GLUT thinks the window's visibility state is, but none of my debug statements are ever printed. Something else just occurred to me which might help debug this. I tried at one point to replace glutDisplayFunc with a function which just printed "glutDislplayFunc called" to stderr. I noticed that the text was only printed when I quit the application.
I downloaded the daily snapshot from 26/11/2011, and then installed all dependencies using brew on my Mac.
Executed export OSTYPE=DARWIN followed by make init and make. There were several compilation problems which I fixed on this makefile:
# $Id: makefile 10648 2011-10-06 15:46:07Z mburo $
#
# This is an ORTS file (c) Michael Buro, licensed under the GPL
# This make file works for systems which use gcc
#
# - shell variable OSTYPE must be set in your shell rc file as follows:
#
# if LINUX matches uppercase($OSTYPE) => Linux
# if DARWIN matches => Mac OS X
# if CYGWIN matches => Cygwin (gcc on Windows)
# if MSYS matches => MinGW (gcc on Windows)
#
# check that value with echo $OSTYPE and set it in your shell resource
# file if above words don't match. Don't forget export OSTYPE when using sh or bash
#
# I use: OSTYPE=`uname`
#
# - ORTS_MTUNE = i686 athlon-xp pentium-m etc.
# if set, -mtune=$(ORTS_MTUNE) is added to compiler options
#
# - set GCC_PRECOMP to 1 if you want to use precompiled header files (gcc >= 3.4)
#
# - adjust SDL/X paths if necessary
#
# - for non-gcc compilers try -DHAS_TYPEOF=0 if typeof causes trouble
#
# - make MDBG=1 ... displays the entire compiler/linker invocation lines
#
# - make clean removes make generated files
# - make cleanobj removes all .o files
#
# - make [MODE=dbg] compiles targets in debug mode (no STL debug!)
#
# - make MODE=opt compiles with optimizations
#
# - make MODE=bp compiles with bprof info
#
# - make MODE=gprof compiles with gprof info
#
# - make MODE=stldbg compiles optimized stl debug version
#
# - make <app> creates application bin/<app> (omit prefix bin/ !)
# use periods in <app> in place of slashes for applications
# within subdirectories (e.g. "make rtscomp06.game2.simtest")
#
# - make list displays a list of all registered applications
#
# - make init creates necessary dep+bin+obj directories and links
#
# - make creates all applications
#
# - shell variable ORTS_MODE defines the default compile mode
# if not set, the passed MODE= parameter or dbg will be used, if MODE is not passed
# otherwise ORTS_MODE will be used
#
# issues:
#
# - all include files are used (only using library includes would be better)
#
# new:
#
# applications and libraries can now name their individual external library dependencies
# (libs + headers)
# see: apps/*/src/app.mk and libs/*/src/lib.mk, esp. libs/gfxclient/src/lib.mk
#
# todo: adjust mac/cygwin to new libary setting
# supported substrings of OSTYPE
# The following words must be uppercase
# If they are found in the uppercased OSTYPE variable
# the particular O/S matches
OSTYPE_LINUX := LINUX
OSTYPE_MAC := DARWIN
OSTYPE_CYGWIN := CYGWIN
OSTYPE_MINGW := MSYS
# convert OSTYPE to uppercase
OSTYPE := $(shell echo -n "$(OSTYPE)" | tr a-z A-Z )
#$(warning OSTYPE=$(OSTYPE))
#OSTYPE := LINUX
# -DOS_LINUX or -DOS_MAC or -DOS_CYGWIN is passed to g++
# also set: OS_LINUX, OS_CYGWIN, OS_MAC := 1 resp.
# MinGW uses OS_LINUX for now.
# tar file name
PROJ := orts
# directories to be excluded from snapshot tar file
# no longer needed SNAPSHOT_EXCLUDE := libs/mapabstr apps/mapabs apps/polypath apps/hpastar
# special targets
EXCL_INC := clean init cleanobj tar dep rmdeps list tar snapshot rpm
# libraries
#LIB_DIRS := kernel network serverclient gfxclient pathfind osl mapabstr path ortsnet ai/low dcdt/se dcdt/sr newpath
#LIB_DIRS := $(wildcard libs/*) libs/dcdt/se libs/dcdt/sr libs/ai/low
LIB_DIRS := $(wildcard libs/*/src) $(wildcard libs/*/*/src)
#$(warning LIBS $(LIB_DIRS))
# sub-projects
ifeq ("$(MAKECMDGOALS)","")
APP_DIRS := orts ortsg# built by default (do not edit)
else
APP_DIRS := $(MAKECMDGOALS)# build the passed on application
endif
FILT := $(filter $(EXCL_INC),$(MAKECMDGOALS))
ifneq ("$(FILT)","")
APP_DIRS :=
endif
#MAKECMDGOALS := compile_gch link_gch $(MAKECMDGOALS)
#$(warning making $(MAKECMDGOALS) ...)
# $(warning making $(APP_DIRS) ...)
.PHONY: all ALWAYS $(EXCL_INC) $(APP_DIRS) init
# where dependencies are stored (change also in dependency command (***) below)
#
DEP := dep
#$(error $(vp))
# make libraries and applications, make and link gch file first
all: all_end
# create tar file of the entire project
tar:
# $(MAKE) clean; cd ..; tar cfz ../$(PROJ).tgz $(PROJ)
# daily SVN snapshot
SVNROOT=svn://mburo#bodo1.cs.ualberta.ca:/all/pubsoft
snapshot:
rm -rf orts
mkdir orts
svn export $(SVNROOT)/orts/trunk orts/trunk
tar cfz $(PROJ).tgz orts
rm -rf orts
rm -rf orts_data
mkdir orts_data
svn export $(SVNROOT)/orts_data/trunk orts_data/trunk
tar cfz orts_data.tgz orts_data
rm -rf orts_data
CC := g++
CC_OPTS := -pipe -felide-constructors -fstrict-aliasing -Wno-deprecated
# -fno-merge-constants
#WARN := -Wall -W -Wundef
WARN := -Wall -W
#-Wold-style-cast
#ifneq ("$(OSTYPE)", "$(OSTYPE_MINGW)")
ifeq (,$(findstring $(OSTYPE_MINGW),$(OSTYPE)))
WARN += -Wundef
endif
OPT:=-O3
ifneq ("$(ORTS_MTUNE)","")
OPT:=$(OPT) -mtune=$(ORTS_MTUNE)
endif
OPT_FRAME := -fomit-frame-pointer
# default
AWK := gawk
EXE_SUFFIX :=
#ifeq ("$(OSTYPE)", "$(OSTYPE_MAC)")
ifneq (,$(findstring $(OSTYPE_MAC),$(OSTYPE)))
################### Mac OS X
OS_MAC := 1
MACROS := -DGCC -DOS_MAC -DHAS_TYPEOF=1 -DTRANSFORM_MOUSE_Y=0 -DMAC_OS_X_VERSION_MIN_REQUIRED=1040 -DTARGET_API_MAC_CARBON=1
USR_FRAME := /Library/Frameworks
SYS_FRAME := /System/Library/Frameworks
INC_OPTS += -I/usr/local/Cellar/sdl/1.2.14/include/SDL \
-I/usr/local/Cellar/sdl_net/1.2.7/include/SDL \
-I/usr/local/Cellar/glew/1.7.0/include/GL \
-I/usr/include/GL \
-L$(USR_FRAME) -L$(SYS_FRAME) -L/usr/local/Cellar/sdl/1.2.14/lib -L/usr/local/Cellar/sdl_net/1.2.7/lib -L/usr/local/lib
SHARED_LIBS0 := -lc -lz -lpthread \
-lSDL \
-lSDL_net \
-lSDLmain \
-framework Foundation \
-framework AppKit
AWK := awk
#WARN += -Wno-long-double
ifeq ("$(CPU)", "G5")
OPT += -mcpu=970 -mpowerpc64
endif
else
################### MinGW
#ifeq ("$(OSTYPE)", "$(OSTYPE_MINGW)")
ifneq (,$(findstring $(OSTYPE_MINGW),$(OSTYPE)))
OS_LINUX := 1
MACROS := -DOS_LINUX -DGCC -D_WIN32=1 -DTRANSFORM_MOUSE_Y=1 -DHAS_TYPEOF=1
MACROS += -DGLUT_NO_LIB_PRAGMA -DGLUT_NO_WARNING_DISABLE
INC_OPTS += -I/mingw/include/GL -I/local/include
SHARED_LIBS0 := -lm -lzlib1 -lmingw32 -lSDLmain -lSDL -lSDL_net -lpthreadGC2 -lstdc++
else
################### Linux | Cygwin
MACROS := -DGCC -DTRANSFORM_MOUSE_Y=1 -DHAS_TYPEOF=1
INC_OPTS += -I$(HOME)/include -I$(HOME)/include/GL -I/usr/include -I/usr/include/SDL -I/usr/local/include/SDL -I$(HOME)/usr/local/include/GL
# -I/home/dsk06/cscrs/c399/c399-software/include
#ifeq ("$(OSTYPE)", "$(OSTYPE_LINUX)")
ifneq (,$(findstring $(OSTYPE_LINUX),$(OSTYPE)))
################### Linux
OS_LINUX := 1
MACROS += -DOS_LINUX
#SHARED_LIBS0 += -L/usr/lib -L/usr/local/lib -L/usr/X11R6/lib -lm -lz -lSDLmain -lSDL -lSDL_net -lpthread -lGL -lGLU -lXi -lXmu -lglut -lGLEW $(MODEL_LIBS) -lstdc++
#SHARED_LIBS0 += -L$(HOME)/lib -lm -lz -lSDLmain -lSDL -lSDL_net -lpthread -lstdc++
SHARED_LIBS0 += -L$(HOME)/lib -lm -lz -lSDL -lSDL_net -lpthread -lstdc++
# -lefence
else
#ifeq ("$(OSTYPE)", "$(OSTYPE_CYGWIN)")
ifneq (,$(findstring $(OSTYPE_CYGWIN),$(OSTYPE)))
################## Cygwin
OS_CYGWIN := 1
EXE_SUFFIX:=.exe
MACROS += -DOS_CYGWIN -DSTDC_HEADERS=1 -DGLUT_IS_PRESENT=1
#-mno-cygwin
#INC_OPTS += -I/usr/include/mingw -I/usr/include/mingw/GL -I/usr/include
#$(warning "INC_OPTS=" $(INC_OPTS))
# fixme: /lib/SDL_main.o -> -lSDLmain (didn't get SDL to compile on Cygwin)
# adjust paths if necessary
SHARED_LIBS0 := -lSDL -lSDL_net -lpthread -lz -lstdc++
# GLEW not checked under cygwin!
else
# unknown OSTYPE
$(error "!!!!! unknown OSTYPE=$(OSTYPE) !!!!")
endif
endif
endif
endif
# default mode; if ORTS_MODE set, use it
# otherwise use MODE if passed, or dbg otherwise
ifeq ("$(ORTS_MODE)", "")
MODE := dbg
else
MODE := $(ORTS_MODE)
endif
OBJ_DIR := obj
CONFIG := config
SHARED_PROF_LIBS := $(SHARED_LIBS0)
SHARED_BP_LIBS := ~/lib/bmon.o $(SHARED_LIBS0)
OBJ_OPT := $(OBJ_DIR)/opt
OBJ_DBG := $(OBJ_DIR)/dbg
OBJ_SDBG := $(OBJ_DIR)/stldbg
OBJ_PROF:= $(OBJ_DIR)/prof
OBJ_BP := $(OBJ_DIR)/bp
OFLAGS := $(WARN) $(OPT) $(OPT_FRAME) # !!! -g added for 2007 competition
DFLAGS := $(WARN) -g -ggdb # -ftrapv
SDFLAGS := $(WARN) -g -ggdb -O -D_GLIBCXX_DEBUG # STL debug mode is SLOW!
PFLAGS := $(WARN) $(OPT) -pg -O
BPFLAGS := $(WARN) -g -ggdb -O2
ifeq ("$(MODE)", "opt")
FLAGS := $(OFLAGS) -DNDEBUG -Wuninitialized
#-DSCRIPT_DEBUG
STRIP := strip
OBJ := $(OBJ_OPT)
SHARED_LIBS := $(SHARED_LIBS0)
else
ifeq ("$(MODE)", "gprof")
FLAGS := $(PFLAGS) -DNDEBUG -Wuninitialized
STRIP := echo
OBJ := $(OBJ_PROF)
SHARED_LIBS := $(SHARED_PROF_LIBS)
else
ifeq ("$(MODE)", "bp")
FLAGS := $(BPFLAGS) -DNDEBUG -Wuninitialized
STRIP := echo
OBJ := $(OBJ_BP)
SHARED_LIBS := $(SHARED_BP_LIBS)
else
ifeq ("$(MODE)", "dbg")
FLAGS := $(DFLAGS)
STRIP := echo
OBJ := $(OBJ_DBG)
SHARED_LIBS := $(SHARED_LIBS0)
else
ifeq ("$(MODE)", "stldbg")
FLAGS := $(SDFLAGS)
STRIP := echo
OBJ := $(OBJ_SDBG)
SHARED_LIBS := $(SHARED_LIBS0)
else
# unknown MODE
$(error "!!!!! unknown MODE=$(MODE) !!!!")
endif
endif
endif
endif
endif
CCOPTS = $(CC_OPTS) $(MACROS) $(FLAGS) $(INC_OPTS) -DBOOST_STRICT_CONFIG
# -m32 for 32-bit applications
LD := $(CC) $(CCOPTS)
LDOPTS := $(FLAGS)
# line prefix
ifeq ("$(MDBG)", "")
VERBOSE=#
else
VERBOSE=
endif
# how to generate precompiled header file if GCC_PRECOMP=1
# otherwise, create dummy file
ALLH := All.H
ALLGCH := $(ALLH).gch
ALLGCHMODE := $(ALLGCH).$(MODE)
ifeq ("$(GCC_PRECOMP)", "1")
$(CONFIG)/$(ALLGCHMODE) : $(CONFIG)/$(ALLH)
# rm -rf $(CONFIG)/$(ALLGCH)
# echo "compile gch file"
$(VERBOSE) $(CC) $(CCOPTS) -c -o xxx1 $<
# mv xxx1 $#
# echo "link gch file"
$(VERBOSE) cd $(CONFIG); ln -sf $(ALLGCHMODE) $(ALLGCH)
else
$(CONFIG)/$(ALLGCHMODE) : $(CONFIG)/$(ALLH)
# echo "DUMMY GCH FILE"
$(VERBOSE) touch $#
endif
# link gch file to gchmode file
# depends on compiled header file
ifeq ("$(GCC_PRECOMP)", "1")
link_gch:
# echo "link gch file"
$(VERBOSE) cd $(CONFIG); ln -sf $(ALLGCHMODE) $(ALLGCH)
else
link_gch:
# echo "remove gch file"
# cd config ; rm -f $(ALLGCHMODE) $(ALLGCH)
endif
#===================================================================
# how to create dependency files
# add depfile (.d) as dependent file
# (***) (can't use $(DEP) in sed command because it contains / - so if DEP changes edit this line!
# also prepend object path for .o file
#
DEP_EXEC = $(VERBOSE) set -e; $(CC) -MM $(CCOPTS) $(INC_OPTS) $< | sed 's/$*\.o[ :]*/$(subst /,.,$(basename $<)).o dep\/$(#F) : /g' | $(AWK) '{ if (index($$1,".o") > 0) { print "$$(OBJ)/" $$0 ; } else { print $$0; } }' > $#; [ -s $# ] || rm -f $#OB
# how to compile source files
#
COMP_EXEC = $(VERBOSE) $(CC) $(CCOPTS) -c -o $# `pwd`/$<
#-------------------------------------
define create_sublib_rules2
$$(OBJ)/libs.$(subst /,.,$1).src.%.o : libs/$1/src/%.$2
# echo "comp($$(MODE)):" $$<
$$(COMP_EXEC)
$$(DEP)/libs.$(subst /,.,$1).src.%.d : libs/$1/src/%.$2
# echo dep: $$<
$$(DEP_EXEC)
endef
define create_sublib_rules
$(foreach ext,C c cpp m,$(eval $(call create_sublib_rules2,$1,$(ext))))
endef
#-------------------------------------
define create_subapp_rules2
$$(OBJ)/apps.$1.src.%.o : apps/$(subst .,/,$1)/src/%.$2
# echo "comp($$(MODE)):" $$<
$$(COMP_EXEC)
$$(DEP)/apps.$1.src.%.d : apps/$(subst .,/,$1)/src/%.$2
# echo dep: $$<
$$(DEP_EXEC)
endef
define create_subapp_rules
$(foreach ext,C c cpp,$(eval $(call create_subapp_rules2,$1,$(ext))))
endef
#===================================================================
# collect all source files, replace suffix by .o, and filter out *_main.o
# input: FILES
# output: O_FILES
define create_O_FILES
#FILES := $$(notdir $$(FILES))
C_FILES := $$(filter %.C, $$(FILES))
c_FILES := $$(filter %.c, $$(FILES))
cpp_FILES := $$(filter %.cpp, $$(FILES))
m_FILES :=
ifeq ("$(OSTYPE)","$(OSTYPE_MAC)")
#ifneq (,$(findstring $(OSTYPE_MAC),$(OSTYPE)))
m_FILES := $$(filter %.m, $$(FILES))
endif
O_FILES := $$(C_FILES:.C=.o) $$(c_FILES:.c=.o) $$(cpp_FILES:.cpp=.o) $$(m_FILES:.m=.o)
O_FILES := $$(subst /,.,$$(O_FILES))
O_FILES := $$(filter-out %_main.o, $$(O_FILES))
endef
# include all applications and dependencies (uses SHARED_LIBS for linking)
APP_SDIRS := $(subst .,/,$(APP_DIRS))
ifneq ("$(APP_DIRS)","")
#include $(patsubst %, apps/%/src/app.mk, $(APP_DIRS))
include $(patsubst %, apps/%/src/app.mk, $(APP_SDIRS))
endif
#$(warning lib_dirs="$(LIB_DIRS)")
vp := $(patsubst %, apps/%/src, $(APP_SDIRS)) \
$(patsubst %, libs/%/src, $(APP_LIBS)) \
# $(LIB_DIRS)
#vp := $(patsubst %, %/src, $(LIB_DIRS)) \
# $(patsubst %, apps/%/src, $(APP_DIRS))
INC_OPTS += -Iconfig $(addprefix -I, $(vp))
# new
INC_OPTS += $(LIB_EXT_HD) $(APP_EXT_HD)
# $(warning INC_OPTS= $(INC_OPTS))
# where source files are searched
#$(warning vp="$(vp)")
vpath %.C $(vp)
vpath %.c $(vp)
vpath %.cpp $(vp)
vpath %.m $(vp)
all_end: link_gch $(APP_DIRS)
cleanobj:
rm -f $(OBJ_OPT)/*
rm -f $(OBJ_DBG)/*
rm -f $(OBJ_SDBG)/*
rm -f $(OBJ_PROF)/*
rm -f $(OBJ_BP)/*
clean:
( rm -f bin/*; exit 0)
rm -f $(DEP)/*
rm -f $(OBJ_OPT)/*
rm -f $(OBJ_DBG)/*
rm -f $(OBJ_SDBG)/*
rm -f $(OBJ_PROF)/*
rm -f $(OBJ_BP)/*
rm -f $(CONFIG)/*.gch*
rm -rf misc/doxygen/html
find . -name "*.bprof" -exec rm -f '{}' \;
find . -name ".ui" -exec rm -f '{}'/* \;
find . -name ".moc" -exec rm -f '{}'/* \;
rmdeps:
# rm -f $(DEP)/
rpm:
cd misc/pkgs/fc7; ./makerpm; cd ../../..
# create dependency, object directories
# doesn't touch links (pointing to fast local partitions)
init:
# echo "create directories"
# config/create_dir bin
# config/create_dir $(DEP)
# config/create_dir $(OBJ_DIR)
# config/create_dir $(OBJ_OPT)
# config/create_dir $(OBJ_DBG)
# config/create_dir $(OBJ_SDBG)
# config/create_dir $(OBJ_PROF)
# config/create_dir $(OBJ_BP)
# # ln -s ../../orts_data/trunk orts_data
# (cd libs/pathfinding/dcdt; ./makelinks; exit 0) > /dev/null 2>&1
Then some changes I had to do manually, to fix errors like:
sr_bv_math.cpp:561: error: ‘isnan’ was not declared in this scope
Edit the file trunk/libs/pathfinding/dcdt/sr/src/sr_bv_math.cpp and right after the cmath include, declare isnan as extern:
#include <cmath>
extern "C" int isnan(double);
That compiled the binaries, but then I had to also download orts_data.tgz to run the applications.
Well, running ortsg for the very first time failed, reporting:
texture size = 64X64
REMARK: can't open file: testgame/ortsg/terrain.tga
REMARK: can't open file: testgame/ortsg/noise.tga
Unable to load terrain noise texture testgame/ortsg/noise.tga
ERROR: /Users/karlphillip/installers/orts/orts/trunk/libs/gfxclient/src/GfxTerrain.C GfxTerrain() (line 213): failed to load noise image testgame/ortsg/noise.tga
REMARK: closing connection
REMARK: !!! already closed
REMARK: ~IO_Buffer called
Even though the files are there. So I KILLED the application and tried it again:
2011-11-27 01:51:02.947 ortsg[390:903] GLUT Warning: glutInit being called a second time.
seed=1322365862
ERROR: /Users/karlphillip/installers/orts/orts/trunk/libs/network/src/TCP_Client.C connect() (line 27): can't connect
REMARK: mixer not open
REMARK: closing connection
REMARK: !!! already closed
/Users/karlphillip/installers/orts/orts/trunk/libs/network/src/TCP_Client.C connect() (line 27): can't connect
Abort trap
The first line of the error might be familiar to you. Even though the app was killed, something seems to be left hanging somewhere, and the only way I found to bypass the error and have a clean run of the application was rebooting my computer.
It seems this application has issues on Mac OS X and need immediate fixing. I suggest you install a Linux VM, or even a Windows VM inside your Mac to be able to run orts, if you really have to use it.