which way is better to create a deb file? - build

I created a c++ library and now I am trying to create a .deb file.
There are 2 ways:
Short way: create directory with *.so and *.h files, edit "control" file and then run dpkg-deb --build ( for example Building a Debian package using dpkg-deb)
Long way: using debmake, debuild and more.. (as described in debian.org/..)
I don't understand what are the benefits to choose the long way (option 2)?

Related

Copying a newly builded file as a Dune's stanza

I have written a library in OCaml with all of its sources located in lib folder.
I also prepared "facade" executables in bin folder.
Now I would like to prepare some examples how to use the above mentioned executables.
To do this I need to either copy an executable beforehand or (preferably) tell Dune to use a newly created one after build.
And here is my question.
Dune's copy_files stanza does not allow1 me to copy from _build folder.
Is there any other way to use fresh executables each time after building or do I need to copy them at some point and keep up to date?
Below is the structure of the project (in case verbal description was misleading in any way).
root
lib <- source
bin <- frontend for source
examples <- how to use the above frontend
1 By not allow I mean the following usage of this stanza:
( copy_files %{project_root}/_build/default/bin/program.exe )
A solution, as suggested by #Lhooq, might be to use dune exec command with --root parameter.
In regard to the provided scenario, if we make a script:
dune exec --root=../.. ./bin/some_program.exe
(*
Where 'some_program' is the name of an .ml file located in bin folder.
I assumed here that the program is compiled to native code, not to bytecode (hence the .exe).
*)
and place it in examples directory, then by invoking it we will actually run the latest build of the program defined in some_program.ml located in bin folder.
And just to make things clear: bin folder does NOT contain any compiled files (neither .exe nor .bc) .

How to always re-generate version header file when underlying VERSION text file changes using CMake?

I maintain a C++ framework/library that uses CMake as its build system. The framework's version is reflected in a file called VERSION (as in many open source libraries).
I would like to generate a C++ header file with a version string, using VERSION as input. I also want this to happen during a re-build, not just when recreating project files. It would be desirable if VERSION was a dependency so the header file is created only when VERSION has changed.
I am familiar with the technique using the file() command in CMake to read the contests of VERSION, e.g.
file(STRINGS "VERSION" FRAMEWORK_VERSION)
And then generating a file using the configure_file command, e.g.:
configure_file(version.h.in version.h)
But this only generates the header file during the generation of project files. If the VERSION file is changed, the version header file will not be re-generated when re-building (i.e. running cmake --build .).
I know I can use like a Python script run as a CMake macro and always create the version header during the build, but I find it a bit annoying.
What is the best practice here?
Isn't it possible to solve this by only using CMake?
One CMake-only solution is to wrap the commands you suggested in a custom target to run a CMake script. If you make your library depend on the custom target, it will behave per the following:
Generates version.h at compile-time, before building your library.
Only re-generates version.h if its contents will change (new version number or new template file, version.h.in)
The script (let's say VersionHeader.cmake) for the custom target will read the version number from the VERSION file, and generate a new version.h file if necessary. The script can look like this:
file(STRINGS "${CMAKE_SOURCE_DIR}/VERSION" FRAMEWORK_VERSION)
configure_file(${CMAKE_CURRENT_LIST_DIR}/version.h.in ${CMAKE_CURRENT_LIST_DIR}/version.h #ONLY)
Then, in your CMakeLists.txt file, define a custom target to run a script:
add_custom_target(VersionHeader
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_LIST_DIR}/VersionHeader.cmake
)
add_dependencies(MyFrameworkLib VersionHeader)

Build folder and makefile

The question comes from my puzzlement when compiling a makefile for Deep Learning framework Caffe on Ubuntu, but it relates, I believe, to a more general phenomenon of the nature of compiling a C++ makefile.
After "make all", the resulting files from the compilation were put in a hidden folder: .build_release, not in the respective folders where the cpp files are.
Then when I tried to run the following lines:
./data/mnist/get_mnist.sh
./examples/mnist/create_mnist.sh
I was getting an error that the system does not find the file:
./create_mnist.sh: 16: ./create_mnist.sh: build/examples/mnist/convert_mnist_data.bin: not found
But the file actually existed in the .build_release folder.
What happened and how to fix this problem?
The issue is not with make, you simply need to follow the instructions carefully. The BUILD_DIR is specified by Makefile.config. By default this folder is named build. Once you followed the compilation instructions:
cp Makefile.config.example Makefile.config
# Adjust Makefile.config (for example, if using Anaconda Python)
make all
make test
make runtest
Navigate to build:
cd build
./data/mnist/get_mnist.sh
./examples/mnist/create_mnist.sh

Compile proftpd and include a library copy inside the installation directory

I do already ask a quiet similar question but in fact I now change my mind.
Id like like to compile proftpd and add a copy of the library it uses to the choosen installation directory.
Let's say I define a prefix in my compilation like:
/usr/local/proftpd
Under this directory I would like to find and use those directories only :
./lib
./usr/lib
./usr/bin
./usr/.....
./etc
./var/log/proftpd
./bin
./sbin
./and others I will not put the whole list
So the idea is after I have all libraries and config file in my main directory I could tar it and send it on another server with the same OS and without installing all the dependencies of protfpd I could use it.
I know it does sound like a windows installer not using shared library but that's in fact exactly what I'm trying to accomplish.
So far I have manage to compile it on AIX using this command line:
./configure --with-modules=mod_tls:mod_sql:mod_sql_mysql:mod_sql_passwd:mod_sftp:mod_sftp_sql --without-getopt --enable-openssl --with-includes=/opt/freeware/include:/opt/freeware/include/mysql/mysql/:/home/poney2/src_proftpd/libmath_header/ --with-libraries=/opt/freeware/lib:/opt/freeware/lib/mysql/mysql/:/home/poney2/src_proftpd/libmath_lib --prefix=/home/poney/proftpd_bin --exec-prefix=/home/poney/proftpd_bin/proftpd
Before trying to ask me why I'm doing so, it's because I have to compile proftpd on IBM AIX with almost all modules and this is not available on the IBM rpm binary repositories.
The use of this LDFLAG
LDFLAGS="-Wl,-blibpath:/a/new/lib/path"
where /a/new/lib/path contains all your library does work with Xlc and Gcc compiler.

Eclipse c++ How to work with existing makefile

I'm a newbie and I've a problem!
I've to work with a c++ code and I don't know how to import it and how to compile it on eclips ( I compiled it by command line).
The code has a particular structure and it is organized in this way:
repos____lib____configure (execute the configure file inside the libraries folders)
I I___makefile (execute the make file inside the libraries folders,
requires make/make.def)
I I___ib1____.cpp
I I I____.h
I ... I____configure (it requires make/configure_lib and
make/configure_includes
I ... I____makefile (generated by configure)
I I___lib2___....
i I___.......
I I___libn____.cpp
i I____.h
i I____configure
i I____makefile (generated by configure)
I
I___make(folder)__bashrc (are set the some environment variables)
I I__configure_bin
I I__configure_includes
I I__configure_lib
I I__make.def (are set all the include path and library path used
I in the configure file)
I___application__main.cpp
I__configure
I__makefile(generated by the configure file)
to be sure that you understand my problem...(sure... :) )
the first configure file is:
cd lib1; ./configure
cd ../lib2; ./configure
.....
....
cd ../libn; ./configure
cd
and the first makefile is
include /media/Dati/WORKHOME/repos/make/make.def
this is the makefile for the whole library
lib:
make -C lib1
make -C lib2
make -C libn
an example of configure file (the one inside lib1):
#!/usr/bin/perl
$INC = '$(OPENCVINC) $(FLTKINC) $(DC1394V2INC)'; ##<-DEFINED IN /make.def
$LIB = '$(OPENCVLIB) $(FLTKLIB) $(DC1394V2LIB)'; #####################
#-------------------------------------------------------------------------------
require '/media/Dati/WORKHOME/repos/make/configure_lib';
print "Created Makefile.\n";
# this will create a include file for the whole directory,
# using the template <dirname>.h.templ
require '/media/Dati/WORKHOME/repos/make/configure_includes';
print "Created $libname.h\n";
compile it without eclipse is simple
type /.configure in the lib folder
type make
go into the application folder
type ./configure
type make
run the program
my question is....in eclipse???
I imported the three with import/ import existing code as makefile project but now I don't know how compile it.
could you please help me? it's important!
thank you very much
gabriele
You have done the right thing by using "import existing code as makefile project".
Now eclipse know that it needs to call make and use your makefile. But Your build process is not only driven by make.
One solution is to write a makefile that call all your build steps. Something Like :
all:
cd dir1 && ./configure && make
cd dir2 && ./configure && make
etc.
my2c
Edit:
I currently have no eclipse installed, so I can not send you detailled steps ... sorry