What is the proper way of building a static binary with openssl? - c++

I have the following make file:
CC=g++
CFLAGS=-c -Wall
REST_LIBS = -lssl -lcrypto -lboost_system -lcpprest
all: main
main: static_pack
g++ -std=c++14 -D DEBUG -Wfatal-errors -static -pthread -I$(basepath)/vendors/cpp-jwt/include -I$(basepath)/vendors/json/include \
-DTS=\"/ctts.json\" \
-DCS_PATH=\"/bin\" \
-DCTFS_ENC=\"/ctfs.enc\" \
-DUNTAR_PATH=\"/\" \
-DCLUSTER_PATH=\"/.clusters\" \
-o run main.cpp \
libmain.a && \
rm -rf debpkg/cs/usr/bin/cs debpkg/cs.deb && \
cp run debpkg/cs/usr/bin/cs && \
dpkg-deb -b debpkg/cs && \
mv debpkg/cs.deb .
static_pack: rest.o aes.o random.o
ar rcs libmain.a random.o aes/aes.o rest/rest.o
rest.o:
g++ -std=c++14 -Wfatal-errors -c $(REST_LIBS) -o rest/rest.o rest/rest.cpp
aes.o: random.o
g++ -std=c++14 -D DEBUG -Wfatal-errors -c -lcrypto -o aes/aes.o random.o aes/aes.cpp
random.o:
g++ -std=c++14 -Wfatal-errors -c -o random.o random.cpp
If I compile this to be dynamically linked I have no problems. However, when I try static compilation I get tons of errors such as:
aes.cpp:(.text+0x706): undefined reference to `EVP_DecryptInit_ex'
aes.cpp:(.text+0x732): undefined reference to `EVP_DecryptUpdate'
aes.cpp:(.text+0x763): undefined reference to `EVP_CIPHER_CTX_ctrl'
aes.cpp:(.text+0x792): undefined reference to `EVP_DecryptFinal_ex'
aes.cpp:(.text+0x7a1): undefined reference to `EVP_CIPHER_CTX_free'
Essentially none of the symbols are being found. I'm not sure what I need to do now. I've tried build my object files as static to but that fails. I've looked into linking order, but that seems right.
My question boils down to two things:
When static linking other objects, do those objects need to be statically compiled as well + archived?
What is wrong with my setup?

You don't need REST_LIBS for your rest.o rule, as it only compiles a source file. You need to pass those libraries to g++ in main rule - as part of it, g++ will call linker.

Ok so apparently linking happens in the opposite order than I thought... and I think it's possible I might have not been linking either originally as a fufu mistake.
REST_LIBS = -lboost_filesystem -lboost_system -lcpprest -lssl -lcrypto -ldl
# /usr/local/lib/libyaml-cpp.a
all: main
main: static_pack
g++ -std=c++14 -D DEBUG -Wfatal-errors -I$(basepath)/vendors/cpp-jwt/include -I$(basepath)/vendors/json/include \
-DTS=\"/ctts.json\" \
-DCS_PATH=\"/bin\" \
-DCTFS_ENC=\"/ctfs.enc\" \
-DUNTAR_PATH=\"/\" \
-DCLUSTER_PATH=\"/.clusters\" \
-o run main.cpp \
libmain.a $(REST_LIBS) -pthread && \
rm -rf debpkg/cs/usr/bin/cs debpkg/cs.deb && \
cp run debpkg/cs/usr/bin/cs && \
dpkg-deb -b debpkg/cs && \
mv debpkg/cs.deb .

Related

How to include tensorflow c++ ".so" file in makefile?

I have created a .so file using the bazel command:
bazel build -c opt --copt="-fPIC" :tensorFlow.so
Following is my makefile:
CFLAGS = -c -g -W -O3 -Wall -Wshadow \
-Wno-long-long -Wpointer-arith -D_REENTRANT \
-D_POSIX_PTHREAD_SEMANTICS -DLINUX2 \
-I ./acl/lib_acl_cpp/include
BASE_PATH=./acl
LDFLAGS = -L$(BASE_PATH)/lib_acl_cpp/lib -l_acl_cpp \
-L$(BASE_PATH)/lib_protocol/lib -l_protocol \
-L$(BASE_PATH)/lib_acl/lib -l_acl \
-lpthread -lprotobuf -ljsoncpp
redisConnection: redisConnection.o
g++ ./redisConnection.o ./UnifiedMetric.pb.o ./getMapFromFeatureDistribution.o ./featureStats.o $(LDFLAGS) -o redisConnection
redisConnection.o: redisConnection.cpp
g++ $(CFLAGS) redisConnection.cpp -o redisConnection.o
I went through various links but couldn't find any way. How do I include the .so file file created in the makefile and what other things have to be added?
Add the paths to header files in INCLUDEPATH.
This might be the exact replica for your problem.

What change to be made in makefile to include protobuf

Makefile:
CFLAGS = -c -g -W -O3 -Wall -Werror -Wshadow \
-Wno-long-long -Wpointer-arith -D_REENTRANT \
-D_POSIX_PTHREAD_SEMANTICS -DLINUX2 \
-I ./acl/lib_acl_cpp/include
BASE_PATH=./acl
LDFLAGS = -L$(BASE_PATH)/lib_acl_cpp/lib -l_acl_cpp \
-L$(BASE_PATH)/lib_protocol/lib -l_protocol \
-L$(BASE_PATH)/lib_acl/lib -l_acl \
-lpthread
redisConnection: redisConnection.o
g++ -o $# $^ $(LDFLAGS)
redisConnection.o: redisConnection.cpp
g++ $(CFLAGS) redisConnection.cpp -o redisConnection.o
And I have generated the nrtprofile.pb.cc and nrtprofile.pb.h with the help of protoc command.
What changes must be made in the makefile because I am getting the following error in the class redisConnection.cpp when I am using the functions:
undefined reference to `google::protobuf::MessageLite::ParseFromString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
I have included nrtprofile.pb.h in the redisConnection.cpp
As here there are two things redisConnection and redisConnection.o, I am getting confused where should I write nrtprofile.pb.cc.
Add -lprotobuf to the LDFLAGS variable.
However, this assumes that the protobuf library is installed in a location where the linker finds it (e.g. /usr/lib). If you have it somewhere else, you can provide the additional search path by setting the LD_LIBRARY_PATH variable like this: export LD_LIBRARY_PATH=/my/special/path.
You can find the needed linker and compiler flags here. Basically, compiler and linker-related, you need to do something like c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf

"no rule to make target" for target created by another makefile

The main makefile is this, as you can see it calls to two other makefiles in the subdirs: comm and bc.
I know that I don't use makefile shortcuts like treating all cpp files at once but please don't pay attention to that right now.
In comm/makefile there is a rule to make comm/build/Communication.o but somehow I don't know how to tell that fact to the main makefile.
CPPFLAGS=-g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc
LDFLAGS=-g -L/usr/lib/x86_64-linux-gnu/ -lQt5Core -lboost_system -lpthread -lboost_thread
all: comm/bin/party bc/bin/bctest bin/protocol
comm/bin/party:
cd comm && $(MAKE)
bc/bin/bctest:
cd bc && $(MAKE)
bin/protocol:build/main.o \
build/TrustedParty.o \
build/Player.o \
build/utils.o \
comm/build/Communication.o \
comm/build/FileParser.o \
comm/build/Party.o \
comm/build/PeerConnection.o \
comm/build/ServerModule.o \
comm/build/Utilities.o \
bc/build/BooleanCircuit.o \
bc/build/Gate.o \
bc/build/Wire.o
g++ -Wall $^ -o bin/protocol $(LDFLAGS)
build/main.o:src/main.cpp
g++ $(CPPFLAGS) -fPIC src/main.cpp -o build/main.o
build/TrustedParty.o:src/TrustedParty.cpp
g++ $(CPPFLAGS) src/TrustedParty.cpp -o build/TrustedParty.o
build/Player.o:src/Player.cpp
g++ $(CPPFLAGS) src/Player.cpp -o build/Player.o
build/utils.o:src/utils.cpp
g++ $(CPPFLAGS) src/utils.cpp -o build/utils.o
clean:
rm -fr build/* bin/*
rm -fr comm/build/* bin/*
rm -fr bc/build/* bin/*
When I run make it returns
16:15:03 **** Build of configuration Default for project bmr ****
make all
g++ -g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc -fPIC src/main.cpp -o build/main.o
g++ -g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc src/TrustedParty.cpp -o build/TrustedParty.o
g++ -g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc src/Player.cpp -o build/Player.o
g++ -g -c --std=c++11 -Iinc -I/usr/include -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/include/boost -Ibc/inc -Icomm/inc src/utils.cpp -o build/utils.o
make: *** No rule to make target `comm/build/Communication.o', needed by `bin/protocol'. Stop.
16:15:11 Build Finished (took 7s.821ms)
Assuming the comm/Makefile knows how to build that target correctly (make build/Communication.o in the comm directory works); then if you really want to get this to work correctly (and you might not want to, see Recursive Make Considered Harmful for why) you need to tell the toplevel make what to do in this situation.
Something like this:
comm/build/%.o:
#$(MAKE) -C comm $(patsubst comm/%,%,$#)

Building library with static lib and c++ sourse code

I have a static library (lwip) compiled with this makefile:
CCDEP=g++
CC=g++
#To compile for linux: make ARCH=linux
#To compile for cygwin: make ARCH=cygwin
ARCH=unix
CFLAGS=-g -Wall -D$(ARCH) -DIPv4 -DLWIP_DEBUG -fpermissive \
-Wparentheses -Wsequence-point -Wswitch-default \
-Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast \
-Wc++-compat -Wwrite-strings -Wold-style-definition \
-Wmissing-prototypes -Wredundant-decls -Wnested-externs
# not used for now but interesting:
# -Wpacked
# -Wunreachable-code
# -ansi
# -std=c89
LDFLAGS=-lpthread -lutil -lboost_thread
CONTRIBDIR=../../../..
LWIPARCH=$(CONTRIBDIR)/ports/unix
ARFLAGS=rs
#Set this to where you have the lwip core module checked out from CVS
#default assumes it's a dir named lwip at the same level as the contrib module
LWIPDIR=$(CONTRIBDIR)/../lwip/src
CFLAGS:=$(CFLAGS) \
-I. -I$(CONTRIBDIR)/apps/httpserver_raw -I$(CONTRIBDIR)/apps/shell \
-I$(CONTRIBDIR)/apps/tcpecho -I$(CONTRIBDIR)/apps/udpecho \
-I$(LWIPDIR)/include -I$(LWIPARCH)/include -I$(LWIPDIR)/include/ipv4 \
-I$(LWIPDIR) -I$(CONTRIBDIR)
# -I$(CLASSDIR)/inc
# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c \
$(LWIPDIR)/core/pbuf.c $(LWIPDIR)/core/raw.c $(LWIPDIR)/core/stats.c \
$(LWIPDIR)/core/sys.c $(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_in.c \
$(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/udp.c $(LWIPDIR)/core/dhcp.c \
$(LWIPDIR)/core/init.c $(LWIPDIR)/core/timers.c $(LWIPDIR)/core/def.c \
CORE4FILES=$(wildcard $(LWIPDIR)/core/ipv4/*.c) $(LWIPDIR)/core/ipv4/inet.c \
$(LWIPDIR)/core/ipv4/inet_chksum.c
# SNMPFILES: Extra SNMPv1 agent
SNMPFILES=$(LWIPDIR)/core/snmp/asn1_dec.c $(LWIPDIR)/core/snmp/asn1_enc.c \
$(LWIPDIR)/core/snmp/mib2.c $(LWIPDIR)/core/snmp/mib_structs.c \
$(LWIPDIR)/core/snmp/msg_in.c $(LWIPDIR)/core/snmp/msg_out.c
# APIFILES: The files which implement the sequential and socket APIs.
APIFILES=$(LWIPDIR)/api/api_lib.c $(LWIPDIR)/api/api_msg.c $(LWIPDIR)/api/tcpip.c \
$(LWIPDIR)/api/err.c $(LWIPDIR)/api/sockets.c $(LWIPDIR)/api/netbuf.c \
$(LWIPDIR)/api/netdb.c
# NETIFFILES: Files implementing various generic network interface functions.'
NETIFFILES=$(LWIPDIR)/netif/etharp.c $(LWIPDIR)/netif/slipif.c
# NETIFFILES: Add PPP netif
NETIFFILES+=$(LWIPDIR)/netif/ppp/auth.c $(LWIPDIR)/netif/ppp/chap.c \
$(LWIPDIR)/netif/ppp/chpms.c $(LWIPDIR)/netif/ppp/fsm.c \
$(LWIPDIR)/netif/ppp/ipcp.c $(LWIPDIR)/netif/ppp/lcp.c \
$(LWIPDIR)/netif/ppp/magic.c $(LWIPDIR)/netif/ppp/md5.c \
$(LWIPDIR)/netif/ppp/pap.c $(LWIPDIR)/netif/ppp/ppp.c \
$(LWIPDIR)/netif/ppp/randm.c $(LWIPDIR)/netif/ppp/vj.c \
$(LWIPARCH)/netif/sio.c
# ARCHFILES: Architecture specific files.
ARCHFILES=$(wildcard $(LWIPARCH)/*.c $(LWIPARCH)/netif/tapif.c $(LWIPARCH)/netif/tunif.c
$(LWIPARCH)/netif/unixif.c $(LWIPARCH)/netif/list.c $(LWIPARCH)/netif/tcpdump.c)
# APPFILES: Applications.
APPFILES=$(CONTRIBDIR)/apps/httpserver_raw/fs.c
$(CONTRIBDIR)/apps/httpserver_raw/httpd.c \
$(CONTRIBDIR)/apps/udpecho/udpecho.c $(CONTRIBDIR)/apps/tcpecho/tcpecho.c \
$(CONTRIBDIR)/apps/shell/shell.c
# LWIPFILES: All the above.
LWIPFILES=$(COREFILES) $(CORE4FILES) $(SNMPFILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES)
LWIPFILESW=$(wildcard $(LWIPFILES))
LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
#LWIPOBJS+=$(notdir $(LWIPFILESW:.cpp=.o))
LWIPLIB=liblwip4.a
APPLIB=liblwipapps.a
APPOBJS=$(notdir $(APPFILES:.c=.o))
#APPOBJS+=$(notdir $(APPFILES:.cpp=.o))
%.o:
$(CC) $(CFLAGS) -c $(<:.o=.c)
all ipv4 compile: liblwip4.a
#all ipv4 compile: simhost
.PHONY: all
clean:
rm -f *.o $(LWIPLIB) $(APPLIB) simhost simnode simrouter *.s .depend* *.core core
depend dep: .depend
include .depend
$(APPLIB): $(APPOBJS)
$(AR) $(ARFLAGS) $(APPLIB) $?
$(LWIPLIB): $(LWIPOBJS)
$(AR) $(ARFLAGS) $(LWIPLIB) $?
.depend: simhost.c simnode.c simrouter.c $(LWIPFILES) $(APPFILES)
$(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend
simhost: .depend $(LWIPLIB) $(APPLIB) simhost.o $(APPFILES)
$(CC) $(CFLAGS) $(LDFLAGS) -o simhost simhost.o $(APPLIB) $(LWIPLIB)
simrouter: .depend $(LWIPLIB) $(APPLIB) simrouter.o
$(CC) $(CFLAGS) $(LDFLAGS) -o simrouter simrouter.o $(APPLIB) $(LWIPLIB)
simnode: .depend $(LWIPLIB) $(APPLIB) simnode.o
$(CC) $(CFLAGS) $(LDFLAGS) -o simnode simnode.o $(APPLIB) $(LWIPLIB)
Many of these things are not needed - that was example of application in 'contrib' folder. So... I get liblwip4.a library - for now all fine.
With this Library I made some test application - a class that uses lwip lib for different connections. I used eclipse IDE (added all includes, the liblwip4.a and so on) and it works fine.
Now I want to make a my_lwiplib.a or my_lwiplib.so with this lwip lib and my class. I made directory with 3 folders - lwip(sourse files), contrib-1.4.1(platform dependent files and so on) and lwipClass(my .h and .cpp file). wrote makefile:
CC = g++
CFLAGS = -fPIC -g -fpermissive
LDFLAGS = -shared
READYLIB = ./contrib-1.4.1/ports/unix/proj/unixsim/liblwip4.a
SOURCES = $(wildcard lwipClass/src/*.cpp)
INCLUDES = -I./lwipClass/inc/ -I./lwip/src/include/ -I./lwip/src/include/lwip/
OBJECTS = $(SOURCES:.cpp=.o)
CFLAGS += $(INCLUDES)
TARGET_SO = libmy_lwip.so
TARGET_STATIC = libmy_lwip.a
clean:
rm -f $(OBJECTS) $(TARGET_SO) $(TARGET_STATIC)
shared : $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) $(READYLIB) -o $(TARGET_SO) $(LDFLAGS)
static : $(OBJECTS)
ar rcs $(TARGET_STATIC) $(OBJECTS) $(READYLIB)
When I do 'make shared' I get:
sudo make shared
g++ -fPIC -g -fpermissive -I./lwipClass/inc/ -I./lwip/src/include/ -
I./lwip/src/include/lwip/ lwipClass/src/lwipClass.o ./contrib-
1.4.1/ports/unix/proj/unixsim/liblwip4.a -o libmy_lwip.so -shared
/usr/bin/ld: lwipClass/src/lwipClass.o: relocation R_X86_64_32 against `.bss' can not be
used when making a shared object; recompile with -fPIC
lwipClass/src/lwipClass.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [shared] Error 1
What's wrong here?
ADDED 14.08
Tryed to compile static lib. It compils ok.
Linked it to eclipse test project and made test application.
classA *myClass;
myClass->getInstance();
When i Try co compile I get
make all
Building file: ../src/test.cpp
Invoking: GCC C++ Compiler
g++ -fpermissive -I/home/user/lwip/lwipClass/inc -O0 -g3 -Wall -c -fmessage-length=0 -
MMD -MP -MF"src/test.d" -MT"src/test.d" -o "src/test.o" "../src/test.cpp"
Finished building: ../src/test.cpp
Building target: test
Invoking: GCC C++ Linker
g++ -o "test" ./src/test.o /home/user/lwip/libmy_lwip.a -lpthread -lboost_thread
/home/user/lwip/libmy_lwip.a(lwipClass.o): In function
`lwipImpl::tcpecho_thread(void*)':
lwipClass.cpp:(.text+0x85): undefined reference to `netbuf_data'
lwipClass.cpp:(.text+0xb9): undefined reference to `netbuf_next'
lwipClass.cpp:(.text+0xce): undefined reference to `netbuf_delete'
lwipClass.cpp:(.text+0xef): undefined reference to `netconn_recv'
That means there are no such functions.
I do
user:~/lwip$ objdump -t (some way /)/liblwip4.a |grep netbuf_data
00000000000003df g F .text 0000000000000103 netbuf_data
Than I do
usr:~/lwip$ objdump -t (some way/)lwip/libmy_lwip.a |grep netbuf_data
0000000000000000 *UND* 0000000000000000 netbuf_data
objdump: liblwip4.a: File format not recognized
wtf?????
In order to construct a shared library, you must first compile the source code and produce position-independent object files. That's what the -fPIC flag is for. You can't build a shared library out of "ordinary" object files, and you can't change that property of an object file later-- at least not easily.
In your example, you are trying to construct a shared library out of position-dependent object files, via a static library (). You can construct a static library from these objects, but if you want to build a shared library, as the linker is telling you, you must recompile with -fPIC.

Must one include all "file.o" files where there is "#include "file.h" "

I have massive cross compilation of omxplayer whcih I am trying to debug. The file is downloaded from here. Unfortunately there are over 5000 files so I can not upload the directory tree. Here is the make command that gets issued:
/path/to/cross/compiler/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ --sysroot=/mnt/root -Wall -L/mnt/root/lib -L/mnt/root/lib -L/mnt/root/usr/lib -L/mnt/root/usr/lib/omxplayer -L/mnt/root/opt/vc/lib -L/mnt/root/usr/lib/arm-linux-gnueabihf -L./ -ldbus-1 -lc -lWFC -lGLESv2 -lEGL -lbcm_host -lopenmaxil -lfreetype -lz -Lffmpeg_compiled/usr/local/lib/ -o omxplayer.bin linux/XMemUtils.o utils/log.o DynamicDll.o utils/PCMRemap.o utils/RegExp.o OMXSubtitleTagSami.o OMXOverlayCodecText.o BitstreamConverter.o linux/RBP.o OMXThread.o OMXReader.o OMXStreamInfo.o OMXAudioCodecOMX.o OMXCore.o OMXVideo.o OMXAudio.o OMXClock.o File.o OMXPlayerVideo.o OMXPlayerAudio.o OMXPlayerSubtitles.o SubtitleRenderer.o Unicode.o Srt.o KeyConfig.o OMXControl.o Keyboard.o omxplayer.o -lvchiq_arm -lvcos -lrt -lpthread -lavutil -lavcodec -lavformat -lavdevice -lavfilter -lswscale -lswresample -lpcre ./arm-linux-gnueabihf-pkg-config --libs dbus-1 -lrt
But then I get the following errors:
/path/to/cross/compiler/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: warning: libavutil.so.51, needed by /mnt/root/usr/lib/arm-linux-gnueabihf/libpostproc.so.52, may conflict with libavutil.so.52
BitstreamConverter.o: In function `DllAvUtilBase::av_frame_move_ref(AVFrame*, AVFrame*)':
BitstreamConverter.cpp:(.text._ZN13DllAvUtilBase17av_frame_move_refEP7AVFrameS1_[_ZN13DllAvUtilBase17av_frame_move_refEP7AVFrameS1_]+0x8): undefined reference to `av_frame_move_ref'
BitstreamConverter.o: In function `DllAvUtilBase::av_frame_unref(AVFrame*)':
BitstreamConverter.cpp:(.text._ZN13DllAvUtilBase14av_frame_unrefEP7AVFrame[_ZN13DllAvUtilBase14av_frame_unrefEP7AVFrame]+0x4): undefined reference to `av_frame_unref'
BitstreamConverter.o: In function `DllAvUtilBase::av_frame_alloc()':
BitstreamConverter.cpp:(.text._ZN13DllAvUtilBase14av_frame_allocEv[_ZN13DllAvUtilBase14av_frame_allocEv]+0x0): undefined reference to `av_frame_alloc'
BitstreamConverter.o: In function `DllAvUtilBase::av_frame_free(AVFrame**)':
BitstreamConverter.cpp:(.text._ZN13DllAvUtilBase13av_frame_freeEPP7AVFrame[_ZN13DllAvUtilBase13av_frame_freeEPP7AVFrame]+0x4): undefined reference to `av_frame_free'
collect2: error: ld returned 1 exit status
make: *** [omxplayer.bin] Error 1
I traced the av_frame_unref function and the others to frame.h which is in both ffmpeg_compiled/usr/local/include/libavutil/frame.h and ffmpeg/libavutil/frame.h. Normally I would link to the .so library with -lframe or -Lffmpeg/libavutil/ -lframe, however, this is not a shared library (.so file) but an object file (.o file). I am pretty sure I do not have to link these manually, that's what the make file is for. Anyone shed some light on what is going on. Also, I will include my Makefile below (I also have a Makefile.include showing the cross compile options, I can post that as well if necessary)
Makefile:
SRC=linux/XMemUtils.cpp \
utils/log.cpp \
DynamicDll.cpp \
utils/PCMRemap.cpp \
utils/RegExp.cpp \
OMXSubtitleTagSami.cpp \
OMXOverlayCodecText.cpp \
BitstreamConverter.cpp \
linux/RBP.cpp \
OMXThread.cpp \
OMXReader.cpp \
OMXStreamInfo.cpp \
OMXAudioCodecOMX.cpp \
OMXCore.cpp \
OMXVideo.cpp \
OMXAudio.cpp \
OMXClock.cpp \
File.cpp \
OMXPlayerVideo.cpp \
OMXPlayerAudio.cpp \
OMXPlayerSubtitles.cpp \
SubtitleRenderer.cpp \
Unicode.cpp \
Srt.cpp \
KeyConfig.cpp \
OMXControl.cpp \
Keyboard.cpp \
omxplayer.cpp \
OBJS+=$(filter %.o,$(SRC:.cpp=.o))
all: omxplayer.bin
%.o: %.cpp
#rm -f $#
$(CXX) $(CFLAGS) $(INCLUDES) -c $< -o $# -Wno-deprecated-declarations
version:
bash gen_version.sh > version.h
omxplayer.bin: version $(OBJS)
$(CXX) $(LDFLAGS) -o omxplayer.bin $(OBJS) -lvchiq_arm -lvcos -lrt -lpthread -lavutil -lavcodec -lavformat -lavdevice -lavfilter -lswscale -lswresample -lpcre `./arm-linux-gnueabihf-pkg-config --libs dbus-1` -lrt
#arm-unknown-linux-gnueabi-strip omxplayer.bin
clean:
for i in $(OBJS); do (if test -e "$$i"; then ( rm $$i ); fi ); done
#rm -f omxplayer.old.log omxplayer.log
#rm -f omxplayer.bin
#rm -rf $(DIST)
#rm -f omxplayer-dist.tar.gz
ffmpeg:
#rm -rf ffmpeg
make -f Makefile.ffmpeg
make -f Makefile.ffmpeg install
dist: omxplayer.bin
mkdir -p $(DIST)/usr/lib/omxplayer
mkdir -p $(DIST)/usr/bin
mkdir -p $(DIST)/usr/share/doc
cp omxplayer omxplayer.bin $(DIST)/usr/bin
cp COPYING $(DIST)/usr/share/doc/
cp README.md $(DIST)/usr/share/doc/README
cp -a ffmpeg_compiled/usr/local/lib/*.so* $(DIST)/usr/lib/omxplayer/
tar -czf omxplayer-dist.tar.gz $(DIST)
It looks like you need to pull in the function definition from the .o files at compile time. I found this article very helpful in explaining the theory behind this:
http://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking/
For more information on linking and compiling, I also highly recommend this book: http://www.network-theory.co.uk/docs/gccintro/index.html
I went around and mule-headedly started adding foo/bar.o instructions after g++, luckily I only had to put two of these: ffmpeg/libavutil/frame.o and ffmpeg/libavutil/buffer.o. I finally got omxplayer to install. Note, if Linux has taught me anything it's that just because something compiles doesn't mean that it will work.
In hindsight, this makes perfect sense and I should have done it before, problem is that most websites either deal with insanely trivial situations, like g++ -o foo.o bar.o or insanely complex cases where you are redefining pkg-config to be cross compile capable and then setting up a dozen flags before even using that. I find these large Makefiles are always difficult to deal with for novice programmers.