Building Poco 1.9.0 with Crypto module - c++

I need to build Poco 1.9.0 with clang for Android armeabi-v7a.
I build it like this:
./configure --no-sharedmemory --no-wstring --config=Android-armeabi-v7a-clang --no-samples --no-tests --omit=Data,PageCompiler,ApacheConnector,CppParser,PDF,PocoDoc,ProGen,Encodings,CppUnit,MongoDB,Redis,SevenZip,Zip
make -j4
make install
Here is configuration file for Android-armeabi-v7a-clang I have created:
#
# $Id: //poco/1.4/build/config/Android#3 $
#
# Android
#
# Make settings for Android NDK
#
#
# General Settings
#
LINKMODE ?= STATIC
ANDROID_ABI ?= armeabi-v7a
POCO_TARGET_OSNAME = Android
POCO_TARGET_OSARCH = $(ANDROID_ABI)
ifeq ($(ANDROID_ABI),armeabi)
TOOL = arm-linux-androideabi
ARCHFLAGS = -mthumb
else
ifeq ($(ANDROID_ABI),armeabi-v7a)
TOOL = arm-linux-androideabi
ARCHFLAGS = -march=armv7-a -mfloat-abi=softfp
LINKFLAGS = -Wl,--fix-cortex-a8
else
ifeq ($(ANDROID_ABI),x86)
TOOL = i686-linux-android
ARCHFLAGS = -march=i686 -msse3 -mstackrealign -mfpmath=sse
else
ifeq ($(ANDROID_ABI),x86_64)
TOOL = x86_64-linux-android
ARCHFLAGS = -msse3 -mstackrealign -mfpmath=sse
else
ifeq ($(ANDROID_ABI),arm64-v8a)
TOOL = aarch64-linux-android
ARCHFLAGS = -march=armv8-a
else
$(error Invalid ABI specified in ANDROID_ABI)
endif
endif
endif
endif
endif
#
# Define Tools
#
CC = $(TOOL)-clang
CXX = $(TOOL)-clang++
LINK = $(CXX)
STRIP = $(TOOL)-strip
LIB = $(TOOL)-ar -cr
RANLIB = $(TOOL)-ranlib
SHLIB = $(CXX) -shared -Wl,-soname,$(notdir $#) -o $#
SHLIBLN = $(POCO_BASE)/build/script/shlibln
DEP = $(POCO_BASE)/build/script/makedepend.gcc
SHELL = sh
RM = rm -rf
CP = cp
MKDIR = mkdir -p
#
# Extension for Shared Libraries
#
SHAREDLIBEXT = .so.$(target_version)
SHAREDLIBLINKEXT = .so
#
# Compiler and Linker Flags
#
CFLAGS = $(ARCHFLAGS) -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing
CFLAGS32 =
CFLAGS64 =
CXXFLAGS = $(ARCHFLAGS) -std=c++11 -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -frtti -fexceptions
CXXFLAGS32 =
CXXFLAGS64 =
LINKFLAGS +=
LINKFLAGS32 =
LINKFLAGS64 =
STATICOPT_CC =
STATICOPT_CXX =
STATICOPT_LINK = -static
SHAREDOPT_CC =
SHAREDOPT_CXX =
SHAREDOPT_LINK = -Wl,-rpath,$(LIBPATH)
DEBUGOPT_CC = -g -D_DEBUG
DEBUGOPT_CXX = -g -D_DEBUG
DEBUGOPT_LINK = -g
RELEASEOPT_CC = -O3 -DNDEBUG -fomit-frame-pointer
RELEASEOPT_CXX = -O2 -DNDEBUG -fomit-frame-pointer
RELEASEOPT_LINK = -O2
#
# System Specific Flags
#
SYSFLAGS = -DPOCO_ANDROID -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY
#
# System Specific Libraries
#
SYSLIBS = -lstdc++ -lsupc++
When I try to build it I get multiple occurrences of this error:
In file included from src/OpenSSLInitializer.cpp:15:
In file included from include/Poco/Crypto/OpenSSLInitializer.h:21:
include/Poco/Crypto/Crypto.h:30:10: fatal error: 'openssl/opensslv.h' file not found
#include <openssl/opensslv.h>
^
1 error generated.
...
In file included from src/X509Certificate.cpp:15:
In file included from include/Poco/Crypto/X509Certificate.h:21:
include/Poco/Crypto/Crypto.h:30:10: fatal error: 'openssl/opensslv.h' file not found
#include <openssl/opensslv.h>
^
1 error generated.
...
As I said earlier I use poco version 1.9.0, clang version 3.8.0 on linux machine. Build without Crypto modul works fine.
Thanks for help

Solve by adding statically builded openssl library to configuration of poco
./configure --no-sharedmemory --no-wstring --config=Android-armeabi-v7a-clang --no-samples --no-tests --include-path=./openssl/Android/armeabi-v7a/include/--omit=Data,PageCompiler,ApacheConnector,CppParser,PDF,PocoDoc,ProGen,Encodings,CppUnit,MongoDB,Redis,SevenZip,Zip

Related

zlib.h:34:19: fatal error: zconf.h: No such file or directory #include "zconf.h"

There are quite some posts about this error, but I was not able to solve it, I hope you can come up with the solution. I am on a Ubuntu machine.
~/graphmap2$
In this folder, I downloaded zlib. You can see the picture
After some Googling, I also noticed that there is no -lz parameter, so I also added that manually as you can see below
However, I still get the same error as when none of the above were done.
Might it be that the path to zlib is not clear for the compiler? However, I installed it in this same folder.
The make file looks like the below:
BIN = ./bin/graphmap2
BIN_DEBUG = ./bin/graphmap-debug
BIN_LINUX = ./bin/Linux-x64/graphmap2
BIN_MAC = ./bin/Mac/graphmap
OBJ_TESTING = ./obj_test
OBJ_TESTING_EXT = ./obj_testext
OBJ_DEBUG = ./obj_debug
OBJ_LINUX = ./obj_linux
OBJ_EXTCIGAR = ./obj_extcigar
OBJ_MAC = ./obj_mac
SOURCE = src
CODEBASE = codebase
# This finds all 'src' folders at maximum depth 2 (level one inside each submodule's folder).
CODEBASE_SRC_FOLDERS = $(shell find $(CODEBASE) -maxdepth 2 -type d -name "src" -exec echo "-I"{} \;)
# $(shell find $(CODEBASE) -maxdepth 3 -type d -name "libs" -exec echo "-I"{} \;)
# $(shell find $(CODEBASE) -maxdepth 2 -type d -name "src" -exec echo "-I"{}"/*/" \;)
# ? allows override by user using env var
GCC ?= g++
# define variables for GCC version check here
GCC_MAJOR_VERSION_GE_4 := $(shell expr `$(GCC) -dumpversion | cut -f1 -d.` \>= 4)
GCC_MINOR_VERSION_GE_7 := $(shell expr `$(GCC) -dumpversion | cut -f2 -d.` \>= 7)
GCC_MAC ?= g++
# CPP_FILES := $(wildcard $(SOURCE)/*/*.cpp) $(wildcard $(SOURCE)/*.cpp) $(wildcard $(SOURCE)/libs/*/*.cpp)
# CC_FILES := $(wildcard $(SOURCE)/*/*.cc) $(wildcard $(SOURCE)/*.cc) $(wildcard $(SOURCE)/libs/*/*.cc)
# H_FILES := $(wildcard $(SOURCE)/*/*.h) $(wildcard $(SOURCE)/*.h) $(wildcard $(SOURCE)/libs/*/*.h)
CPP_FILES := $(wildcard $(CODEBASE)/*/src/*.cpp) $(wildcard $(CODEBASE)/*/src/libs/*/*.cpp) $(wildcard $(CODEBASE)/*/src/*/*.cpp) $(wildcard $(SOURCE)/*/*.cpp) $(wildcard $(SOURCE)/*.cpp) $(wildcard $(SOURCE)/libs/*/*.cpp)
CC_FILES := $(wildcard $(CODEBASE)/*/src/*.cc) $(wildcard $(CODEBASE)/*/src/libs/*/*.cc) $(wildcard $(CODEBASE)/*/src/*/*.cc) $(wildcard $(SOURCE)/*/*.cc) $(wildcard $(SOURCE)/*.cc) $(wildcard $(SOURCE)/libs/*/*.cc)
H_FILES := $(wildcard $(CODEBASE)/*/src/*.h) $(wildcard $(CODEBASE)/*/src/libs/*/*.h) $(wildcard $(CODEBASE)/*/src/*/*.h) $(wildcard $(SOURCE)/*/*.h) $(wildcard $(SOURCE)/*.h) $(wildcard $(CODEBASE)/*/src/*.hpp) $(wildcard $(CODEBASE)/*$
OBJ_FILES := $(CPP_FILES:.cpp=.o) $(CC_FILES:.cc=.o)
OBJ_FILES_FOLDER_TESTING := $(addprefix $(OBJ_TESTING)/,$(OBJ_FILES))
OBJ_FILES_FOLDER_TESTING_EXT := $(addprefix $(OBJ_TESTING_EXT)/,$(OBJ_FILES))
OBJ_FILES_FOLDER_DEBUG := $(addprefix $(OBJ_DEBUG)/,$(OBJ_FILES))
OBJ_FILES_FOLDER_LINUX := $(addprefix $(OBJ_LINUX)/,$(OBJ_FILES))
OBJ_FILES_FOLDER_EXTCIGAR := $(addprefix $(OBJ_EXTCIGAR)/,$(OBJ_FILES))
OBJ_FILES_FOLDER_MAC := $(addprefix $(OBJ_MAC)/,$(OBJ_FILES))
LIB_DIRS = -L"/usr/local/lib"
CC_LIBS = -static-libgcc -static-libstdc++ -D__cplusplus=201103L
# INCLUDE = -I"./src/" -I"/usr/include/" -I"libs/libdivsufsort-2.0.1/build/include" -I"libs/seqan-library-1.4.2/include"
# INCLUDE = -I"./src/" -I"/usr/include/" -I"src/libs/seqan-library-1.4.2/include"
INCLUDE = -I"./src/" -I"/usr/include/" -I"$(CODEBASE)/seqlib/src/libs/seqan-library-2.0.1/include" -I"$(CODEBASE)/seqlib/src/libs/libdivsufsort-2.0.1-64bit/" $(CODEBASE_SRC_FOLDERS)
CC_FLAGS_DEBUG = -O3 -g -rdynamic -c -fmessage-length=0 -ffreestanding -fopenmp -m64 -std=c++11 -Werror=return-type -pthread -march=native -lz
CC_FLAGS_RELEASE = -DRELEASE_VERSION -g -O3 -fdata-sections -ffunction-sections -c -fmessage-length=0 -ffreestanding -fopenmp -m64 -std=c++11 -Werror=return-type -pthread -lz # -march=native
CC_FLAGS_EXTCIGAR = -DRELEASE_VERSION -DUSE_EXTENDED_CIGAR_FORMAT -g -O3 -fdata-sections -ffunction-sections -c -fmessage-length=0 -ffreestanding -fopenmp -m64 -std=c++11 -Werror=return-type -pthread -march=native -lz
CC_FLAGS_NOT_RELEASE = -g -O3 -fdata-sections -ffunction-sections -c -fmessage-length=0 -ffreestanding -fopenmp -m64 -std=c++11 -Werror=return-type -Wuninitialized -pthread -march=native -lz
CC_FLAGS_NOT_RELEASE_EXT = -g -O3 -DUSE_EXTENDED_CIGAR_FORMAT -fdata-sections -ffunction-sections -c -fmessage-length=0 -ffreestanding -fopenmp -m64 -std=c++11 -Werror=return-type -Wuninitialized -pthread -march=native -lz LD_FLAGS = -static-libgcc -static-libstdc++ -m64 -ffreestanding -lz
# LD_LIBS = -lpthread -lgomp -lm -lz -ldivsufsort64
LD_LIBS = -lpthread -lgomp -lm -lz
all: gcc_version_check linux
install: /usr/bin/graphmap
/usr/bin/graphmap: bin/Linux-x64/graphmap
cp bin/Linux-x64/graphmap /usr/bin/graphmap
modules:
git submodule update --init --recursive
# git submodule foreach git pull origin master
testing: $(OBJ_FILES_FOLDER_TESTING)
mkdir -p $(dir $(BIN))
$(GCC) $(LD_FLAGS) $(LIB_DIRS) -o $(BIN) $(OBJ_FILES_FOLDER_TESTING) $(LD_LIBS)
obj_test/%.o: %.cc $(H_FILES)
mkdir -p $(dir $#)
$(GCC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_NOT_RELEASE) -o $# $<
obj_test/%.o: %.cpp $(H_FILES)
mkdir -p $(dir $#)
$(GCC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_NOT_RELEASE) -o $# $<
testingext: $(OBJ_FILES_FOLDER_TESTING_EXT)
mkdir -p $(dir $(BIN)) $(GCC) $(LD_FLAGS) $(LIB_DIRS) -o $(BIN) $(OBJ_FILES_FOLDER_TESTING_EXT) $(LD_LIBS)
obj_testext/%.o: %.cc $(H_FILES)
mkdir -p $(dir $#)
$(GCC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_NOT_RELEASE_EXT) -o $# $<
obj_testext/%.o: %.cpp $(H_FILES)
mkdir -p $(dir $#)
$(GCC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_NOT_RELEASE_EXT) -o $# $<
gcc_version_check:
ifneq ($(GCC_MAJOR_VERSION_GE_4), 1)
$(warning "*** WARNING $(GCC) major version <4 ***")
endif
ifneq ($(GCC_MINOR_VERSION_GE_7), 1)
$(warning "*** WARNING $(GCC) minor version <7 ***")
endif
Any ideas?
Seems compiler is not able to find the file in the includes path you mentioned.
First check if zconf.h file is available on your machine and get that location. If the file is available then just give the path of the file to the compiler using -I option.
INCLUDE = -I"<YourPath>" -I"./src/" -I"/usr/include/" -I"$(CODEBASE)/seqlib/src/libs/seqan-library-2.0.1/include" -I"$(CODEBASE)/seqlib/src/libs/libdivsufsort-2.0.1-64bit/" $(CODEBASE_SRC_FOLDERS)
If the file itself is missing, then you would need to install it
sudo apt-get install libz-dev
Based on information shared by #Knud Larsen :
The Ubuntu package name is zlib1g-dev from where you can get the missing file. /usr/include/zconf.h
https://packages.ubuntu.com/focal-updates/amd64/zlib1g-dev/filelist
Just for future reference, what Altaf mentioned is correct. More than that, you can continue adding things that are not in the appropriate place exactly like this. Locate them and then add them manually.
If the makefile is not very big this will eventually be ok. It doesn't scale on the general case however, and maybe changing the makefile in a more radical way should be done.

Problem using VariantDir with a SCons Builder that generates a list of files to use as source for Program

I have a SConstruct that build my tool in 3 steps:
build a static library. In my case it's the antlr4 c++ runtime
generate the antlr4 cpp and h files (listener, visitor etc) of an antlr4's grammar
finally build a program using those files and linking to the antlr4 runtime library.
1 and 2 can be built in any order, even together but 3 ahs to be built when the other two have finished.
All this works perfectly when I don't use any VariantDir, however SCons fails when I try to use a variant directory, saying that it can't find the autogenerated files:
cons: *** [build/Parser/CoralBaseListener.o] Source `build/Parser/CoralBaseListener.cpp' not found, needed by target `build/Parser/CoralBaseListener.o'.
this is the whole SConstruct:
import os
import subprocess
env = Environment(
CC = "clang",
CXX = "clang++",
CXXFLAGS = ['-std=c++11', '-stdlib=libc++']
)
env.Append(ENV = {'CLASSPATH': './dependencies/antlr4/antlr-4.8-complete.jar'})
# RelWithDbgInfo
env.Append(CXXFLAGS = ['-O2', '-g', '-DNDEBUG'])
VariantDir('./build', './src')
VariantDir('./build/antlr4Runtime', './dependencies/antlr4Runtime')
#
# Builder for generating grammar files with antlr4 (the java app)
#
def auto_antlr_generated_files(prefix):
return [File(prefix + _file + ext) for _file in [
'CoralBaseListener',
'CoralBaseVisitor',
'CoralLexer',
'CoralListener',
'CoralParser',
'CoralVisitor'] for ext in ['.cpp', '.h']
]
def antlr_emitter(target, source, env):
target = auto_antlr_generated_files('src/Parser/')
return target, source
AntlrBuilder = Builder(
action='java org.antlr.v4.Tool $SOURCE -Dlanguage=Cpp -package Coral -visitor -listener -o src/Parser',
emitter=antlr_emitter
)
env.Append(BUILDERS={'Antlr': AntlrBuilder})
#
# Cloning the Environment for Antlr4 runtime
#
antlrEnv = env.Clone()
antlrEnv.Append(CXXFLAGS = [
'-Wall',
'-pedantic',
'-W',
'-Wno-overloaded-virtual',
'-Wno-dollar-in-identifier-extension',
'-Wno-four-char-constants'
])
#
# Building in 3 steps, first the antlr4 runtime library, then the parser files with Antlr then the final program
#
AntlrRuntime = antlrEnv.StaticLibrary(
'lib/antlr4-runtime',
source =
Glob('./build/antlr4Runtime/*.cpp') + \
Glob('./build/antlr4Runtime/atn/*.cpp') + \
Glob('./build/antlr4Runtime/dfa/*.cpp') + \
Glob('./build/antlr4Runtime/misc/*.cpp') + \
Glob('./build/antlr4Runtime/support/*.cpp') + \
Glob('./build/antlr4Runtime/tree/*.cpp') + \
Glob('./build/antlr4Runtime/tree/pattern/*.cpp') + \
Glob('./build/antlr4Runtime/tree/xpath/*.cpp'),
CPPPATH = './build/antlr4Runtime',
ARFLAGS = 'qc'
)
ParserFiles = env.Antlr(source='./Coral.g4')
CoralLang = env.Program(target = 'coral',
source = Glob('./build/*.cpp') + Glob('./build/Parser/*.cpp'),
CPPPATH = ['./build', './build/antlr4Runtime'],
LIBPATH = './lib',
LIBS = ['antlr4-runtime']
)
Requires(ParserFiles, AntlrRuntime)
Depends(auto_antlr_generated_files('./build/src/Parser/'), ParserFiles)
Depends(CoralLang, ParserFiles)
It is probably worth mentioning that at this point, when I have the error, the autogenerated antlr4 files are not in ./src nor in ./build, So basically the command never generated them in first place.
note that without VariantDir everything works as expected. Everything is build in the right steps without problems
import os
import subprocess
env = Environment(
CC = "clang",
CXX = "clang++",
CXXFLAGS = ['-std=c++11', '-stdlib=libc++']
)
env.Append(ENV = {'CLASSPATH': './dependencies/antlr4/antlr-4.8-complete.jar'})
# RelWithDbgInfo
env.Append(CXXFLAGS = ['-O2', '-g', '-DNDEBUG'])
#
# Builder for generating grammar files with antlr4 (the java app)
#
def auto_antlr_generated_files(prefix):
return [File(prefix + _file + ext) for _file in [
'CoralBaseListener',
'CoralBaseVisitor',
'CoralLexer',
'CoralListener',
'CoralParser',
'CoralVisitor'] for ext in ['.cpp', '.h']
]
def antlr_emitter(target, source, env):
target = auto_antlr_generated_files('src/Parser/')
return target, source
AntlrBuilder = Builder(
action='java org.antlr.v4.Tool $SOURCE -Dlanguage=Cpp -package Coral -visitor -listener -o src/Parser',
emitter=antlr_emitter
)
env.Append(BUILDERS={'Antlr': AntlrBuilder})
#
# Cloning the Environment for Antlr4 runtime
#
antlrEnv = env.Clone()
antlrEnv.Append(CXXFLAGS = [
'-Wall',
'-pedantic',
'-W',
'-Wno-overloaded-virtual',
'-Wno-dollar-in-identifier-extension',
'-Wno-four-char-constants'
])
#
# Building in 3 steps, first the antlr4 runtime library, then the parser files with Antlr then the final program
#
AntlrRuntime = antlrEnv.StaticLibrary(
'lib/antlr4-runtime',
source =
Glob('./dependencies/antlr4Runtime/*.cpp') + \
Glob('./dependencies/antlr4Runtime/atn/*.cpp') + \
Glob('./dependencies/antlr4Runtime/dfa/*.cpp') + \
Glob('./dependencies/antlr4Runtime/misc/*.cpp') + \
Glob('./dependencies/antlr4Runtime/support/*.cpp') + \
Glob('./dependencies/antlr4Runtime/tree/*.cpp') + \
Glob('./dependencies/antlr4Runtime/tree/pattern/*.cpp') + \
Glob('./dependencies/antlr4Runtime/tree/xpath/*.cpp'),
CPPPATH = './dependencies/antlr4Runtime',
ARFLAGS = 'qc'
)
ParserFiles = env.Antlr(source='./Coral.g4')
CoralLang = env.Program(target = 'coral',
source = Glob('./src/*.cpp') + Glob('./src/Parser/*.cpp'),
CPPPATH = ['./src', './dependencies/antlr4Runtime'],
LIBPATH = './lib',
LIBS = ['antlr4-runtime']
)
Requires(ParserFiles, AntlrRuntime)
Depends(CoralLang, ParserFiles)
I have the feeling that I'm doing something remarkably silly but I can't figure out what exactly.
This is what SCons output with the first SConstruct, the one that uses VariantDir:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: *** [build/Parser/CoralBaseListener.o] Source `build/Parser/CoralBaseListener.cpp' not found, needed by target `build/Parser/CoralBaseListener.o'.
scons: building terminated because of errors.
This is really all and if I read this correctly, SCons is jumping straight to point 3 and of course at it fails because point 2 didn't create the files that point 3 needs as source.
This is instead a snippet of the output of the second SConstruct, the one that doesn't use VariantDir. (I cut off some of the similar lines where Scons create the static library, but they are all similar, as you know)
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
clang++ -o dependencies/antlr4Runtime/ANTLRErrorListener.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Wall -pedantic -W -Wno-overloaded-virtual -Wno-dollar-in-identifier-extension -Wno-four-char-constants -Idependencies/antlr4Runtime dependencies/antlr4Runtime/ANTLRErrorListener.cpp
...
clang++ -o dependencies/antlr4Runtime/tree/xpath/XPathWildcardElement.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Wall -pedantic -W -Wno-overloaded-virtual -Wno-dollar-in-identifier-extension -Wno-four-char-constants -Idependencies/antlr4Runtime dependencies/antlr4Runtime/tree/xpath/XPathWildcardElement.cpp
ar qc lib/libantlr4-runtime.a dependencies/antlr4Runtime/ANTLRErrorListener.o ... dependencies/antlr4Runtime/tree/xpath/XPathWildcardElement.o
ranlib lib/libantlr4-runtime.a
java org.antlr.v4.Tool Coral.g4 -Dlanguage=Cpp -package Coral -visitor -listener -o src/Parser
clang++ -o src/Parser/CoralListener.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralListener.cpp
clang++ -o src/Parser/CoralBaseListener.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralBaseListener.cpp
clang++ -o src/Parser/CoralParser.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralParser.cpp
clang++ -o src/Parser/CoralLexer.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralLexer.cpp
clang++ -o src/main.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/main.cpp
clang++ -o src/Parser/CoralVisitor.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralVisitor.cpp
clang++ -o src/Parser/CoralBaseVisitor.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralBaseVisitor.cpp
clang++ -o coral src/main.o src/Parser/CoralBaseListener.o src/Parser/CoralBaseVisitor.o src/Parser/CoralLexer.o src/Parser/CoralListener.o src/Parser/CoralParser.o src/Parser/CoralVisitor.o -Llib -lantlr4-runtime
scons: done building targets.
So reading this is obvious that Scons start with building the static library, then he runs antlr to generate the files needed to parse my syntax and finally, when all the dependencies are created, it build the program.

How Do I Configure Qmake for Cross Compilation?

What I have done so far is create two makefiles: a project makefile and a package makefile.The project makefile was,however, created using qmake. When I compile the package, I get an x86-64 binary which means the makefile is not cross compiling. How can I fix this?
Here's a the part where I believe the source of the problem:
CC = gcc
CXX = g++
DEFINES = -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I.
LINK = g++
LFLAGS = -m64 -Wl,-O1
LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lcrypto -lssl -lQtCore -lpthread
AR = ar cqs
RANLIB =
QMAKE = /usr/lib/x86_64-linux-gnu/qt4/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
SED = sed
COPY_FILE = $(COPY)
COPY_DIR = $(COPY) -r
STRIP = strip
INSTALL_FILE = install -m 644 -p
INSTALL_DIR = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
DEL_FILE = rm -f
SYMLINK = ln -f -s
DEL_DIR = rmdir
MOVE = mv -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
I changed the first line "CC = gcc" to "CC ?=gcc" but it didn't fix the problem.

Compile and link sources from different directories with make and gcc

I`m having a Project with some subdirectories. I want to compile them with one makefile per Directory and link all Output files into one executable. Can anyone explain me, which commands I should use (-c or -g or extra call)?
makefile in my root-directory:
LIBS =
# The test will be called in this file. There is no need to change this.
#SRCS = main_test.c
SRCS = min.c max.c
###############################################################################
# #
# Normally it is not needed to edited below this. #
# #
###############################################################################
#SRCS = main_test.c Automated.c Basic.c Console.c CUCurses.c CUError.c Cunit_intl.c \
# MyMem.c TestDB.c TestRun.c Util.c wxWidget.c main_test.c \
# $(TST_SRCS)
# define the C object files
#
# This uses Suffix Replacement within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
OBJ = $(SRCS:%.c=%.o)
# define the C compiler to use
CC = gcc
# define any compile-time flags
ODIR = out
#compile and link
#CFLAGS = -O0 -g -Wall -fmessage-length=0 -fprofile-arcs -ftest-coverage
#compile without link
CFLAGS = -O0 -c -Wall -fmessage-length=0 -fprofile-arcs -ftest-coverage
#TODO Linkerflags
LFLAGS = --coverage
#VPATH=test
#VPATH=source
# define the executable file,
TARGET = CUnit
export COVERAGE = $(TST_SRCS)
export STUBS = $(STUB_SRCS)
all:
$(MAKE) -C stub
$(MAKE) -C source
#echo --- build finished ---
#echo.
#echo TODO
#echo --- start linking ---
#echo.
and makefile of subdirectory
# define any directories containing header files other than /usr/include
# TODO
# define any libraries to link into executable:
# if I want to link in libraries (libx.so or libx.a) I use the -llibname
# option, something like (this will link in libmylib.so and libm.so:
LIBS =
# TODO define the C source files
SRCS = $(COVERAGE)
# define the C object files
#
# This uses Suffix Replacement within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
OBJ = $(SRCS:%.c=%.o)
# define the C compiler to use
CC = gcc
# define any compile-time flags
ODIR = ../out
#compile without link
CFLAGS = -O0 -c -fmessage-length=0 -fprofile-arcs -ftest-coverage
#TODO Linkerflags
LFLAGS = --coverage
# define the executable file,
all: $(TARGET) $(OBJ)
$(CC) $(OBJ) $(CFLAGS) -o $(TARGET) $(LFLAGS) $(OBJ)
#echo +++ build of source finished +++
clean:
$(RM) *.o *~ $(MAIN)
# DO NOT DELETE THIS LINE -- make depend needs it
I it is easier for the linker, if all Output file are in the same Directory. Works this with ODIR?
With the compiler option -c -g I can compile each submake and link the object files together.
CFLAGS = -O0 -Wall -c -g -fmessage-length=0 -fprofile-arcs -ftest-coverage

Makefile and .Mak File + CodeBlocks and VStudio

I am a little new to the whole makefile concept so I have some questions regarding it.
I am creating a project using CodeBlocks in linux, I used a tool called cbp2mak to create a .make file out of the CodeBlocks project (if anyone knows a better tool please let me know).
Now I am not sure what the difference is between .mak and .makefile, could anyone tell me? I can compile .mak using "make -C .mak" but what is the difference?
The reason im trying to use it is because I want provide the source code for my project and want it to be buildable in both linux and windows so I don't want to give them my codeblocks project file. So i thought I could use a makefile that can be used to build in both linux and windows.
I would also like to check in Windows if both MinGW and VC++ compiler exists and build the source with both compilers, in Linux it will be only with GNU GCC.
The .mak file also has some macros to determine what to build depending on if it is being run on windows or linux as there are platform specific files.
So questions:
-What is the difference between .mak and .makefile
-Can I run a .mak file in windows? say using visual studio?
-Could there be a better solution to what I am doing now? (I used cpb2mak as it automatically generates a .mak file which saves a lot of time as I don't know how to create makefiles)
Also feel free to provide any advice or tips regarding this.
EDIT:
I have now put up the full .mak file
Also my project is a library which I build both a static and shared versions of it. The .mak file was auto generated but I hadded the platform handle with the ifdef and "shell, uname" function
# project performer-1.0
export PATH := /opt/wx/2.8/bin:$(PATH)
export LD_LIBRARY_PATH := /opt/wx/2.8/lib:$(LD_LIBRARY_PATH)
_WX = /home/gr/projects/gui/codeblocks/wx
_WX.LIB = $(_WX)/lib
_WX.INCLUDE = $(_WX)/include
_CB = /home/gr/projects/gui/codeblocks/cb/src
_CB.INCLUDE = $(_CB)/include
_CB.LIB = $(_CB)/devel
CFLAGS_C = $(filter-out -include "sdk.h",$(CFLAGS))
# -----------------------------------------
# MAKE_DEP = -MMD -MT $# -MF $(#:.o=.d)
CFLAGS = -Wall
INCLUDES = -I../performer-1.0
LDFLAGS = -s
RCFLAGS =
LDLIBS = $(T_LDLIBS) -lrt -lboost_regex-gcc43-mt -lxerces-c -lstdc++
LINK_exe = gcc -o $# $^ $(LDFLAGS) $(LDLIBS)
LINK_con = gcc -o $# $^ $(LDFLAGS) $(LDLIBS)
LINK_dll = gcc -o $# $^ $(LDFLAGS) $(LDLIBS) -shared
LINK_lib = rm -f $# && ar rcs $# $^
COMPILE_c = gcc $(CFLAGS_C) -o $# -c $< $(MAKEDEP) $(INCLUDES)
COMPILE_cpp = g++ $(CFLAGS) -o $# -c $< $(MAKEDEP) $(INCLUDES)
COMPILE_rc = windres $(RCFLAGS) -J rc -O coff -i $< -o $# -I$(dir $<)
%.o : %.c ; $(COMPILE_c)
%.o : %.cpp ; $(COMPILE_cpp)
%.o : %.cxx ; $(COMPILE_cpp)
%.o : %.rc ; $(COMPILE_rc)
.SUFFIXES: .o .d .c .cpp .cxx .rc
all: all.before all.targets all.after
all.before :
-
all.after : $(FIRST_TARGET)
# -----------------------------------------------------------
ifeq "$(shell uname)" "Linux"
# -----------------------------------------------------------
all.targets : Linux_Dynamic_target Linux_Static_target
# -----------------------------------------------------------
else
# -----------------------------------------------------------
all.targets : Windows_Dynamic_target
# -----------------------------------------------------------
endif
# -----------------------------------------------------------
clean :
rm -fv $(clean.OBJ)
rm -fv $(DEP_FILES)
.PHONY: all clean distclean
# -----------------------------------------------------------
ifeq "$(shell uname)" "Linux"
# -----------------------------------------------------------
# -----------------------------------------
# Linux_Dynamic_target
Linux_Dynamic_target.BIN = libs/libperformer-1.so
Linux_Dynamic_target.OBJ = src/analysis/analyzer.o src/analysis/comparer.o src/analysis/paverage.o src/analysis/pfunctor.o src/analysis/pmax.o src/analysis/pmin.o src/config/configfile.o src/data_collection/datacollector.o src/data_collection/linux/linfactory.o src/data_collection/linux/linmemprof.o src/data_collection/linux/lintimer.o src/data_collection/linux/procsmaps.o src/data_collection/linux/procstatus.o src/data_collection/pstructs.o src/data_collection/resultxml.o
DEP_FILES += src/analysis/analyzer.d src/analysis/comparer.d src/analysis/paverage.d src/analysis/pfunctor.d src/analysis/pmax.d src/analysis/pmin.d src/config/configfile.d src/data_collection/datacollector.d src/data_collection/linux/linfactory.d src/data_collection/linux/linmemprof.d src/data_collection/linux/lintimer.d src/data_collection/linux/procsmaps.d src/data_collection/linux/procstatus.d src/data_collection/pstructs.d src/data_collection/resultxml.d
clean.OBJ += $(Linux_Dynamic_target.BIN) $(Linux_Dynamic_target.OBJ)
Linux_Dynamic_target : Linux_Dynamic_target.before $(Linux_Dynamic_target.BIN) Linux_Dynamic_target.after_always
Linux_Dynamic_target : CFLAGS += -Wall -g -Os
Linux_Dynamic_target : INCLUDES +=
Linux_Dynamic_target : RCFLAGS +=
Linux_Dynamic_target : LDFLAGS += $(CREATE_LIB) $(CREATE_DEF)
Linux_Dynamic_target : T_LDLIBS =
ifdef LMAKE
Linux_Dynamic_target : CFLAGS -= -O1 -O2 -g -pipe
endif
Linux_Dynamic_target.before :
Linux_Dynamic_target.after_always : $(Linux_Dynamic_target.BIN)
$(Linux_Dynamic_target.BIN) : $(Linux_Dynamic_target.OBJ)
$(LINK_dll)
# -----------------------------------------
# Linux_Static_target
Linux_Static_target.BIN = libs/libperformer-1.a
Linux_Static_target.OBJ = src/analysis/analyzer.o src/analysis/comparer.o src/analysis/paverage.o src/analysis/pfunctor.o src/analysis/pmax.o src/analysis/pmin.o src/config/configfile.o src/data_collection/datacollector.o src/data_collection/linux/linfactory.o src/data_collection/linux/linmemprof.o src/data_collection/linux/lintimer.o src/data_collection/linux/procsmaps.o src/data_collection/linux/procstatus.o src/data_collection/pstructs.o src/data_collection/resultxml.o
DEP_FILES += src/analysis/analyzer.d src/analysis/comparer.d src/analysis/paverage.d src/analysis/pfunctor.d src/analysis/pmax.d src/analysis/pmin.d src/config/configfile.d src/data_collection/datacollector.d src/data_collection/linux/linfactory.d src/data_collection/linux/linmemprof.d src/data_collection/linux/lintimer.d src/data_collection/linux/procsmaps.d src/data_collection/linux/procstatus.d src/data_collection/pstructs.d src/data_collection/resultxml.d
clean.OBJ += $(Linux_Static_target.BIN) $(Linux_Static_target.OBJ)
Linux_Static_target : Linux_Static_target.before $(Linux_Static_target.BIN) Linux_Static_target.after_always
Linux_Static_target : CFLAGS += -Wall -g -Os
Linux_Static_target : INCLUDES +=
Linux_Static_target : RCFLAGS +=
Linux_Static_target : LDFLAGS += $(CREATE_DEF)
Linux_Static_target : T_LDLIBS =
ifdef LMAKE
Linux_Static_target : CFLAGS -= -O1 -O2 -g -pipe
endif
Linux_Static_target.before :
Linux_Static_target.after_always : $(Linux_Static_target.BIN)
$(Linux_Static_target.BIN) : $(Linux_Static_target.OBJ)
$(LINK_lib)
# -----------------------------------------
# -----------------------------------------------------------
else
# -----------------------------------------------------------
# -----------------------------------------
# Windows_Dynamic_target
Windows_Dynamic_target.BIN = libs/performer-1.so
Windows_Dynamic_target.OBJ = src/analysis/analyzer.o src/analysis/comparer.o src/analysis/paverage.o src/analysis/pfunctor.o src/analysis/pmax.o src/analysis/pmin.o src/config/configfile.o src/data_collection/datacollector.o src/data_collection/pstructs.o src/data_collection/resultxml.o src/data_collection/windows/winfactory.o src/data_collection/windows/wintimer.o
DEP_FILES += src/analysis/analyzer.d src/analysis/comparer.d src/analysis/paverage.d src/analysis/pfunctor.d src/analysis/pmax.d src/analysis/pmin.d src/config/configfile.d src/data_collection/datacollector.d src/data_collection/pstructs.d src/data_collection/resultxml.d src/data_collection/windows/winfactory.d src/data_collection/windows/wintimer.d
clean.OBJ += $(Windows_Dynamic_target.BIN) $(Windows_Dynamic_target.OBJ)
Windows_Dynamic_target : Windows_Dynamic_target.before $(Windows_Dynamic_target.BIN) Windows_Dynamic_target.after_always
Windows_Dynamic_target : CFLAGS += -Wall -g -Os
Windows_Dynamic_target : INCLUDES +=
Windows_Dynamic_target : RCFLAGS +=
Windows_Dynamic_target : LDFLAGS += $(CREATE_LIB) $(CREATE_DEF)
Windows_Dynamic_target : T_LDLIBS =
ifdef LMAKE
Windows_Dynamic_target : CFLAGS -= -O1 -O2 -g -pipe
endif
Windows_Dynamic_target.before :
Windows_Dynamic_target.after_always : $(Windows_Dynamic_target.BIN)
$(Windows_Dynamic_target.BIN) : $(Windows_Dynamic_target.OBJ)
$(LINK_dll)
ifdef MAKE_DEP
-include $(DEP_FILES)
endif
# -----------------------------------------------------------
endif
#
I beleive Glen's answer is incorrect as mak and mk (make) files are not at all the same. They are both used in automating builds but that's where the similarity ends.
mak file is a microsoft standard which can be built with the following command out of a visual studio command prompt:
nmake /f NAMEOFfile.mak
nmake is part of Visual Studio and the mak file's synthax/structure will also differ from mk (make) files.
Make or mk files are mainly used in Linux builds with some instances of Cross Platform support (provided that the Dev is supporting Windows). To build mk file you need either Autotools or CMake (these tools are available in both Windows and Linux). mk files will also be accompanied with a configure script that needs to be run before the make step which is not the case for mak/nmake.
I don't think there is a difference. It's just a makefile by a different name.
Try editing your question and posting up the contents of the .mak file and it'll be clearer to us then