I can successfully build protobuf in Windows, it result in three .lib files, but don't know how to build protobuf-c in Windows, there are no documents about it.
i was able to do that with Cygwin:
you can download the sources from here https://github.com/protobuf-c/protobuf-c
depending on the protobuf that you've compiled you can download the "right" version of the protobuf-c.
generally speaking, to build with Cygwin you'll need to add on top of the default installation:
gcc and the tools around it.
tools to build protobuf and protobuf-c as documented in the Github of each (https://github.com/protobuf-c/protobuf-c). build protobuf again i suspect for Cygwin to recognize it?
build as told (same for both):
./autogen.sh
./configure --prefix=/usr
make
make install
Related
I'm trying to install libwebsockets C library with vcpkg according to the instruction. And don't understand something.
OS - Ubuntu 20.04
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg install [library-name]
Library is installed and what to do next? How to compile test files with the library?
The question is more about how to use vcpkg on linux.
You can give an example of another library installed with vcpkg.
vcpkg is a C/C++ package manager, it is very necessary in windows.
However, in ubuntu, itself provides a very complete package management mechanism.
Therefore, even if you are building a cross platform software system, do not use vcpkg in ubuntu :)
You can try this:
$> sudo apt install libwebsockets-dev
In this way, the libwebsockets header files and library files you need have been installed and can be used directly.
Here is another example:
I want to install gtkmm4 in ubuntu 20.04 LTS, since gtkmm4 is not available for apt download I'm installing it with vcpkg.
for simplification, I'm setting VCPKG_DIR to the vcpkg directory I cloned.
export VCPKG_DIR=/path/to/vckpg
Then for a C++ program, you can write CMake file like below
PROJECT(gtkmmtest)
cmake_minimum_required(VERSION 3.10)
set(VCPKG_DIR $ENV{VCPKG_DIR})
include(${VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake) # --> important
# Use the package PkgConfig to detect GTK+ headers/library files
FIND_PACKAGE(PkgConfig REQUIRED)
FIND_PACKAGE(Threads REQUIRED)
pkg_check_modules(GTK4 REQUIRED gtk4)
PKG_CHECK_MODULES(GTKMM gtkmm-4.0)
include_directories(${GTK4_INCLUDE_DIRS})
include_directories(${GTKMM_INCLUDE_DIRS})
link_directories(${VCPKG_DIR}/packages/gtk_x64-linux/lib)
link_directories(${GTK4_LIBRARY_DIRS})
add_definitions(${GTK4_CFLAGS_OTHER})
target_link_libraries(${GTKMMTEST} PRIVATE ${GTK4_LIBRARIES} ${GTKMM_LIBRARIES} pthread)
Complete CMake file can be found here
You can still use the the standard include_directories and link_directories if there is no PkgConfig avilable.
eg:
include_directories(${VCPKG_DIR}/packages/gtkmm_x64-linux/include/gtkmm-4.0/)
Library is installed and what to do next? How to compile test files with the library?
The question is more about how to use vcpkg on linux.
The answer to this question really depends on your buildsystem and the port/library you want to use and not the platform itself.
In the case of libwebsockets libwebsockets-config.cmake get installed so you could use CMake and do a find_package(libwebsockets CONFIG REQUIRED) to get the imported targets the port exports within LibwebsocketsTargets.cmake. Of course this requires setting CMAKE_TOOLCHAIN_FILE to the vcpkg toolchain (<vcpkg_root>/scripts/buildsystems/vcpkg.cmake) or including it before the first project() in your CMakeLists.txt (more details are mentioned in the vcpkg docs which you hopefully read....)
Other libraries/ports might export *.pc files. For these FindPkgConfig.cmake can be used directly (see CMake docs) or you can setup PKG_CONFIG_PATH and prepend <vcpkg_root>/installed/<triplet (here probably: x64-linux)>/(debug/)lib/pkgconfig for other buildsystems like autotools or manual makefiles etc.
In the end how to use vcpkg or more precisly the libraries from it depends on what buildsystem you intend to use.
I'm a python developer new to C and developing C code on Windows that needs to work on Windows and Linux.
To that end, I downloaded MSYS2 and used pacman to install gcc and bz2.
My question is: How do I use bzip2 in my C code.
When I try to compile this C code:
#include <bzlib.h>
using the command gcc test.c -lbzip2 -o test.out I get the following error:
test.c:1:10: fatal error: bzlib.h: No such file or directory
Am I including the correct header file? Am I linking it correctly?
When not using 3rd party libraries a simple "hello world" program compiles and executes fine.
Short version: assuming you are using the MSYS target, pacman -S libbz2-devel.
Long version: In MSYS2 you can find which package contains a file using:
pacman -F bzlib.h
to which the answer is:
mingw32/mingw-w64-i686-bzip2 1.0.8-1 [installed]
mingw32/include/bzlib.h
mingw64/mingw-w64-x86_64-bzip2 1.0.8-1 [installed]
mingw64/include/bzlib.h
msys/libbz2-devel 1.0.8-1 (development)
usr/include/bzlib.h
To interpret this output, first understand that an MSYS2 installation supports three different development targets:
mingw32 (builds native Win32 applications using mingw-w64)
mingw64 (builds native Win64 applications using mingw-w64)
msys (builds Win32 or Win64 applications that depend on MSYS DLLs and runtime environment, using a custom GCC port and runtime library, and supports a lot of POSIX functionality).
When you install MSYS2 you will get three startup scripts in the Start Menu , one for each of those environments.
The output of pacman -F above told us that for targets mingw32 and mingw64, the package bzip2 contains the files required to do development with bzip. However, on the msys target, the package libbz2-devel is required.
This is a common package layout in msys and in the various *nix package managers (MSYS2 pacman is a port of ArchLinux pacman):
bzip2 is the binaries for using bzip2 in your shell
libbz2 is a shared object binary (DLL)
libbz2-devel is the header files and static libraries that you need to link bzip2 into your program.
You can list the files for each package with pacman -F --list libbz2-devel etc.
The mingw32/mingw64 targets typically have single packages that include all of those three things in the one package, e.g. pacman -F --list mingw64/mingw-w64-x86_64-bzip2.
I assume you are using msys target as otherwise this question would not have arisen .
Installing all the binary packages listed here and changing the header filename to bzlib.h fixed the problem.
I am having trouble installing the FFTW library on Windows. I am following instructions from the following link:
http://www.fftw.org/fftw3_doc/Installation-on-non_002dUnix-systems.html#Installation-on-non_002dUnix-systems
1)
After downloading minGW 64-bit, I was wondering how I would access the "kernel" and "simd-support" directory to compile the c files as recommended.
2)
As I am unfamiliar with this library, is there a better way of installing the library using the command line?
As written in this link, under the subtitle "building FFTW3 under minGW":
http://www.fftw.org/install/windows.html
when I run the following commmand:
./configure --with-our-malloc16 --with-windows-f77-mangling --enable-shared --disable-static --enable-threads --with-combined-threads --enable-portable-binary --enable-sse2 --with-incoming-stack-boundary=2
I get:
'.' is not recognized as an internal or external command
any help would be much appreciated
For FFTW 3.3.10, I installed Cygwin with the mingw64-gcc package. From within the Cygwin command window, I set the following two variables:
export CC=x86_64-w64-mingw32-gcc.exe
export AR=x86_64-w64-mingw32-ar.exe
Next, I added "#define FFTW_DLL" to the fftw3.h header before building. I configured the build with the following command:
./configure --prefix=/cygdrive/c/fftw-build --with-our-malloc16 --with-windows-f77-mangling --enable-shared --disable-static --enable-threads --with-combined-threads --enable-sse2 --enable-avx --enable-avx2 --enable-avx512 --enable-avx-128-fma --with-incoming-stack-boundary=2 -disable-fortran --disable-alloca
and then I ran
make
make check
make install
Once that was done, the resulting desired DLL was in the bin directory, not the lib one. I followed the instructions in BUILD-MINGW64.sh from the fftw.org website to create the .def text file, and ran
lib /machine:x64 /def:libfftw3-3.def
on that text file to get the required .lib. VS2017 seems to be happy with that.
You are running your configure script in the cmd/power shell. You have to run your configure command in the MinGW shell.
http://www.fftw.org/install/windows.html has prebuilt libraries. They offer well maintained and optimised builds for 32bit and 64bit applications.
I am building a web server using the libwebsockets library on a TS-7800 board using the arm-linux-gcc cross compiler. Using Ubuntu. Installed CMake, OpenSSL, and libwebsockets and built the library per the instructions on Github.
I made a "hello world" C file which #includes libwebsockets.h
When I compile the executable with gcc, it compiles fine and the .exe runs.
When I compile with arm-linux-gcc, I get the following:
root#gordon-MS-7A39:/# arm-linux-gcc -o hellosockets /home/gordon/workspace/HelloCrossWorld/hello_cross.c
/home/gordon/workspace/HelloCrossWorld/hello_cross.c:3:27: libwebsockets.h: No such file or directory
It appears that arm-linux-gcc compiler cannot "see" the header file for libwebsockets. I'm guessing that the installation of the websockets library was successful because gcc can see it.
How do I enable the arm cross compiler to see the libwebsockets.h file?
Thank you for your input!
You'll need to add armhf architecture to your package management system. Perform the following actions as super user:
dpkg --add-architecture armhf
apt update
apt install libwebsockets-dev:armhf
Make sure you're also using the armhf toolchain:
apt install binutils-arm-linux-gnueabihf g++-arm-linux-gnueabihf
Alternatively, take a look at Buildroot
I was unaware of the -I and -L preprocessor options for gcc and arm-linux-gcc.
I was able to add libraries to the project and will look into creating makefiles for the project.
I have a git repository which I can build with:
./autogen.sh
./configure
make
sudo make install
Now I want to cross compile it for windows with the mingw32/mingw-w64 cross compiler.
I tried it with
export CXX=/usr/bin/x86_64-w64-mingw32-gcc
but that didn't work for me.
I have configure eclipse that I can compile windows executables as well, that works, but only with plane c code. Now I need external libraries, which I have to compile for windows as well.
As described on a(n old, but mostly correct) page of the MinGW-w64 wiki (written by yours truly a long time ago):
./configure --host=x86_64-w64-mingw32
should do the trick if the package doesn't need special handling for Windows.