Reputation: 305
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.
Upvotes: 0
Views: 965
Reputation: 207798
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 ...
Upvotes: 1