I download the dense trajectory project of Inria and I try to compile it on my mac. https://lear.inrialpes.fr/people/wang/download/dense_trajectory_release_v1.2.tar.gz
I got a problem when using make the error I have is :
=== linking: release/DenseTrack ===
c++ -L/opt/lib -pipe -Wall -O3 -ggdb -o release/DenseTrack -lopencv_core -lopencv_highgui -lopencv_video -lopencv_imgproc -lavformat -lavdevice -lavutil -lavcodec -lswscale
ld: warning: directory not found for option '-L/opt/lib'
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [release/DenseTrack] Error 1
I followed the README and installed opencv and ffmpeg.
Does someone know how to handle this kind of error ?
** Edit **
the first warning was due to the compiler searching for my opencv lib directory, but the error of undefined symbol is still present:
=== linking: release/DenseTrack ===
c++ -L/usr/local/Cellar/opencv/3.4.1_5/lib -pipe -Wall -O3 -ggdb -o release/DenseTrack -lopencv_core -lopencv_highgui -lopencv_video -lopencv_imgproc -lavformat -lavdevice -lavutil -lavcodec -lswscale
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [release/DenseTrack] Error 1
the makefile of Inria :
# set the binaries that have to be built
TARGETS := DenseTrack Video
# set the build configuration set
BUILD := release
#BUILD := debug
# set bin and build dirs
BUILDDIR := .build_$(BUILD)
BINDIR := $(BUILD)
# libraries
LDLIBS = $(addprefix -l, $(LIBS) $(LIBS_$(notdir $*)))
LIBS := \
opencv_core opencv_highgui opencv_video opencv_imgproc \
avformat avdevice avutil avcodec swscale
# set some flags and compiler/linker specific commands
CXXFLAGS = -pipe -D __STDC_CONSTANT_MACROS -D STD=std -Wall $(CXXFLAGS_$(BUILD)) -I. -I/opt/include
CXXFLAGS_debug := -ggdb
CXXFLAGS_release := -O3 -DNDEBUG -ggdb
LDFLAGS = -L/usr/local/Cellar/opencv/3.4.1_5/lib -pipe -Wall $(LDFLAGS_$(BUILD))
LDFLAGS_debug := -ggdb
LDFLAGS_release := -O3 -ggdb
include make/generic.mk
the generic.mk is :
#
# Copyright (C) 2009 Alexander Kl"aser
#
# This piece is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# This software has been downloaded from:
# http://lear.inrialpes.fr/people/klaeser/software
#
#
# Variables that need to be set in the Makefile that includes this file:
# TARGETS all files that are exectuables without there .cpp extension
# BUILDDIR temporary dir where things are compiled to (optional, by default ".build")
# BINDIR dir where executables are linked to (optional, by default "bin")
# SRCDIRS list of directories in which source files are located
# this variable needs to be set if you do not have your source and
# include files located in the same directory!
#
# Variables used for compiling/linking:
# CXXFLAGS flags for compiling
# LDFLAGS flags used for linking
# LDLIBS list of libraries to be linked
# CXX compiler linker (should be g++ by default)
#
# set paths for the dependency tool and gcc
DEP = make/dep.py
# set some standard directories in case they have not been set
BUILDDIR ?= .build
BINDIR ?= bin
# all include files
INCLUDES := $(addprefix $(BUILDDIR)/,$(TARGETS:=.l))
#
# some general rules
#
.PHONY: all clean
.PRECIOUS: $(BUILDDIR)/%.d
all: $(BINDIR) $(addprefix $(BINDIR)/,$(notdir $(TARGETS)))
#echo "=== done ==="
$(INCLUDES): $(BUILDDIR)
clean:
#echo "=== cleaning up ==="
#rm -rf $(BUILDDIR)
$(BUILDDIR) $(BINDIR):
#echo "=== creating directory: $# ==="
#mkdir -p $#
#
# rules for creating dependency files
#
# dependencies of .cpp files on other files
$(BUILDDIR)/%.d: %.cpp
#echo "=== creating dependency file: $# ==="
#test -e $(dir $#) || mkdir -p $(dir $#)
g++ $(CXXFLAGS) -MM -MT $(BUILDDIR)/$*.o -MT $(BUILDDIR)/$*.d -MF $# $<
# dependencies for the linking
%.so.l %.l: %.d
#echo "=== creating dependency file: $# ==="
#test -e $(dir $#) || mkdir -p $(dir $#)
$(DEP) "$(BINDIR)/$(#F:.l=)" $*.l $(BUILDDIR) $< $(SRCDIRS) > $#
#
# rules for compiling and linking
# (link dependencies are defined in .l files)
#
# compiling
$(BUILDDIR)/%.o: %.cpp
#echo "=== compiling: $# ==="
#test -e $(dir $#) || mkdir -p $(dir $#)
$(CXX) -fPIC $(CXXFLAGS) -c -o $# $<
# linking for shared libraries
$(BINDIR)/%.so:
#echo "=== linking: $# ==="
#rm -f $#
$(CXX) -shared $(LDFLAGS) -o $# $(filter %.o, $^) $(LDLIBS)
# linking
$(BINDIR)/%:
#echo "=== linking: $# ==="
#rm -f $#
$(CXX) $(LDFLAGS) -o $# $(filter %.o, $^) $(LDLIBS)
%: %.o
%.h: ;
%.hpp: ;
%.c: ;
%.cpp: ;
#
# include dependency files
#
ifneq ($(MAKECMDGOALS),clean)
-include $(INCLUDES)
endif
When I do make there is the error because no main is found and so the binary files isn't created in the released directory, when I do make DenseTrack.cpp
there is no error but nothing is done.
Thanks.
First, find where you actually installed the OpenCV libraries. So, let's take libopencv_core.dylib and look for it in a bunch of likely places, i.e. $HOME, /usr and /opt:
find $HOME /usr /opt -name libopencv_core.dylib
Sample Output
/Users/mark/OpenCV/lib/libopencv_core.dylib
Now we know where it is (on my system), so we can tell the linker:
c++ -L/Users/mark/OpenCV/lib ...
Related
I have created the following makefile with reference to this site to try out automatic dependency generation. My makefile works fine when I run it with GNU Make 3.81(the one that comes with macOS). However, if I run it with the newer version of GNU Make(4.3, installed via Homebrew), all the objects and dependency files get recreated every single time when I run make, even though there is no change in the source files.
CXX := clang++
CXXFLAGS := -Wall -Werror -std=c++11
ICUROOT := ${HOME}/opt/icu4c
XERCESCROOT := ${HOME}/opt/xercesc
CPPFLAGS := -I$(ICUROOT)/include -I$(XERCESCROOT)/include
LDFLAGS := -lxerces-c -licuuc
LDLIBS := -L$(ICUROOT)/lib -L$(XERCESCROOT)/lib
OBJDIR := obj
DEPDIR := $(OBJDIR)/.deps
DEPFLAGS = -MT $# -MMD -MP -MF $(DEPDIR)/$*.d
SRCS = $(wildcard *.cpp)
.PHONY: all
all: DOMPrint
COMPILE.cc = $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
$(OBJDIR)/%.o: %.cpp
$(OBJDIR)/%.o: %.cpp $(DEPDIR)/%.d | $(DEPDIR)
$(COMPILE.cc) $(OUTPUT_OPTION) $<
$(DEPDIR): ; #mkdir -p $#
DEPFILES := $(SRCS:%.cpp=$(DEPDIR)/%.d)
$(DEPFILES): ;
DOMPrint: $(addprefix $(OBJDIR)/,DOMPrint.o DOMPrintFilter.o DOMPrintErrorHandler.o DOMTreeErrorReporter.o)
$(CXX) $(CXXFLAGS) $(LDLIBS) $(LDFLAGS) -o $# $^
-include $(wildcard $(DEPFILES))
Debugging information printed from make --debug(partial), it shows that the dependency file is newer than the target, and the object file is rebuilt:
GNU Make 4.3
Built for arm-apple-darwin21.1.0
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
Updating goal targets....
File 'all' does not exist.
Prerequisite 'obj/.deps/DOMPrintErrorHandler.d' is newer than target 'obj/DOMPrintErrorHandler.o'.
Must remake target 'obj/DOMPrintErrorHandler.o'.
clang++ -MT obj/DOMPrintErrorHandler.o -MMD -MP -MF obj/.deps/DOMPrintErrorHandler.d -Wall -Werror -std=c++11 -I/Users/chunwaichan/opt/icu4c/include -I/Users/chunwaichan/opt/xercesc/include -c -o obj/DOMPrintErrorHandler.o DOMPrintErrorHandler.cpp
Successfully remade target file 'obj/DOMPrintErrorHandler.o'.
...
However, looking at the last modified time in make -p output below(partial), the dependency file isn't newer than the object file, but the automatic variable ? does show that it is newer.
obj/DOMPrintErrorHandler.o: DOMPrintErrorHandler.cpp obj/.deps/DOMPrintErrorHandler.d ...
# Implicit rule search has been done.
# Implicit/static pattern stem: 'DOMPrintErrorHandler'
# Last modified 2022-01-08 10:50:25.517904773
# File has been updated.
# Successfully updated.
# automatic
# ? := obj/.deps/DOMPrintErrorHandler.d
obj/.deps/DOMPrintErrorHandler.d:
# Implicit rule search has not been done.
# Last modified 2022-01-08 09:45:13.890973263
# File has been updated.
# Successfully updated.
# recipe to execute (from 'Makefile', line 32):
I have tested this makefile with GNU Make 3.81 till 4.3, starting from version 4.0, this issue happens. I would like to know what change/enhancement in the newer version of GNU Make has caused this issue and how can I fix my makefile to make it compatible.
I can't reproduce the behavior you see with the standard version of GNU make on my GNU/Linux system. Here is a complete repro case that I used:
$ cat main.h
#define RET 0
$ cat main.cpp
#include "main.h"
int main() { return RET; }
$ cat Makefile
CXX := g++
CXXFLAGS := -Wall -Werror -std=c++11
CPPFLAGS := -I.
OBJDIR := obj
DEPDIR := $(OBJDIR)/.deps
DEPFLAGS = -MT $# -MMD -MP -MF $(DEPDIR)/$*.d
COMPILE.cc = $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
SRCS = $(wildcard *.cpp)
OBJS = $(SRCS:%.cpp=$(OBJDIR)/%.o)
DEPS = $(SRCS:%.cpp=$(DEPDIR)/%.d)
all: main
$(OBJDIR)/%.o: %.cpp
$(OBJDIR)/%.o: %.cpp $(DEPDIR)/%.d | $(DEPDIR) ; $(COMPILE.cc) $(OUTPUT_OPTION) $<
$(DEPDIR): ; #mkdir -p $#
$(DEPS): ;
main: $(OBJS) ; $(CXX) $(CXXFLAGS) $(LDLIBS) $(LDFLAGS) -o $# $^
clean: ; rm -rf obj main
-include $(wildcard $(DEPS))
$ make
g++ -MT obj/main.o -MMD -MP -MF obj/.deps/foo.d -Wall -Werror -std=c++11 -I. -c -o obj/main.o main.cpp
g++ -Wall -Werror -std=c++11 -o main obj/main.o
$ make
make: Nothing to be done for 'all'.
Also something odd: the output of my make -p does not show any automatic variables, as are shown in your example:
obj/main.o: main.cpp obj/.deps/main.d main.cpp main.h | obj/.deps
# Implicit rule search has been done.
# Implicit/static pattern stem: 'main'
# Last modified 2022-01-08 14:18:05.5745307
# File has been updated.
# Successfully updated.
# recipe to execute (from 'Makefile', line 19):
$(COMPILE.cc) $(OUTPUT_OPTION) $<
Maybe the version of GNU make you are using has some local changes?
If you download the vanilla GNU make source from https://ftp.gnu.org/gnu/make/ and compile that does it work properly?
Makefile specified in this question, compiling all the cpp programs in a folder but not with python embedded cpp programs.
all: myUB
sourcesC := $(wildcard ../src/*.cpp)
objectsC := $(patsubst %.cpp,%.o,$(sourcesC))
INPATH=-I"C:/Python27/include"
LIBPATH=-L"C:/Python27/libs"-lpython27
myUB:
#echo 'Building target $#'
g++ -O0 -Wall -c -g3 -fmessage-length=0 \
$(sourcesC)
del *.o
clean:
Your final makefile could look somthing like:
all: myUB
sourcesC := $(wildcard ../src/*.cpp)
# Not used
#objectsC := $(patsubst %.cpp,%.o,$(sourcesC))
INC = -IC:\Python27\include
LIBS = -LC:\Python27\libs -lpython27
myUB:
#echo 'Building target $#'
g++ -O0 -Wall -g3 -fmessage-length=0 -o myprog.out $(sourcesC) $(INC) $(LIBS)
clean:
rm myprog.out
update
For the undefined ref to WinMain(), it means the linker can't find this function in your code. Either you need to include a library/object that contains it or you can define it yourself in a cpp file like:
#include <windows.h>
int WINAPI (*MyDummyReferenceToWinMain)(HINSTANCE hInstance, ..., int
nShowCmd ) = &WinMain;
I got the function template from here.
But this seems to mean that you are creating a windows application instead of a console app which uses int main(...) entry point.
Update2
I have made a new makefile to do what you have asked for in your latest comment which seems to be to create one executable per source file - I am assuming each source file has its own main.
# Build vars
CXX = g++
CXX_FLAGS = -O0 -Wall -g3
INC = -IC:\Python27\includ
LIBS = -LC:\Python27\libs -lpython27
# Sources
SRC_DIR=src
SOURCES = $(wildcard $(SRC_DIR)/*.cpp)
$(info SOURCES: $(SOURCES))
# Executables
EXE_DIR=bin
EXECUTABLES = $(subst $(SRC_DIR)/,$(EXE_DIR)/,$(subst cpp,out,$(SOURCES)))
$(info EXECUTABLES: $(EXECUTABLES))
$(info ----)
# Directories
DIRS = $(EXE_DIR)
# Rule to create folders and compile executables
all: $(DIRS) $(EXECUTABLES)
# Pattern rule to build each executable
$(EXE_DIR)/%.out : $(SRC_DIR)/%.cpp
#echo "compiling $< --> $#"
#$(CXX) $(CXX_FLAGS) -o $# $< $(INC) $(LIBS)
# Rule to create output dirs
$(DIRS):
#echo "Creating output folders"
#mkdir -p $(EXE_DIR)
# Rule to clean up
clean:
#echo "Cleaning"
#rm -rf $(EXE_DIR)
This should create one executable in the folder bin/ for each source file (.cpp) in folder src/.
So I have been trying to use the answers and the idea of this published question: Makefile: Compiling from directory to another directory
In the following excerpt code, you can see the definition of the directories, for sources and compilation objects.
all : Mpois Mkvz MBJ Mlid
# Definitions
COMPILER := gfortran -O3
LIBS := -g -fbounds-check -ffast-math -lm
# Directories of object code
OBJDIR = objects
SRCDIR = src
SOURCES := $(SRCDIR)/lbm_const.f90 $(SRCDIR)/BORDERS.f90 $(SRCDIR)/CONVERGENCE.f90 $(SRCDIR)/FILESIO.f90 $(SRCDIR)/LBM.f90
OBJECTS := $(OBJDIR)/lbm_const.o $(OBJDIR)/BORDERS.o $(OBJDIR)/CONVERGENCE.o $(OBJDIR)/FILESIO.o $(OBJDIR)/LBM.o
SOURCES_pois := $(SRCDIR)/Main_pois.f90
OBJECTS_pois := $(OBJDIR)/Main_pois.o
# Linking
Mpois: $(OBJECTS) $(OBJECTS_pois)
$(COMPILER) $^ -o $# $(LIBS)
# Compiling
$(OBJECTS): $(OBJDIR)/%.o: %.f90
$(COMPILER) -c $< -o $#
# Compiling
$(OBJECTS_pois): $(OBJDIR)/%.o: %.f90
$(COMPILER) -c $< -o $#
clean:
rm -f $(OBJDIR)/*.o
rm -f $(OBJDIR)/*.mod
rm -f $(SRCDIR)/*.mod
When running the makefile script I get the following error:
make: *** No rule to make target 'lbm_const.f90', needed by 'objects/lbm_const.o'. Stop.
Interesting is to note that when SRCDIR = src changes to SRCDIR = . the makefile compiles even having files in folder src.
I am trying since a week to compile a code written in F90 and C. I keep getting an undefined symbols error. I will try to give as much information as I can but the package includes hundreds of files so it is a bit difficult to give all the details. This is the Makefile
include paths.mk
include include.mk.$(OPT)
#------------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------------#
# Double check that the "LOWO" flags have been set. In case they have not, clone the #
# standard options. LOWO stands for LOWer Optimisation, and these flags are used for a #
# subroutines that are taking several hours to compile with ifort-13 (ed_state_vars.f90 #
# and a few others). #
#------------------------------------------------------------------------------------------#
ifeq ($(F_LOWO_OPTS),)
F_LOWO_OPTS = $(F_OPTS)
endif
#------------------------------------------------------------------------------------------#
#----- Compiler commands. -----------------------------------------------------------------#
INCLUDES = $(PAR_INCS) -I$(ED_INCS) $(HDF5_INCS) $(MPI_INCS)
F90_COMMAND = $(F_COMP) -c $(F_OPTS) $(INCLUDES) $(PAR_DEFS)
F90_LOWO_COMMAND = $(F_COMP) -c $(F_LOWO_OPTS) $(INCLUDES) $(PAR_DEFS)
FPP_COMMAND = $(F_COMP) -c -DUSE_INTERF=$(USE_INTERF) -DUSENC=$(USENC) -D$(CMACH) \
-DUSE_HDF5=$(USE_HDF5) -DUSE_COLLECTIVE_MPIO=$(USE_COLLECTIVE_MPIO) \
-DUSE_MPIWTIME=$(USE_MPIWTIME) $(F_OPTS) $(INCLUDES) $(PAR_DEFS)
FPP_LOWO_COMMAND = $(F_COMP) -c -DUSE_INTERF=$(USE_INTERF) -DUSENC=$(USENC) -D$(CMACH) \
-DUSE_HDF5=$(USE_HDF5) -DUSE_COLLECTIVE_MPIO=$(USE_COLLECTIVE_MPIO) \
-DUSE_MPIWTIME=$(USE_MPIWTIME) $(F_LOWO_OPTS) $(INCLUDES) $(PAR_DEFS)
CXX_COMMAND = $(C_COMP) -c $(C_OPTS) -D$(CMACH) $(HDF5_INCS) $(INCLUDES) $(PAR_DEFS)
#------------------------------------------------------------------------------------------#
#----- Define archive and executable names. -----------------------------------------------#
EXE=$(BASE)/ed_$(ED_VERSION)-$(OPT)
LIBMODEL=$(BASE)/ed_$(ED_VERSION)-$(OPT).a
#------------------------------------------------------------------------------------------#
include objects.mk
#----- Define targets. --------------------------------------------------------------------#
all:
make gendep
make $(EXE)
make $(EXE)
make $(EXE)
make $(EXE)
make $(EXE)
gendep:
#echo ""
./generate_deps.sh $(ED_ROOT)
#echo === Finished dependencies ===
$(EXE): $(LIBMODEL) $(MAINOBJ)
#echo ""
$(LOADER) -o $(EXE) edmain.o $(LOADER_OPTS) $(INCLUDES) $(LIBMODEL) $(HDF5_LIBS) \
$(PAR_LIBS) $(NC_LIBS) $(LIBS) $(LOADER_OPTS)
#echo ""
#echo Finished building === $(EXE)
#echo ""
$(MAINOBJ): $(MAIN)
#echo ""
cp -f $< $(<F:.F90=.F90)
$(FPP_COMMAND) $(<F:.F90=.F90)
rm -f $(<F:.F90=.F90)
$(LIBMODEL): $(OBJ_MODEL)
$(ARCHIVE) $(LIBMODEL) $(OBJ_MODEL)
FORCE:
install:
#echo ""
ln -fs `pwd`/$(EXE) ../run/$(BASE)
ln -fs `pwd`/$(EXE) ../test/$(BASE)
#echo ""
clean:
#echo ""
rm -f $(LIBMODEL) $(EXE) *.o *.mod *.F90 *.f90 *.stb *.d dependency.mk
rm -f ../$(EXE) ../$(LIBMODEL)
touch dependency.mk
#echo ""
#----- Define rules -----------------------------------------------------------------------#
include rules.mk
The Makefile includes this other file
# Define make (gnu make works best).
MAKE=/usr/bin/make
# libraries.
BASE=$(ED_ROOT)/build/
# Activate appropriate parts below, comment out others.
# HDF 5 Libraries
# ED2 HAS OPTIONAL HDF 5 I/O
# If you wish to use this functionality specify USE_HDF5=1
# and specify the location of the include directory
# library files. Make sure you include the zlib.a location too.
USE_HDF5=1
HDF5_INCS=-I/opt/local/include
HDF5_LIBS= -L/opt/local/lib -lhdf5 -lhdf5_fortran -lz -L/opt/local/lib/libgcc/ -lstdc++ -lm
#---------------------------------------------------------------
# If you have a version of hdf5 compiled in parallel, then you
# may benefit from collective I/O, then use this flag = 1
# Otherwise, set it to zero.
USE_COLLECTIVE_MPIO=0
#---------------------------------------------------------------
# interface ----------------------------------------------------
# This should be 1 unless you are running with -gen-interfaces.
# Interfaces usually make the compilation to crash when the
# -gen-interfaces option are on, so this flag bypass all
# interfaces in the code.
USE_INTERF=1
# MPI_Wtime. ---------------------------------------------------
# If USE_MPIWTIME=1, then it will use MPI libraries to compute
# the wall time (the only double-precision intrinsic). In case
# you don't have it, leave USE_MPIWTIME=0, in which case it will
# use a simpler, single-precision function.
USE_MPIWTIME=0
#----------------- MAC_OS_X (Leopard) ---- gfortan/gcc ---------------
CMACH=MAC_OS_X
F_COMP=gfortran
C_COMP=gcc
LOADER=gfortran
##################################### COMPILER OPTIONS #####################################
#------------------------------------------------------------------------------------------#
USE_INTERF=1
F_OPTS= -O0 -ffree-line-length-none
C_OPTS= -O0 -DLITTLE -stdlib=libstdc++
F_LOWO_OPTS= -O0 -ffree-line-length-none
LOADER_OPTS= -O0 -ffixed-line-length-none
#------------------------------------------------------------------------------------------#
# For IBM,HP,SGI,ALPHA,LINUX use these:
ARCHIVE=ar rs
# For NEC SX-6
#ARCHIVE=sxar rs
# For SUN,CONVEX
#ARCHIVE=ar r'
The compilation looks fine apart from a couple of warnings. Then in the linking phase something goes wrong. The last lines of the make read:
ar rs /Users/manfredo/Desktop/ED2/ED/build//ed_2.1-opt.a allometry.o an_header.o
!!!all other object files listed!!!
therm_lib.o therm_lib8.o twostream_rad.o update_derived_props.o utils_c.o utils_f.o vegetation_dynamics.o
ar: creating archive /Users/manfredo/Desktop/ED2/ED/build//ed_2.1-opt.a
/opt/local/bin/ranlib: file: /Users/manfredo/Desktop/ED2/ED/build//ed_2.1-opt.a(consts_coms.o) has no symbols
/opt/local/bin/ranlib: file: /Users/manfredo/Desktop/ED2/ED/build//ed_2.1-opt.a(ed_max_dims.o) has no symbols
cp -f /Users/manfredo/Desktop/ED2/ED/src/driver/edmain.F90 edmain.F90
gfortran -c -DUSE_INTERF=1 -DUSENC= -DMAC_OS_X -DUSE_HDF5=1 -DUSE_COLLECTIVE_MPIO=0 -DUSE_MPIWTIME=0 -O0 -ffree-line-length-none -I/Users/manfredo/Desktop/ED2/ED/src/include -I/opt/local/include edmain.F90
rm -f edmain.F90
gfortran -o /Users/manfredo/Desktop/ED2/ED/build//ed_2.1-opt edmain.o -O0 -ffixed-line-length-none -I/Users/manfredo/Desktop/ED2/ED/src/include -I/opt/local/include /Users/manfredo/Desktop/ED2/ED/build//ed_2.1-opt.a -L/opt/local/lib -lhdf5 -lhdf5_fortran -lz -L/opt/local/lib/libgcc/ -lstdc++ -lm \
-O0 -ffixed-line-length-none
Undefined symbols for architecture x86_64:
"_calchydrosubsurface_", referenced from:
_ed_model_ in ed_2.1-opt.a(ed_model.o)
"_calchydrosurface_", referenced from:
_ed_model_ in ed_2.1-opt.a(ed_model.o)
"_canopy_photosynthesis_", referenced from:
___rk4_driver_MOD_rk4_timestep in ed_2.1-opt.a(rk4_driver.o)
!!!all other similar errors!!!
"_writehydro_", referenced from:
_ed_model_ in ed_2.1-opt.a(ed_model.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[1]: *** [/Users/manfredo/Desktop/ED2/ED/build//ed_2.1-opt] Error 1
make: *** [all] Error 2
Thanks
That's a linker error. You don't seem to link in the .o file or library that contains _calchydrosubsurface_. Without knowing your source code or libraries used, it's hard to help you but tell you what to look for:
Search for the source code or library containing calchydrosubsurface; once found, make sure the symbol is exported properly (nm <object file>), and make sure you link against that in your make file.
I am trying to compile a .ttcn file with my a generated makefile with role is to create a .cc and .hh file.
But when I run the make command I have a problem with the .o file, it is not generated so my .exe is not generated too
here is the error I have and my Makefile:
Makefile:
# This Makefile was generated by the Makefile Generator
# of the TTCN-3 Test Executor version CRL 113 200/5 R2A
# for U-TMV\qi11091 (qi11091#WMUC-0118) on Thu Apr 9 16:49:49 2015
# Copyright Ericsson Telecom AB 2000-2014
# The following make commands are available:
# - make, make all Builds the executable test suite.
# - make archive Archives all source files.
# - make check Checks the semantics of TTCN-3 and ASN.1 modules.
# - make clean Removes all generated files.
# - make compile Translates TTCN-3 and ASN.1 modules to C++.
# - make dep Creates/updates dependency list.
# - make executable Builds the executable test suite.
# - make library Builds the library archive.
# - make objects Builds the object files without linking the executable.
# WARNING! This Makefile can be used with GNU make only.
# Other versions of make may report syntax errors in it.
#
# Do NOT touch this line...
#
.PHONY: all shared_objects executable library objects check clean dep archive
.SUFFIXES: .d
#
# Set these variables...
#
# The path of your TTCN-3 Test Executor installation:
# Uncomment this line to override the environment variable.
# TTCN3_DIR =
# Your platform: (SOLARIS, SOLARIS8, LINUX, FREEBSD or WIN32)
PLATFORM = WIN32
# Your C++ compiler:
# (if you change the platform, you may need to change the compiler)
CXX = g++
# Flags for the C++ preprocessor (and makedepend as well):
CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)/include
# Flags for dependency generation
CXXDEPFLAGS = -MM
# Flags for the C++ compiler:
CXXFLAGS = -Wall
# Flags for the linker:
LDFLAGS =
ifeq ($(PLATFORM), WIN32)
# Silence linker warnings.
LDFLAGS += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc
endif
# Utility to create library files
AR = ar
ARFLAGS =
# Flags for the TTCN-3 and ASN.1 compiler:
COMPILER_FLAGS = -L
# Execution mode: (either ttcn3 or ttcn3-parallel)
TTCN3_LIB = ttcn3-parallel
# The path of your libxml2 installation:
# If you do not have your own one, leave it unchanged.
XMLDIR = $(TTCN3_DIR)
# Directory to store the archived source files:
ARCHIVE_DIR = backup
#
# You may change these variables. Add your files if necessary...
#
# TTCN-3 modules of this project:
TTCN3_MODULES = TTCN3SessionSetup.ttcn
# ASN.1 modules of this project:
ASN1_MODULES =
# C++ source & header files generated from the TTCN-3 & ASN.1 modules of
# this project:
GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) $(ASN1_MODULES:.asn=.cc)
GENERATED_HEADERS = $(GENERATED_SOURCES:.cc=.hh)
# C/C++ Source & header files of Test Ports, external functions and
# other modules:
USER_SOURCES =
USER_HEADERS = $(USER_SOURCES:.cc=.hh)
# Object files of this project that are needed for the executable test suite:
OBJECTS = $(GENERATED_OBJECTS) $(USER_OBJECTS)
GENERATED_OBJECTS = $(GENERATED_SOURCES:.cc=.o)
USER_OBJECTS = $(USER_SOURCES:.cc=.o)
DEPFILES = $(USER_OBJECTS:.o=.d) $(GENERATED_OBJECTS:.o=.d)
# Other files of the project (Makefile, configuration files, etc.)
# that will be added to the archived source files:
OTHER_FILES = Makefile
# The name of the executable test suite:
EXECUTABLE = TTCN3SessionSetup.exe
LIBRARY = libTTCN3SessionSetup.a
TARGET = $(EXECUTABLE)
#
# Do not modify these unless you know what you are doing...
# Platform specific additional libraries:
#
SOLARIS_LIBS = -lsocket -lnsl -lxml2
SOLARIS8_LIBS = -lsocket -lnsl -lxml2
LINUX_LIBS = -lxml2
FREEBSD_LIBS = -lxml2
WIN32_LIBS = -lxml2
#
# Rules for building the executable...
#
all: $(TARGET) ;
executable: $(EXECUTABLE) ;
library: $(LIBRARY) ;
objects: $(OBJECTS) compile;
$(EXECUTABLE): $(OBJECTS)
if $(CXX) $(LDFLAGS) -o $# $^ \
-L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) \
-L$(OPENSSL_DIR)/lib -lcrypto \
-L$(XMLDIR)/lib $($(PLATFORM)_LIBS); \
then : ; else $(TTCN3_DIR)/bin/titanver $(OBJECTS); exit 1; fi
$(LIBRARY): $(OBJECTS)
$(AR) -r $(ARFLAGS) $(LIBRARY) $(OBJECTS)
.cc.o .c.o:
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $# $<
.cc.d .c.d:
#echo Creating dependency file for '$<'; set -e; \
$(CXX) $(CXXDEPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $< \
| sed 's/\($*\)\.o[ :]*/\1.o $# : /g' > $#; \
[ -s $# ] || rm -f $#
$(GENERATED_SOURCES) $(GENERATED_HEADERS): compile
#if [ ! -f $# ]; then $(RM) compile; $(MAKE) compile; fi
check: $(TTCN3_MODULES) $(ASN1_MODULES)
$(TTCN3_DIR)/bin/compiler -s $(COMPILER_FLAGS) $^
compile: $(TTCN3_MODULES) $(ASN1_MODULES)
$(TTCN3_DIR)/bin/compiler $(COMPILER_FLAGS) $^ - $?
touch $#
clean:
-$(RM) $(EXECUTABLE) $(LIBRARY) $(OBJECTS) $(GENERATED_HEADERS) \
$(GENERATED_SOURCES) compile $(DEPFILES) \
tags *.log
dep: $(GENERATED_SOURCES) $(USER_SOURCES) ;
ifeq ($(findstring n,$(MAKEFLAGS)),)
ifeq ($(filter clean check compile archive diag,$(MAKECMDGOALS)),)
-include $(DEPFILES)
endif
endif
archive:
mkdir -p $(ARCHIVE_DIR)
tar -cvhf - $(TTCN3_MODULES) $(ASN1_MODULES) \
$(USER_HEADERS) $(USER_SOURCES) $(OTHER_FILES) \
| gzip >$(ARCHIVE_DIR)/`basename $(TARGET) .exe`-`date '+%y%m%d-%H%M'`.tgz
diag:
$(TTCN3_DIR)/bin/compiler -v 2>&1
$(TTCN3_DIR)/bin/mctr_cli -v 2>&1
$(CXX) -v 2>&1
$(AR) -V 2>&1
#echo TTCN3_DIR=$(TTCN3_DIR)
#echo OPENSSL_DIR=$(OPENSSL_DIR)
#echo XMLDIR=$(XMLDIR)
#echo PLATFORM=$(PLATFORM)
#
# Add your rules here if necessary...
#
And here is my error
qi11091#WMUC-0118 ~/Documents/TITAN_Command_Line/FirstTest
$ make
/cygdrive/c/Users/qi11091/Documents/TITAN_files/TITAN/bin/compiler -L TTCN3Ses sionSetup.ttcn - TTCN3SessionSetup.ttcn
Notify: Parsing TTCN-3 module `TTCN3SessionSetup.ttcn'...
Notify: Checking modules...
Notify: Generating code...
Notify: File `TTCN3SessionSetup.hh' was generated.
Notify: File `TTCN3SessionSetup.cc' was generated.
Notify: 2 files were updated.
touch compile
Creating dependency file for TTCN3SessionSetup.cc
g++: Fehler: spawn: No such file or directory
g++ -c -DWIN32 -I/cygdrive/c/Users/qi11091/Documents/TITAN_files/TITAN /include -Wall -o TTCN3SessionSetup.o TTCN3SessionSetup.cc
g++: Fehler: spawn: No such file or directory
Makefile:151: die Regel für Ziel „TTCN3SessionSetup.o“ scheiterte
make: *** [TTCN3SessionSetup.o] Fehler 1
If that's an exact copy of the output you're seeing, then one problem is:
g++ -c -DWIN32 -I/cygdrive/c/Users/qi11091/Documents/TITAN_files/TITAN /include -Wall -o TTCN3SessionSetup.o TTCN3SessionSetup.cc
Note all the spaces between .../TITAN_files/TITAN and /include. That whitespace makes the compiler think these are separate arguments, and it seems like you're trying to add the "file" /include to your compile line, which does not exist of course.
Your makefile doesn't actually set the TTCN3_DIR variable, in this example, so I don't know where that value is coming from but wherever it is, you need to be sure there is no whitespace at the end of the value.