I download POSIX Threads for Windows source code from https://sourceforge.net/projects/pthreads4w/files/.
Unzip it. In the directory, there several files for make:
Bmakefile Makefile Nmakefile GNUmakefile.in
If directly run mingw32-make, I get
Makefile:123: *** missing separator. Stop.
Open makefile in editor, the first line told me:
This makefile is compatible with MS nmake
Maybe it is not a standard makefile file?
So, I just delete makefile. and change the name of GNUmakefile.in into makefile. Then run 'mingw32-make' again, I get
process_begin: CreateProcess(NULL, #RC# --help, ...) failed.
mingw32-make: makefile:112: pipe: No error
makefile:180: #srcdir#/common.mk: No such file or directory
mingw32-make: *** No rule to make target '#srcdir#/common.mk'. Stop.
I don't really know how make actualy working. But if I want to compile it, what should I do?
===========================================================
UPDATE
There is README file, and it suggest how to build using MINGW. But seems all it told(like autoheader autoconf ) are not windows commands.
Building with MinGW
NOTE: All building and testing is done using makefiles. We use the
native make system for each toolchain, which is 'make' in this case.
We have found that Mingw builds of the GCE library variants can fail
when run on 64 bit systems, believed to be due to the DWARF2 exception
handling being a 32 bit mechanism. The GC variants are fine. MinGW64
offers SJLJ or SEH exception handling so choose one of those.
From the source directory:
run 'autoheader' to rewrite the config.h file
run 'autoconf' to rewrite the GNUmakefiles (library and tests)
run './configure' to create config.h and GNUmakefile.
run 'make' without arguments to list possible targets.
E.g.
$ autoheader
$ autoconf
$ ./configure
$ make realclean all-tests
===========================================================
UPDATE
Seems the MINGW I downloaded already contains pthreads library. I don't need to compile it now.
Related
I have compiled QT-5.8 from github successfully, each submodule is cloned by init-repository provided by QT. However, in Qt5.8, it has removed qtwebkit.
But my app needs qtwebkit, so I clone qtwebkit submodule and qmake it.
However, it shows the compilation errors
( test -e Makefile.api || /usr/local/Qt-5.8.0/bin/qmake -o Makefile.api /home/tumh/qt5/qtwebkit/Source/api.pri ) && make -f Makefile.api
make[1]: Entering directory '/home/tumh/qt5/qtwebkit/Source'
make[1]: *** No rule to make target '/home/tumh/qt5/qtwebkit/Source/WebCore//libWebCore.a', needed by '../lib/libQt5WebKit.so.5.8.0'. Stop.
make[1]: Leaving directory '/home/tumh/qt5/qtwebkit/Source'
Makefile:40: recipe for target 'sub-api-pri-make_first-ordered' failed
make: *** [sub-api-pri-make_first-ordered] Error 2
I have no idea that how to compile a single submodule in QT.
Any suggestion is appreciated.
thanks!
You should take tarball of webkit from official releases. It should build fine with Qt-5.8.
The following describes how to compile qtwebkit module so it is usable with Qt 5.9.9. I assume the process is similar if not identical for Qt 5.8.
An overview of the process
All of the required components should be compiled using one tool chain. I suggest using the one installed with Qt.
You gonna need ICU compiled, the source code can be obtained from the official site.
The source code of qtwebkit module that we want to compile is available here (thx #J. Doe for the link!)
Regardless of the operating system you are working on, in order to compile qtwebkit module you gonna need the following additional tools:
ruby
gperf
flex
bison
python 2
Qtwebkit module depends on declarative module. It becomes available when qtquick1 is installed.
It is assumed that Qt 5.9.9 is installed. I was using these installers.
The process takes some time so if you need the module ready ASAP go to the last section (What if you cannot perform some of the above steps).
Compiling on Windows (tested on Win10)
On Windows I recommend using chocolatey to install additional tools.
Compiling ICU
Install msys2 package via chocolatey. It allows to use the scrips provided with ICU source code with very few modifications.
Installation script requires make program available. It doesn't matter if mingw32-make is virtually (of even literally) the same tool. Copy mingw32-make.exe and rename it to make.exe.
Using cmd with integrated mingw tools (installed along with Qt) open msys2 shell forwarding the PATH variable.
msys2_shell -use-full-path
Go to the ICU source code directory (mine was C:\icu\source) and run
./runConfigureICU MinGW -prefix=$PWD/../dist
(It is expected to encounter "unknown platform" issue, no worries)
Now run:
gcc -dumpmachine
Save the output, in my case it was i686-w64-mingw32.
Using this result execute:
./configure -build=i686-w64-mingw32 -prefix=$PWD/../dist
(modify build parameter according to the result of the previous step)
Now, you should be able to compile ICU with:
make & make install
(If you want to speed things up you can engage multiple CPU cores in the above process. For example in order to engage 777 cores execute make -j777 & make install)
Assuming your ICU source code was in C:\icu\source directory, the result of the compilation should be in C:\icu\dist.
Compiling qtwebkit module
As said in the first section, compiling qtwebkit module requires additional tools.
They can be installed via chocolatey using the following command:
choco install ruby gperf winflexbison python2
This, among others, installs win_flex.exe and win_bison.exe. As of this writing these executables are located (at least in my case) in C:\ProgramData\chocolatey\lib\winflexbison\tools .
The qmake checks for programs named bison.exe and flex.exe. So I have copied both win_flex.exe and win_bison.exe and renamed them flex.exe and bison.exe accordingly.
The last step is to add both of these programs to PATH variable.
To do so execute (in cmd with integrated mingw tools) the following command:
set PATH=C:\ProgramData\chocolatey\lib\winflexbison\tools;%PATH%
Additionally you need to point to the directory where includes and libs of compiled ICU are located. I have done it like this:
set PATH=C:\icu\dist\bin;%PATH%
set INCLUDE=C:\icu\dist\include;
set LIB=C:\icu\dist\lib;
Above assumes that prior to executing this commands there was no variables named INCLUDE and LIB set in the currently used cmd.
Finally, qmake process checks for a variable named SQLITE3SRCDIR.
As suggested by this answer you can set it to sqlite sources provided with Qt. In my case it was done like this:
set SQLITE3SRCDIR=C:\Qt\Qt5.9.9\5.9.9\Src\qtbase\src\3rdparty\sqlite
Now (using the same cmd) go to the directory where Qt sources are located and execute configure.bat. I have done both of these steps with:
cd C:\Qt\Qt5.9.9\5.9.9\Src
configure.bat
Finally, extract the downloaded source code of the qtwebkitmodule to the sources directory of Qt (C:\Qt\Qt5.9.9\5.9.9\Src in my case) and make a module. I have done it like this:
cd qtwebkit-opensource-src-5.9.0
mkdir build
cd build
qmake -r ..
make
make install
It is strongly recommended to utilize multiple cores in the make process, otherwise prepare yourself for a very long compilation.
Now you should be able to use webkit and webkitwidgets in your Qt projects.
Compiling on Linux (tested on LUbuntu 18.04)
I suggest using compilation tools provided with Qt instead of default make and g++ compiler. To do so I have exported path to the tools provided with Qt like this:
export PATH=/home/$USER/Qt5.9.9/5.9.9/gcc_64/bin/:$PATH
You gonna need ICU compiled. I suggest using version 56.1 as it is the same shipped with Qt 5.9.9. The compilation process is almost identical as it was described for Windows. the only difference is that you run:
./runConfigureICU Linux/gcc --prefix=$PWD/../dist
and later configure script can be omitted on Linux.
On lUbuntu 18.04 I needed the following packages installed:
apt-get install ruby bison gperf python flex perl libx11-dev xserver-xorg-dev xorg-dev libpulse-dev libsqlite3-dev
As with compiling qtwebkit on Windows, you gonna need qtquick1 module installed.
I have encountered an error saying that some headers related to OpenGL were missing. If you have the same problem then in my case installing libgl1-mesa-dev package solved it.
Now extract source code of qtwebkit module sources directory of your Qt installation. In my case it was "/home/$USER/Qt5.9.9/5.9.9/Src".
Modify WTF.pri file and add the path to ICU includes and libs after the first INCLUDEPATH. In my case it was done like this:
...
INCLUDEPATH += /home/$USER/icu/dist/include/
LIBS += -L/home/$USER/icu/dist/lib/
...
Note '-L' is placed before path pointing to libs.
Now you should be able to compile qtwebkit module in usual manner:
mkdir build
cd build
qmake -r ..
make & make install
What if you cannot perform some of the above steps
You can always try to use prebuild binaries:
https://download.qt.io/snapshots/ci/qtwebkit/5.9/latest/qtwebkit/
or unofficial fork of the qtwebkit module:
https://github.com/qtwebkit/qtwebkit/releases
I want to create a .exe of ndpiReader.c demo program that comes with nDPI library. I was successful to compile it on Ubuntu using commands specified on their github page as bellow:
./autogen.sh
./configure
make
I have tried to cross compile it using GCC inside Ubuntu but I wasn't successful. I also tried to use the pcapExample.sln to compile it in Visual Studio 2012, but I keep getting error messages like:
Error 29 error C1083: Cannot open include file: 'ndpi_api.h': No such file or directory
Although ndpi_api.h and all other files that I get this error for already are listed in the project solution explorer.
Has anyone actually been able to make a win32 executable out of this ndpiReader.c file? If yes, please specify the steps, requirements, or a link.
nDPI lib is hosted here: https://github.com/ntop/nDPI
ndpiReader.c is hosted here: https://github.com/ntop/nDPI/tree/dev/example
pcapExample.sln is hosted here: https://github.com/ntop/nDPI/tree/dev/example/Win32
I saw from your other questions that you had already tried to compile this with CYGWIN and ran into a number of problems.
Here’s a step-by-step guide I just used to compile nDPI (including the ndpiReader.exe example):
Install CYGWIN:
Accept the default directories, and pick a mirror.
At the Select Packages step, expand the Devel category, and select the following developer packages to install:
autoconf
autoconf2.5
automake
automake1.15
binutils
cmake
cygwin-devel
gcc-core
gcc-tools-epoch2-autoconf
gcc-tools-epoch2-automake
libtool
make
pkg-config
w32api-headers
w32api-runtime
Install libpcap under CYGWIN:
Download and unpack the Winpcap Developer's pack.
Copy libpacket.a and libwpcap.a from WpdPack\Lib\ to cygwin\lib\
In cygwin\lib, copy libwpcap.a to libpcap.a
In cygwin\usr\include, create a pcap directory
Copy all headers from WpdPack\Include to cygwin\usr\include\pcap
I'm sure you've installed winpcap already as part of everything else you've tried, but double-check that the necessary (packet.dll and wpcap.dll) libraries are already in cygwin\c\WINDOWS\system32.
Now you've got all the necessary tools and libraries to compile nDPI on Windows!
Building nDPI
Download and unpack nDPI again in a clean directory, so you don't get tripped up by any issues from the previous build you tried.
Open a CYGWIN terminal, and cd into the nDPI directory.
Run autogen.sh
./autogen.sh
This should complete without any errors.
If it stops with "somepackage is missing: please install it and try again," you've missed installing a CYGWIN package that is needed to build the source.
If it stops with "Missing libpcap(-dev) library," double-check the previous steps you did to copy libpcap.a in cygwin\lib.
autogen.sh should start running the configure stage for you. (If it doesn't, or part of this stage fails, you can rerun configure after fixing any issue.)
./configure
After checking for a number of things, configure will end by creating a Makefile.
Build the nDPI library, by running make.
make
It will build the library, then try to build the examples, but fail because it can't find pcap.h
cd into the example directory, and manually compile ndpiReader.c by adding -I/usr/include/pcap to the command:
cd example/
gcc -DHAVE_CONFIG_H -I. -I.. -I../src/include -I/usr/include/pcap -g -O2 -c -o ndpiReader.o ndpiReader.c
I included my command as an example. If your compiler command is slightly different, just add -I/usr/include/pcap to what your Makefile had invoked.
Leave the example directory, and resume the make.
cd ..
make
This last step will link ndpiReader with the ndpi library, and create the executable you're looking for.
I'm trying to install cross-compiler using that tutorial .
I got stuck cross-compiling GCC version 4.9.1 using my native linux-GCC compiler. I occured an error during the installation and the solution is to build it in non-source directory. However, I have no idea how can I do it. I've read the documentation. However, it hasn't helped me.
I just want to install C++ and C version.
I haven't done this for ages but I think it means create a new empty directory and run configure from there, i.e. rather than
cd /usr/src/crosscompiler
./configure ...
do
mkdir /usr/src/crosscompiler-build
cd /usr/src/crosscompiler-build
/usr/src/crosscompiler/configure ...
which will then set up the build environment and make files in that new directory to use the source tree from the old directory. (If that doesn't work, you could try putting the empty directory inside the source tree, e.g. /usr/src/crosscompiler/build)
That all said, I thought a separate build directory has been the only way to build GCC for 10+ years, so I'm surprised the tutorial says anything different. You can build binutils into a separate path too, and there are ways of combining the GCC and binutils sources so that they can be built in one go too.
I've checked out a ROS package that I have on my repository on a different PC (ubuntu).
The problem is that while rosmake (or make for that matter) from cli, in eclipse it gives me the following error.
/usr/bin/make all
rospack: error while loading shared libraries: librospack.so: cannot open shared object file: No such file or directory
Makefile:1: /cmake.mk: No such file or directory
make: * No rule to make target `/cmake.mk'. Stop.
I suppose it's problem is eclipse's build enviroment. How do I debug this?
Shouldn't it work out of the box?
It seems that because I was running eclipse from an icon it couldn't get the environment variables. I had to change the link to bash -i -c eclipse.
I am trying to use CMake in order to compile opencv.
I am reading the tutorial but can't understand what is CMakeLists files and how is it connected to the gui of CMake?
Also couldn't understand what are makefiles, are they the same is CMakeLists?
And which file is it which I in the end open with visual-studio?
I don't know about Windows (never used it), but on a Linux system you just have to create a build directory (in the top source directory)
mkdir build-dir
go inside it
cd build-dir
then run cmake and point to the parent directory
cmake ..
and finally run make
make
Notice that make and cmake are different programs. cmake is a Makefile generator, and the make utility is governed by a Makefile textual file. See cmake & make wikipedia pages.
NB: On Windows, cmake might operate so could need to be used differently. You'll need to read the documentation (like I did for Linux)
CMake takes a CMakeList file, and outputs it to a platform-specific build format, e.g. a Makefile, Visual Studio, etc.
You run CMake on the CMakeList first. If you're on Visual Studio, you can then load the output project/solution.
Yes, cmake and make are different programs. cmake is (on Linux) a Makefile generator (and Makefile-s are the files driving the make utility). There are other Makefile generators (in particular configure and autoconf etc...). And you can find other build automation programs (e.g. ninja).
CMake (Cross platform make) is a build system generator. It doesn't build your source, instead, generates what a build system needs: the build scripts. Doing so you don't need to write or maintain platform specific build files. CMake uses relatively high level CMake language which usually written in CMakeLists.txt files. Your general workflow when consuming third party libraries usually boils down the following commands:
cmake -S thelibrary -B build
cmake --build build
cmake --install build
The first line known as configuration step, this generates the build files on your system. -S(ource) is the library source, and -B(uild) folder. CMake falls back to generate build according to your system. it will be MSBuild on Windows, GNU Makefiles on Linux. You can specify the build using -G(enerator) paramater, like:
cmake -G Ninja -S libSource -B build
end of the this step, generates build scripts, like Makefile, *.sln files etc. on build directory.
The second line invokes the actual build command, it's like invoking make on the build folder.
The third line install the library. If you're on Windows, you can quickly open generated project by, cmake --open build.
Now you can use the installed library on your project with configured by CMake, writing your own CMakeLists.txt file. To do so, you'll need to create a your target and find the package you installed using find_package command, which will export the library target names, and link them against your own target.
Cmake from Windows terminal:
mkdir build
cd build/
cmake ..
cmake --build . --config Release
./Release/main.exe
Regarding CMake 3.13.3, platform Windows, and IDE Visual Studio 2017, I suggest this guide. In brief I suggest:
1. Download cmake > unzip it > execute it.
2. As example download GLFW > unzip it > create inside folder Build.
3. In cmake Browse "Source" > Browse "Build" > Configure and Generate.
4. In Visual Studio 2017 Build your Solution.
5. Get the binaries.
Regards.